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 {
assets: any,
span: Span,
readlink: any,
stat: any,
doResolve: any
stat: any
) {
const outputPath = compilation.outputOptions.path
......@@ -173,11 +172,6 @@ export class TraceEntryPointsPlugin implements webpack5.WebpackPluginInstance {
},
readlink,
stat,
resolve: doResolve
? (id, parent, job, isCjs) => {
return doResolve(id, parent, job, !isCjs)
}
: undefined,
ignore: [...TRACE_IGNORES, ...this.excludeFiles],
mixedModules: true,
})
......@@ -455,8 +449,7 @@ export class TraceEntryPointsPlugin implements webpack5.WebpackPluginInstance {
assets,
traceEntrypointsPluginSpan,
readlink,
stat,
doResolve
stat
)
.then(() => callback())
.catch((err) => callback(err))
......
......@@ -250,11 +250,9 @@ async function main() {
...process.env,
// run tests in headless mode by default
HEADLESS: 'true',
TRACE_PLAYWRIGHT: 'true',
...(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
// reliable polling method.
// CHOKIDAR_USEPOLLING: 'true',
......
......@@ -84,6 +84,9 @@ describe('prerender native module', () => {
/node_modules\/sqlite3\/.*?\.js/,
/node_modules\/sqlite3\/.*?\.node/,
/node_modules\/sqlite\/.*?\.js/,
/node_modules\/next/,
/next\/router\.js/,
/next\/dist\/client\/router\.js/,
/\/data\.sqlite/,
],
notTests: [],
......
......@@ -1832,6 +1832,7 @@ describe('Prerender', () => {
/node_modules\/react\/index\.js/,
/node_modules\/react\/package\.json/,
/node_modules\/react\/cjs\/react\.production\.min\.js/,
/node_modules\/next/,
],
notTests: [],
},
......@@ -1843,6 +1844,7 @@ describe('Prerender', () => {
/node_modules\/react\/index\.js/,
/node_modules\/react\/package\.json/,
/node_modules\/react\/cjs\/react\.production\.min\.js/,
/node_modules\/next/,
/\/world.txt/,
],
notTests: [
......@@ -1858,6 +1860,9 @@ describe('Prerender', () => {
/node_modules\/react\/index\.js/,
/node_modules\/react\/package\.json/,
/node_modules\/react\/cjs\/react\.production\.min\.js/,
/node_modules\/next/,
/next\/router\.js/,
/next\/dist\/client\/router\.js/,
/node_modules\/@firebase\/firestore\/.*?\.js/,
],
notTests: [/\/world.txt/],
......
......@@ -71,6 +71,12 @@ describe('TypeScript Features', () => {
const helloTrace = await fs.readJSON(
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(
helloTrace.files.some((file) => file.includes('components/world.js'))
).toBe(true)
......
......@@ -85,6 +85,9 @@ describe('TypeScript Features', () => {
await nextBuild(appDir)
})
it('should trace correctly', async () => {
const appTrace = await fs.readJSON(
join(appDir, '.next/server/pages/_app.js.nft.json')
)
const singleAliasTrace = await fs.readJSON(
join(appDir, '.next/server/pages/single-alias.js.nft.json')
)
......@@ -100,6 +103,9 @@ describe('TypeScript Features', () => {
const basicAliasTrace = await fs.readJSON(
join(appDir, '.next/server/pages/basic-alias.js.nft.json')
)
expect(
appTrace.files.some((file) => file.includes('node_modules/next'))
).toBe(true)
expect(
singleAliasTrace.files.some((file) =>
file.includes('components/hello.js')
......
......@@ -130,6 +130,7 @@ describe('Production Usage', () => {
/node_modules\/react\/index\.js/,
/node_modules\/react\/package\.json/,
/node_modules\/react\/cjs\/react\.production\.min\.js/,
/node_modules\/next/,
/next\/link\.js/,
/next\/dist\/client\/link\.js/,
/next\/dist\/shared\/lib\/router\/utils\/resolve-rewrites\.js/,
......@@ -146,6 +147,7 @@ describe('Production Usage', () => {
/node_modules\/react\/index\.js/,
/node_modules\/react\/package\.json/,
/node_modules\/react\/cjs\/react\.production\.min\.js/,
/node_modules\/next/,
/next\/link\.js/,
/next\/dist\/client\/link\.js/,
/next\/dist\/shared\/lib\/router\/utils\/resolve-rewrites\.js/,
......@@ -160,6 +162,7 @@ describe('Production Usage', () => {
/node_modules\/react\/index\.js/,
/node_modules\/react\/package\.json/,
/node_modules\/react\/cjs\/react\.production\.min\.js/,
/node_modules\/next/,
/next\/link\.js/,
/next\/dist\/client\/link\.js/,
/next\/dist\/shared\/lib\/router\/utils\/resolve-rewrites\.js/,
......@@ -167,12 +170,7 @@ describe('Production Usage', () => {
/node_modules\/nanoid\/url-alphabet\/index\.js/,
/node_modules\/es5-ext\/array\/#\/clear\.js/,
],
notTests: [
/node_modules\/nanoid\/index\.cjs/,
/next\/dist\/pages\/_error\.js/,
/next\/error\.js/,
/\0/,
],
notTests: [/next\/dist\/pages\/_error\.js/, /next\/error\.js/, /\0/],
},
{
page: '/counter',
......@@ -183,6 +181,7 @@ describe('Production Usage', () => {
/node_modules\/react\/package\.json/,
/node_modules\/react\/cjs\/react\.production\.min\.js/,
/node_modules\/react\/cjs\/react\.development\.js/,
/node_modules\/next/,
/next\/router\.js/,
/next\/dist\/client\/router\.js/,
/next\/dist\/shared\/lib\/router\/utils\/resolve-rewrites\.js/,
......@@ -197,6 +196,7 @@ describe('Production Usage', () => {
/node_modules\/react\/index\.js/,
/node_modules\/react\/package\.json/,
/node_modules\/react\/cjs\/react\.production\.min\.js/,
/node_modules\/next/,
/next\/link\.js/,
/next\/dist\/client\/link\.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