Skip to content

Commit

Permalink
fix(next): use moduleGraph.getIssuer to avoid deprecation warning (#3…
Browse files Browse the repository at this point in the history
…6329) (#36330)

fix: #36329 



## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
  • Loading branch information
await-ovo committed Apr 21, 2022
1 parent 9456fc6 commit 864d401
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/next/server/dev/hot-reloader.ts
Expand Up @@ -106,12 +106,16 @@ const matchNextPageBundleRequest = route(
)

// Recursively look up the issuer till it ends up at the root
function findEntryModule(issuer: any): any {
if (issuer.issuer) {
return findEntryModule(issuer.issuer)
function findEntryModule(
compilation: webpack5.Compilation,
issuerModule: any
): any {
const issuer = compilation.moduleGraph.getIssuer(issuerModule)
if (issuer) {
return findEntryModule(compilation, issuer)
}

return issuer
return issuerModule
}

function erroredPages(compilation: webpack5.Compilation) {
Expand All @@ -121,7 +125,7 @@ function erroredPages(compilation: webpack5.Compilation) {
continue
}

const entryModule = findEntryModule(error.module)
const entryModule = findEntryModule(compilation, error.module)
const { name } = entryModule
if (!name) {
continue
Expand Down
29 changes: 29 additions & 0 deletions test/development/webpack-issuer-deprecation-warning/index.test.ts
@@ -0,0 +1,29 @@
import { createNext } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { renderViaHTTP } from 'next-test-utils'

describe('webpack-issuer-deprecation-warning', () => {
let next: NextInstance

beforeAll(async () => {
next = await createNext({
files: {
'pages/index.js': `
export default function Page() {
return <p>hello world
}
`,
},
dependencies: {},
})
})
afterAll(() => next.destroy())

it('should not appear deprecation warning about webpack module issuer', async () => {
const html = await renderViaHTTP(next.url, '/')
expect(html).toContain('Syntax Error')
expect(next.cliOutput).not.toContain(
'[DEP_WEBPACK_MODULE_ISSUER] DeprecationWarning: Module.issuer: Use new ModuleGraph API'
)
})
})
2 changes: 2 additions & 0 deletions test/lib/next-modes/next-dev.ts
Expand Up @@ -40,6 +40,8 @@ export class NextDevInstance extends NextInstance {
},
})

this._cliOutput = ''

this.childProcess.stdout.on('data', (chunk) => {
const msg = chunk.toString()
process.stdout.write(chunk)
Expand Down

0 comments on commit 864d401

Please sign in to comment.