Unverified Commit bf097f1d authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Update resolving for node_modules trace pass (#30985)

* Update resolving for node_modules trace pass

* Update test
parent 5db9d09e
...@@ -114,8 +114,7 @@ export class TraceEntryPointsPlugin implements webpack5.WebpackPluginInstance { ...@@ -114,8 +114,7 @@ export class TraceEntryPointsPlugin implements webpack5.WebpackPluginInstance {
assets: any, assets: any,
span: Span, span: Span,
readlink: any, readlink: any,
stat: any, stat: any
doResolve: any
) { ) {
const outputPath = compilation.outputOptions.path const outputPath = compilation.outputOptions.path
...@@ -173,11 +172,6 @@ export class TraceEntryPointsPlugin implements webpack5.WebpackPluginInstance { ...@@ -173,11 +172,6 @@ export class TraceEntryPointsPlugin implements webpack5.WebpackPluginInstance {
}, },
readlink, readlink,
stat, stat,
resolve: doResolve
? (id, parent, job, isCjs) => {
return doResolve(id, parent, job, !isCjs)
}
: undefined,
ignore: [...TRACE_IGNORES, ...this.excludeFiles], ignore: [...TRACE_IGNORES, ...this.excludeFiles],
mixedModules: true, mixedModules: true,
}) })
...@@ -455,8 +449,7 @@ export class TraceEntryPointsPlugin implements webpack5.WebpackPluginInstance { ...@@ -455,8 +449,7 @@ export class TraceEntryPointsPlugin implements webpack5.WebpackPluginInstance {
assets, assets,
traceEntrypointsPluginSpan, traceEntrypointsPluginSpan,
readlink, readlink,
stat, stat
doResolve
) )
.then(() => callback()) .then(() => callback())
.catch((err) => callback(err)) .catch((err) => callback(err))
......
...@@ -250,11 +250,9 @@ async function main() { ...@@ -250,11 +250,9 @@ async function main() {
...process.env, ...process.env,
// run tests in headless mode by default // run tests in headless mode by default
HEADLESS: 'true', HEADLESS: 'true',
TRACE_PLAYWRIGHT: 'true',
...(isFinalRun ...(isFinalRun
? { ? {
// only trace on final run as previous traces
// are removed anyways
TRACE_PLAYWRIGHT: 'true',
// Events can be finicky in CI. This switches to a more // Events can be finicky in CI. This switches to a more
// reliable polling method. // reliable polling method.
// CHOKIDAR_USEPOLLING: 'true', // CHOKIDAR_USEPOLLING: 'true',
......
...@@ -84,6 +84,9 @@ describe('prerender native module', () => { ...@@ -84,6 +84,9 @@ describe('prerender native module', () => {
/node_modules\/sqlite3\/.*?\.js/, /node_modules\/sqlite3\/.*?\.js/,
/node_modules\/sqlite3\/.*?\.node/, /node_modules\/sqlite3\/.*?\.node/,
/node_modules\/sqlite\/.*?\.js/, /node_modules\/sqlite\/.*?\.js/,
/node_modules\/next/,
/next\/router\.js/,
/next\/dist\/client\/router\.js/,
/\/data\.sqlite/, /\/data\.sqlite/,
], ],
notTests: [], notTests: [],
......
...@@ -1832,6 +1832,7 @@ describe('Prerender', () => { ...@@ -1832,6 +1832,7 @@ describe('Prerender', () => {
/node_modules\/react\/index\.js/, /node_modules\/react\/index\.js/,
/node_modules\/react\/package\.json/, /node_modules\/react\/package\.json/,
/node_modules\/react\/cjs\/react\.production\.min\.js/, /node_modules\/react\/cjs\/react\.production\.min\.js/,
/node_modules\/next/,
], ],
notTests: [], notTests: [],
}, },
...@@ -1843,6 +1844,7 @@ describe('Prerender', () => { ...@@ -1843,6 +1844,7 @@ describe('Prerender', () => {
/node_modules\/react\/index\.js/, /node_modules\/react\/index\.js/,
/node_modules\/react\/package\.json/, /node_modules\/react\/package\.json/,
/node_modules\/react\/cjs\/react\.production\.min\.js/, /node_modules\/react\/cjs\/react\.production\.min\.js/,
/node_modules\/next/,
/\/world.txt/, /\/world.txt/,
], ],
notTests: [ notTests: [
...@@ -1858,6 +1860,9 @@ describe('Prerender', () => { ...@@ -1858,6 +1860,9 @@ describe('Prerender', () => {
/node_modules\/react\/index\.js/, /node_modules\/react\/index\.js/,
/node_modules\/react\/package\.json/, /node_modules\/react\/package\.json/,
/node_modules\/react\/cjs\/react\.production\.min\.js/, /node_modules\/react\/cjs\/react\.production\.min\.js/,
/node_modules\/next/,
/next\/router\.js/,
/next\/dist\/client\/router\.js/,
/node_modules\/@firebase\/firestore\/.*?\.js/, /node_modules\/@firebase\/firestore\/.*?\.js/,
], ],
notTests: [/\/world.txt/], notTests: [/\/world.txt/],
......
...@@ -71,6 +71,12 @@ describe('TypeScript Features', () => { ...@@ -71,6 +71,12 @@ describe('TypeScript Features', () => {
const helloTrace = await fs.readJSON( const helloTrace = await fs.readJSON(
join(appDir, '.next/server/pages/hello.js.nft.json') join(appDir, '.next/server/pages/hello.js.nft.json')
) )
const appTrace = await fs.readJSON(
join(appDir, '.next/server/pages/_app.js.nft.json')
)
expect(
appTrace.files.some((file) => file.includes('node_modules/next'))
).toBe(true)
expect( expect(
helloTrace.files.some((file) => file.includes('components/world.js')) helloTrace.files.some((file) => file.includes('components/world.js'))
).toBe(true) ).toBe(true)
......
...@@ -85,6 +85,9 @@ describe('TypeScript Features', () => { ...@@ -85,6 +85,9 @@ describe('TypeScript Features', () => {
await nextBuild(appDir) await nextBuild(appDir)
}) })
it('should trace correctly', async () => { it('should trace correctly', async () => {
const appTrace = await fs.readJSON(
join(appDir, '.next/server/pages/_app.js.nft.json')
)
const singleAliasTrace = await fs.readJSON( const singleAliasTrace = await fs.readJSON(
join(appDir, '.next/server/pages/single-alias.js.nft.json') join(appDir, '.next/server/pages/single-alias.js.nft.json')
) )
...@@ -100,6 +103,9 @@ describe('TypeScript Features', () => { ...@@ -100,6 +103,9 @@ describe('TypeScript Features', () => {
const basicAliasTrace = await fs.readJSON( const basicAliasTrace = await fs.readJSON(
join(appDir, '.next/server/pages/basic-alias.js.nft.json') join(appDir, '.next/server/pages/basic-alias.js.nft.json')
) )
expect(
appTrace.files.some((file) => file.includes('node_modules/next'))
).toBe(true)
expect( expect(
singleAliasTrace.files.some((file) => singleAliasTrace.files.some((file) =>
file.includes('components/hello.js') file.includes('components/hello.js')
......
...@@ -130,6 +130,7 @@ describe('Production Usage', () => { ...@@ -130,6 +130,7 @@ describe('Production Usage', () => {
/node_modules\/react\/index\.js/, /node_modules\/react\/index\.js/,
/node_modules\/react\/package\.json/, /node_modules\/react\/package\.json/,
/node_modules\/react\/cjs\/react\.production\.min\.js/, /node_modules\/react\/cjs\/react\.production\.min\.js/,
/node_modules\/next/,
/next\/link\.js/, /next\/link\.js/,
/next\/dist\/client\/link\.js/, /next\/dist\/client\/link\.js/,
/next\/dist\/shared\/lib\/router\/utils\/resolve-rewrites\.js/, /next\/dist\/shared\/lib\/router\/utils\/resolve-rewrites\.js/,
...@@ -146,6 +147,7 @@ describe('Production Usage', () => { ...@@ -146,6 +147,7 @@ describe('Production Usage', () => {
/node_modules\/react\/index\.js/, /node_modules\/react\/index\.js/,
/node_modules\/react\/package\.json/, /node_modules\/react\/package\.json/,
/node_modules\/react\/cjs\/react\.production\.min\.js/, /node_modules\/react\/cjs\/react\.production\.min\.js/,
/node_modules\/next/,
/next\/link\.js/, /next\/link\.js/,
/next\/dist\/client\/link\.js/, /next\/dist\/client\/link\.js/,
/next\/dist\/shared\/lib\/router\/utils\/resolve-rewrites\.js/, /next\/dist\/shared\/lib\/router\/utils\/resolve-rewrites\.js/,
...@@ -160,6 +162,7 @@ describe('Production Usage', () => { ...@@ -160,6 +162,7 @@ describe('Production Usage', () => {
/node_modules\/react\/index\.js/, /node_modules\/react\/index\.js/,
/node_modules\/react\/package\.json/, /node_modules\/react\/package\.json/,
/node_modules\/react\/cjs\/react\.production\.min\.js/, /node_modules\/react\/cjs\/react\.production\.min\.js/,
/node_modules\/next/,
/next\/link\.js/, /next\/link\.js/,
/next\/dist\/client\/link\.js/, /next\/dist\/client\/link\.js/,
/next\/dist\/shared\/lib\/router\/utils\/resolve-rewrites\.js/, /next\/dist\/shared\/lib\/router\/utils\/resolve-rewrites\.js/,
...@@ -167,12 +170,7 @@ describe('Production Usage', () => { ...@@ -167,12 +170,7 @@ describe('Production Usage', () => {
/node_modules\/nanoid\/url-alphabet\/index\.js/, /node_modules\/nanoid\/url-alphabet\/index\.js/,
/node_modules\/es5-ext\/array\/#\/clear\.js/, /node_modules\/es5-ext\/array\/#\/clear\.js/,
], ],
notTests: [ notTests: [/next\/dist\/pages\/_error\.js/, /next\/error\.js/, /\0/],
/node_modules\/nanoid\/index\.cjs/,
/next\/dist\/pages\/_error\.js/,
/next\/error\.js/,
/\0/,
],
}, },
{ {
page: '/counter', page: '/counter',
...@@ -183,6 +181,7 @@ describe('Production Usage', () => { ...@@ -183,6 +181,7 @@ describe('Production Usage', () => {
/node_modules\/react\/package\.json/, /node_modules\/react\/package\.json/,
/node_modules\/react\/cjs\/react\.production\.min\.js/, /node_modules\/react\/cjs\/react\.production\.min\.js/,
/node_modules\/react\/cjs\/react\.development\.js/, /node_modules\/react\/cjs\/react\.development\.js/,
/node_modules\/next/,
/next\/router\.js/, /next\/router\.js/,
/next\/dist\/client\/router\.js/, /next\/dist\/client\/router\.js/,
/next\/dist\/shared\/lib\/router\/utils\/resolve-rewrites\.js/, /next\/dist\/shared\/lib\/router\/utils\/resolve-rewrites\.js/,
...@@ -197,6 +196,7 @@ describe('Production Usage', () => { ...@@ -197,6 +196,7 @@ describe('Production Usage', () => {
/node_modules\/react\/index\.js/, /node_modules\/react\/index\.js/,
/node_modules\/react\/package\.json/, /node_modules\/react\/package\.json/,
/node_modules\/react\/cjs\/react\.production\.min\.js/, /node_modules\/react\/cjs\/react\.production\.min\.js/,
/node_modules\/next/,
/next\/link\.js/, /next\/link\.js/,
/next\/dist\/client\/link\.js/, /next\/dist\/client\/link\.js/,
/next\/dist\/shared\/lib\/router\/utils\/resolve-rewrites\.js/, /next\/dist\/shared\/lib\/router\/utils\/resolve-rewrites\.js/,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment