Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix trace case with tsconfig/jsconfig baseUrl #30286

Merged
merged 2 commits into from Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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
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)
})
})
})