Skip to content

Commit

Permalink
fix(deps): update dependency @vercel/nft to ^0.17.0 (#765)
Browse files Browse the repository at this point in the history
* fix(deps): update dependency @vercel/nft to ^0.17.0

* chore: adapt to changed NFT type

* fix: make checksum deterministic

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Netlify Team Account 1 <netlify-team-account-1@users.noreply.github.com>
Co-authored-by: Eduardo Bouças <mail@eduardoboucas.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
5 people committed Oct 26, 2021
1 parent a78451c commit 14c19f1
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 49 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -59,7 +59,7 @@
"dependencies": {
"@babel/parser": "^7.15.7",
"@netlify/esbuild": "^0.13.6",
"@vercel/nft": "^0.15.1",
"@vercel/nft": "^0.17.0",
"archiver": "^5.3.0",
"array-flat-polyfill": "^1.0.1",
"common-path-prefix": "^3.0.0",
Expand Down
13 changes: 10 additions & 3 deletions src/runtimes/node/bundlers/nft/index.ts
Expand Up @@ -49,13 +49,16 @@ const bundle: BundleFunction = async ({
const filteredIncludedPaths = filterExcludedPaths([...dependencyPaths, ...includedFilePaths], excludedPaths)
const dirnames = filteredIncludedPaths.map((filePath) => normalize(dirname(filePath))).sort()

// Sorting the array to make the checksum deterministic.
const srcFiles = [...filteredIncludedPaths, ...transpilation.keys()].sort()

return {
aliases: transpilation,
basePath: getBasePath(dirnames),
cleanupFunction,
inputs: dependencyPaths,
mainFile,
srcFiles: [...filteredIncludedPaths, ...transpilation.keys()],
srcFiles,
}
}

Expand Down Expand Up @@ -113,7 +116,9 @@ const traceFilesAndTranspile = async function ({
}
},
})
const normalizedDependencyPaths = dependencyPaths.map((path) => (basePath ? resolve(basePath, path) : resolve(path)))
const normalizedDependencyPaths = [...dependencyPaths].map((path) =>
basePath ? resolve(basePath, path) : resolve(path),
)

// We look at the cache object to find any paths corresponding to ESM files.
const esmPaths = [...(cache.analysisCache?.entries() || [])].filter(([, { isESM }]) => isESM).map(([path]) => path)
Expand Down Expand Up @@ -150,7 +155,9 @@ const getSrcFiles: GetSrcFilesFunction = async function ({ basePath, config, mai
includedFilesBasePath,
)
const { fileList: dependencyPaths } = await nodeFileTrace([mainFile], { base: basePath, ignore: ignoreFunction })
const normalizedDependencyPaths = dependencyPaths.map((path) => (basePath ? resolve(basePath, path) : resolve(path)))
const normalizedDependencyPaths = [...dependencyPaths].map((path) =>
basePath ? resolve(basePath, path) : resolve(path),
)
const includedPaths = filterExcludedPaths([...normalizedDependencyPaths, ...includedFilePaths], excludedPaths)

return includedPaths
Expand Down
75 changes: 37 additions & 38 deletions tests/main.js
Expand Up @@ -781,46 +781,45 @@ testMany(
basePath: fixtureDir,
})
const bundler = options.config['*'].nodeBundler
const functions = await listFunctionsFiles(fixtureDir, opts)
const sortedFunctions = sortOn(functions, 'mainFile')
t.deepEqual(
sortedFunctions,
[
{ name: 'five', mainFile: 'five/index.ts', runtime: 'js', extension: '.ts', srcFile: 'five/index.ts' },

bundler === 'nft' && {
name: 'five',
mainFile: 'five/index.ts',
runtime: 'js',
extension: '.ts',
srcFile: 'five/util.ts',
},
const files = await listFunctionsFiles(fixtureDir, opts)
const sortedFiles = sortOn(files, ['mainFile', 'srcFile'])
const expectedFiles = [
{ name: 'five', mainFile: 'five/index.ts', runtime: 'js', extension: '.ts', srcFile: 'five/index.ts' },

bundler === 'nft' && {
name: 'five',
mainFile: 'five/index.ts',
runtime: 'js',
extension: '.ts',
srcFile: 'five/util.ts',
},

{
name: 'four',
mainFile: 'four.js/four.js.js',
runtime: 'js',
extension: '.js',
srcFile: 'four.js/four.js.js',
},
{ name: 'one', mainFile: 'one/index.js', runtime: 'js', extension: '.js', srcFile: 'one/index.js' },
{ name: 'test', mainFile: 'test', runtime: 'go', extension: '', srcFile: 'test' },
{ name: 'test', mainFile: 'test.js', runtime: 'js', extension: '.js', srcFile: 'test.js' },
{ name: 'test', mainFile: 'test.zip', runtime: 'js', extension: '.zip', srcFile: 'test.zip' },

(bundler === undefined || bundler === 'nft') && {
name: 'two',
mainFile: 'two/two.js',
runtime: 'js',
extension: '.json',
srcFile: 'two/three.json',
},
{
name: 'four',
mainFile: 'four.js/four.js.js',
runtime: 'js',
extension: '.js',
srcFile: 'four.js/four.js.js',
},
{ name: 'one', mainFile: 'one/index.js', runtime: 'js', extension: '.js', srcFile: 'one/index.js' },
{ name: 'test', mainFile: 'test', runtime: 'go', extension: '', srcFile: 'test' },
{ name: 'test', mainFile: 'test.js', runtime: 'js', extension: '.js', srcFile: 'test.js' },
{ name: 'test', mainFile: 'test.zip', runtime: 'js', extension: '.zip', srcFile: 'test.zip' },

(bundler === undefined || bundler === 'nft') && {
name: 'two',
mainFile: 'two/two.js',
runtime: 'js',
extension: '.json',
srcFile: 'two/three.json',
},

{ name: 'two', mainFile: 'two/two.js', runtime: 'js', extension: '.js', srcFile: 'two/two.js' },
]
.filter(Boolean)
.map(normalizeFiles.bind(null, fixtureDir)),
)
{ name: 'two', mainFile: 'two/two.js', runtime: 'js', extension: '.js', srcFile: 'two/two.js' },
]
.filter(Boolean)
.map(normalizeFiles.bind(null, fixtureDir))

t.deepEqual(sortedFiles, sortOn(expectedFiles, ['mainFile', 'srcFile']))
},
)

Expand Down

1 comment on commit 14c19f1

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏱ Benchmark results

largeDepsEsbuild: 8.3s

largeDepsNft: 53.3s

largeDepsZisi: 1m 6.7s

Please sign in to comment.