@@ -48,14 +48,14 @@ const isReact18 = parseInt(process.env.NEXT_TEST_REACT_VERSION) === 18
4848 . map ( ( file : string ) => {
4949 // Normalize sharp, different architectures have different files
5050 if ( file . includes ( '/node_modules/@img/sharp-libvips-' ) ) {
51- return '@img/sharp-libvips-*'
51+ return '/node_modules/ @img/sharp-libvips-*'
5252 }
5353 if (
5454 file . match (
5555 / \/ n o d e _ m o d u l e s \/ @ i m g \/ s h a r p - \w + - \w + \/ l i b \/ s h a r p - \w + - \w + .n o d e $ /
5656 )
5757 ) {
58- return '@img/sharp-*/sharp-*.node'
58+ return '/node_modules/ @img/sharp-*/sharp-*.node'
5959 }
6060
6161 // Strip double node_modules to simplify output
@@ -76,21 +76,32 @@ const isReact18 = parseInt(process.env.NEXT_TEST_REACT_VERSION) === 18
7676 it ( 'should not trace too many files in next-server.js.nft.json' , async ( ) => {
7777 let trace = await readNormalizedNFT ( '.next/next-server.js.nft.json' )
7878
79- // Group the entries together so that the snapshot doesn't change too often.
79+ // Group the entries together so that the snapshot doesn't change too often.
8080 // This trace contains quite a lot of files that aren't actually needed. But there isn't much
8181 // that Turbopack itself can do about that.
82-
8382 let traceGrouped = [
8483 ...new Set (
8584 trace . map ( ( file : string ) => {
86- if ( file . startsWith ( '/node_modules/next/dist/client/' ) ) {
87- return '/node_modules/next/dist/client/*'
88- }
89- if ( file . startsWith ( '/node_modules/next/dist/server/' ) ) {
90- return '/node_modules/next/dist/server/*'
91- }
92- if ( file . startsWith ( '/node_modules/next/dist/shared/' ) ) {
93- return '/node_modules/next/dist/shared/*'
85+ if ( file . startsWith ( '/node_modules/next/' ) ) {
86+ if ( file . startsWith ( '/node_modules/next/dist/client/' ) ) {
87+ return '/node_modules/next/dist/client/*'
88+ }
89+ if ( file . startsWith ( '/node_modules/next/dist/server/' ) ) {
90+ return '/node_modules/next/dist/server/*'
91+ }
92+ if ( file . startsWith ( '/node_modules/next/dist/shared/' ) ) {
93+ return '/node_modules/next/dist/shared/*'
94+ }
95+ } else if (
96+ file . startsWith ( '/node_modules/react' ) ||
97+ file . endsWith ( '.node' )
98+ ) {
99+ return file
100+ } else {
101+ let match = / ^ \/ n o d e _ m o d u l e s \/ ( @ [ ^ / ] + \/ [ ^ / ] + | [ ^ / ] + ) \/ / . exec ( file )
102+ if ( match != null ) {
103+ return `/node_modules/${ match [ 1 ] } /*`
104+ }
94105 }
95106 return file
96107 } )
@@ -99,18 +110,13 @@ const isReact18 = parseInt(process.env.NEXT_TEST_REACT_VERSION) === 18
99110
100111 expect ( traceGrouped ) . toMatchInlineSnapshot ( `
101112 [
102- "/node_modules/@img/colour/color.cjs",
103- "/node_modules/@img/colour/index.cjs",
104- "/node_modules/@next/env/dist/index.js",
105- "/node_modules/@swc/helpers/cjs/_class_private_field_loose_base.cjs",
106- "/node_modules/@swc/helpers/cjs/_class_private_field_loose_key.cjs",
107- "/node_modules/@swc/helpers/cjs/_interop_require_default.cjs",
108- "/node_modules/@swc/helpers/cjs/_interop_require_wildcard.cjs",
109- "/node_modules/client-only/index.js",
110- "/node_modules/detect-libc/lib/detect-libc.js",
111- "/node_modules/detect-libc/lib/elf.js",
112- "/node_modules/detect-libc/lib/filesystem.js",
113- "/node_modules/detect-libc/lib/process.js",
113+ "/node_modules/@img/colour/*",
114+ "/node_modules/@img/sharp-*/sharp-*.node",
115+ "/node_modules/@img/*",
116+ "/node_modules/@next/env/*",
117+ "/node_modules/@swc/helpers/*",
118+ "/node_modules/client-only/*",
119+ "/node_modules/detect-libc/*",
114120 "/node_modules/next/dist/build/output/log.js",
115121 "/node_modules/next/dist/build/segment-config/app/app-segment-config.js",
116122 "/node_modules/next/dist/build/segment-config/app/app-segments.js",
@@ -221,44 +227,9 @@ const isReact18 = parseInt(process.env.NEXT_TEST_REACT_VERSION) === 18
221227 "/node_modules/react/index.js",
222228 "/node_modules/react/jsx-dev-runtime.js",
223229 "/node_modules/react/jsx-runtime.js",
224- "/node_modules/semver/classes/comparator.js",
225- "/node_modules/semver/classes/range.js",
226- "/node_modules/semver/classes/semver.js",
227- "/node_modules/semver/functions/cmp.js",
228- "/node_modules/semver/functions/coerce.js",
229- "/node_modules/semver/functions/compare.js",
230- "/node_modules/semver/functions/eq.js",
231- "/node_modules/semver/functions/gt.js",
232- "/node_modules/semver/functions/gte.js",
233- "/node_modules/semver/functions/lt.js",
234- "/node_modules/semver/functions/lte.js",
235- "/node_modules/semver/functions/neq.js",
236- "/node_modules/semver/functions/parse.js",
237- "/node_modules/semver/functions/satisfies.js",
238- "/node_modules/semver/internal/constants.js",
239- "/node_modules/semver/internal/debug.js",
240- "/node_modules/semver/internal/identifiers.js",
241- "/node_modules/semver/internal/lrucache.js",
242- "/node_modules/semver/internal/parse-options.js",
243- "/node_modules/semver/internal/re.js",
244- "/node_modules/sharp/lib/channel.js",
245- "/node_modules/sharp/lib/colour.js",
246- "/node_modules/sharp/lib/composite.js",
247- "/node_modules/sharp/lib/constructor.js",
248- "/node_modules/sharp/lib/index.js",
249- "/node_modules/sharp/lib/input.js",
250- "/node_modules/sharp/lib/is.js",
251- "/node_modules/sharp/lib/libvips.js",
252- "/node_modules/sharp/lib/operation.js",
253- "/node_modules/sharp/lib/output.js",
254- "/node_modules/sharp/lib/resize.js",
255- "/node_modules/sharp/lib/sharp.js",
256- "/node_modules/sharp/lib/utility.js",
257- "/node_modules/styled-jsx/dist/index/index.js",
258- "/node_modules/styled-jsx/index.js",
259- "/node_modules/styled-jsx/style.js",
260- "@img/sharp-*/sharp-*.node",
261- "@img/sharp-libvips-*",
230+ "/node_modules/semver/*",
231+ "/node_modules/sharp/*",
232+ "/node_modules/styled-jsx/*",
262233 ]
263234 ` )
264235 } )
0 commit comments