Skip to content
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

Update to latest @vercel/nft and leverage new reason types #35446

Merged
merged 1 commit into from Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -68,11 +68,13 @@ function getFilesMapFromReasons(

for (const file of fileList!) {
const reason = reasons!.get(file)
const isInitial =
reason?.type.length === 1 && reason.type.includes('initial')

if (
!reason ||
!reason.parents ||
(reason.type === 'initial' && reason.parents.size === 0)
(isInitial && reason.parents.size === 0)
) {
continue
}
Expand Down Expand Up @@ -360,8 +362,10 @@ export class TraceEntryPointsPlugin implements webpack5.WebpackPluginInstance {
(file) => {
file = nodePath.join(this.tracingRoot, file)
const depMod = depModMap.get(file)
const isAsset = reasons.get(file)?.type.includes('asset')

return (
!isAsset &&
Array.isArray(depMod?.loaders) &&
depMod.loaders.length > 0
)
Expand Down
2 changes: 1 addition & 1 deletion packages/next/compiled/@vercel/nft/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/next/package.json
Expand Up @@ -161,7 +161,7 @@
"@types/webpack-sources1": "npm:@types/webpack-sources@0.1.5",
"@types/ws": "8.2.0",
"@vercel/ncc": "0.33.1",
"@vercel/nft": "0.17.5",
"@vercel/nft": "0.18.0",
"acorn": "8.5.0",
"amphtml-validator": "1.0.35",
"arg": "4.1.0",
Expand Down
11 changes: 11 additions & 0 deletions test/integration/production/pages/api/index.js
@@ -1,3 +1,14 @@
import fs from 'fs'
import path from 'path'
import data from '../../static/hello.json'

export default (req, res) => {
console.log({
importedData: data,
fsLoadedData: fs.readFileSync(
path.join(process.cwd(), 'static', 'hello.json'),
'utf8'
),
})
res.end('API index works')
}
1 change: 1 addition & 0 deletions test/integration/production/static/hello.json
@@ -0,0 +1 @@
{ "hello": "world" }
13 changes: 12 additions & 1 deletion test/integration/production/test/index.test.js
Expand Up @@ -51,7 +51,7 @@ describe('Production Usage', () => {

appPort = await findPort()
context.appPort = appPort
app = await nextStart(appDir, appPort)
app = await nextStart(appDir, appPort, { cwd: appDir })
output = (result.stderr || '') + (result.stdout || '')
console.log(output)

Expand Down Expand Up @@ -223,6 +223,17 @@ describe('Production Usage', () => {
/!/,
],
},
{
page: '/api',
tests: [/webpack-runtime\.js/, /static\/hello\.json/],
notTests: [
/next\/dist\/server\/next\.js/,
/next\/dist\/bin/,
/\0/,
/\?/,
/!/,
],
},
]

for (const check of checks) {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Expand Up @@ -5624,10 +5624,10 @@
resolved "https://registry.yarnpkg.com/@vercel/ncc/-/ncc-0.33.1.tgz#b240080a3c1ded9446a30955a06a79851bb38f71"
integrity sha512-Mlsps/P0PLZwsCFtSol23FGqT3FhBGb4B1AuGQ52JTAtXhak+b0Fh/4T55r0/SVQPeRiX9pNItOEHwakGPmZYA==

"@vercel/nft@0.17.5":
version "0.17.5"
resolved "https://registry.yarnpkg.com/@vercel/nft/-/nft-0.17.5.tgz#eab288a3786b8bd6fc08c0ef0b70d162984d1643"
integrity sha512-6n4uXmfkcHAmkI4rJlwFJb8yvWuH6uDOi5qme0yGC1B/KmWJ66dERupdAj9uj7eEmgM7N3bKNY5zOYE7cKZE1g==
"@vercel/nft@0.18.0":
version "0.18.0"
resolved "https://registry.yarnpkg.com/@vercel/nft/-/nft-0.18.0.tgz#3a489036e53af529f8c1247a9910e92a696ebb8e"
integrity sha512-FFzpmYC4hu/nnh3bm+dVWRYq59jN7ogW8hcuzKeWnXjDqtWDawn9oGnOgMFsKdqtI40RJuscPko/kzFh62ukOw==
dependencies:
"@mapbox/node-pre-gyp" "^1.0.5"
acorn "^8.6.0"
Expand Down