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

Ensure build trace handles mixed modules #28770

Merged
merged 1 commit into from
Sep 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ export class TraceEntryPointsPlugin implements webpack.Plugin {
readlink,
stat,
ignore: [...TRACE_IGNORES, ...this.excludeFiles],
mixedModules: true,
})

const tracedDeps: string[] = []
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const getCmsData = require('some-cms')

export function fetchData() {
return getCmsData()
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
if (isServer) {
const curEntry = origEntries['pages/_app']
origEntries['pages/_app'] = [
path.resolve('lib/get-data.js'),
path.join(__dirname, 'lib/get-data.js'),
...curEntry,
]
console.log(origEntries)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions test/integration/build-trace-extra-entries/app/pages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { fetchData } from '../lib/fetch-data'

export default function Page() {
return 'index page'
}

export function getStaticProps() {
fetchData()

return {
props: {},
}
}
3 changes: 0 additions & 3 deletions test/integration/build-trace-extra-entries/pages/index.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { nextBuild } from 'next-test-utils'

jest.setTimeout(1000 * 60)

const appDir = join(__dirname, '..')
const appDir = join(__dirname, '../app')

describe('build trace with extra entries', () => {
it('should build and trace correctly', async () => {
Expand All @@ -28,5 +28,8 @@ describe('build trace with extra entries', () => {
expect(
indexTrace.files.some((file) => file.endsWith('hello.json'))
).toBeFalsy()
expect(
indexTrace.files.some((file) => file.includes('some-cms/index.js'))
).toBe(true)
})
})