Skip to content

Commit

Permalink
Ensure build trace handles mixed modules (#28770)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Sep 3, 2021
1 parent fcdf732 commit 14a999e
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 5 deletions.
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)
})
})

0 comments on commit 14a999e

Please sign in to comment.