Skip to content

Commit

Permalink
Update resolving for node_modules trace pass (#30985)
Browse files Browse the repository at this point in the history
* Update resolving for node_modules trace pass

* Update test
  • Loading branch information
ijjk committed Nov 5, 2021
1 parent 5db9d09 commit bf097f1
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
})
Expand Down Expand Up @@ -455,8 +449,7 @@ export class TraceEntryPointsPlugin implements webpack5.WebpackPluginInstance {
assets,
traceEntrypointsPluginSpan,
readlink,
stat,
doResolve
stat
)
.then(() => callback())
.catch((err) => callback(err))
Expand Down
4 changes: 1 addition & 3 deletions run-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/prerender-native-module.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand Down
5 changes: 5 additions & 0 deletions test/e2e/prerender.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
},
Expand All @@ -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: [
Expand All @@ -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/],
Expand Down
6 changes: 6 additions & 0 deletions test/integration/jsconfig-baseurl/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions test/integration/jsconfig-paths/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
)
Expand All @@ -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')
Expand Down
12 changes: 6 additions & 6 deletions test/integration/production/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/,
Expand All @@ -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/,
Expand All @@ -160,19 +162,15 @@ 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/,
/node_modules\/nanoid\/index\.js/,
/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',
Expand All @@ -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/,
Expand All @@ -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/,
Expand Down

0 comments on commit bf097f1

Please sign in to comment.