Skip to content

Commit

Permalink
Fix trace case with tsconfig/jsconfig baseUrl (vercel#30286)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk authored Oct 25, 2021
1 parent 0910e8b commit 73fbd69
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -476,10 +476,12 @@ export class TraceEntryPointsPlugin implements webpack5.WebpackPluginInstance {

const CJS_RESOLVE_OPTIONS = {
...NODE_RESOLVE_OPTIONS,
modules: undefined,
extensions: undefined,
}
const ESM_RESOLVE_OPTIONS = {
...NODE_ESM_RESOLVE_OPTIONS,
modules: undefined,
extensions: undefined,
}

Expand Down
18 changes: 18 additions & 0 deletions test/integration/jsconfig-baseurl/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
findPort,
launchApp,
killApp,
nextBuild,
check,
} from 'next-test-utils'

Expand Down Expand Up @@ -61,4 +62,21 @@ describe('TypeScript Features', () => {
expect(found).toBe(true)
})
})

describe('should build', () => {
beforeAll(async () => {
await nextBuild(appDir)
})
it('should trace correctly', async () => {
const helloTrace = await fs.readJSON(
join(appDir, '.next/server/pages/hello.js.nft.json')
)
expect(
helloTrace.files.some((file) => file.includes('components/world.js'))
).toBe(true)
expect(
helloTrace.files.some((file) => file.includes('react/index.js'))
).toBe(true)
})
})
})
47 changes: 47 additions & 0 deletions test/integration/jsconfig-paths/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
renderViaHTTP,
findPort,
launchApp,
nextBuild,
killApp,
check,
} from 'next-test-utils'
Expand Down Expand Up @@ -78,4 +79,50 @@ describe('TypeScript Features', () => {
expect(found).toBe(true)
})
})

describe('should build', () => {
beforeAll(async () => {
await nextBuild(appDir)
})
it('should trace correctly', async () => {
const singleAliasTrace = await fs.readJSON(
join(appDir, '.next/server/pages/single-alias.js.nft.json')
)
const wildcardAliasTrace = await fs.readJSON(
join(appDir, '.next/server/pages/wildcard-alias.js.nft.json')
)
const resolveOrderTrace = await fs.readJSON(
join(appDir, '.next/server/pages/resolve-order.js.nft.json')
)
const resolveFallbackTrace = await fs.readJSON(
join(appDir, '.next/server/pages/resolve-fallback.js.nft.json')
)
const basicAliasTrace = await fs.readJSON(
join(appDir, '.next/server/pages/basic-alias.js.nft.json')
)
expect(
singleAliasTrace.files.some((file) =>
file.includes('components/hello.js')
)
).toBe(true)
expect(
wildcardAliasTrace.files.some((file) =>
file.includes('mypackage/myfile.js')
)
).toBe(true)
expect(
resolveOrderTrace.files.some((file) => file.includes('lib/a/api.js'))
).toBe(true)
expect(
resolveFallbackTrace.files.some((file) =>
file.includes('lib/b/b-only.js')
)
).toBe(true)
expect(
basicAliasTrace.files.some((file) =>
file.includes('components/world.js')
)
).toBe(true)
})
})
})

0 comments on commit 73fbd69

Please sign in to comment.