Skip to content

chore(deps): remove read-pkg-up #4043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@
"prettyjson": "^1.2.1",
"pump": "^3.0.0",
"raw-body": "^2.4.1",
"read-pkg-up": "^7.0.1",
"semver": "^7.3.5",
"source-map-support": "^0.5.19",
"static-server": "^2.2.1",
Expand Down
21 changes: 17 additions & 4 deletions src/lib/functions/runtimes/js/builders/zisi.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const { mkdir, writeFile } = require('fs').promises
const { mkdir, readFile, writeFile } = require('fs').promises
const path = require('path')

const { zipFunction } = require('@netlify/zip-it-and-ship-it')
const decache = require('decache')
const readPkgUp = require('read-pkg-up')
const findUp = require('find-up')
const sourceMapSupport = require('source-map-support')

const { NETLIFYDEVERR } = require('../../../../../utils')
Expand Down Expand Up @@ -79,13 +79,26 @@ const getTargetDirectory = async ({ errorExit }) => {
return targetDirectory
}

const readPackageJson = async (func) => {
const cwd = path.dirname(func.mainFile)
const packageJsonPath = await findUp('package.json', { cwd, type: 'file' })

if (!packageJsonPath) {
return
}

const packageJson = await readFile(packageJsonPath, 'utf-8')

return JSON.parse(packageJson)
}

module.exports = async ({ config, directory, errorExit, func, projectRoot }) => {
const functionsConfig = addFunctionsConfigDefaults(
normalizeFunctionsConfig({ functionsConfig: config.functions, projectRoot }),
)

const packageJson = await readPkgUp(func.mainFile)
const hasTypeModule = packageJson && packageJson.packageJson.type === 'module'
const packageJson = await readPackageJson(func)
const hasTypeModule = packageJson && packageJson.type === 'module'

// We must use esbuild for certain file extensions.
const mustTranspile = ['.mjs', '.ts'].includes(path.extname(func.mainFile))
Expand Down