mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
update @next/rspack-core version to 1.0.2 and update the snapshot other changes: - packages/next/src/build/webpack-config.ts Adjusted configuration to account for differences in default node config between Rspack and Webpack. - packages/next/src/shared/lib/format-webpack-messages.ts Added a fallback to moduleIdentifier in cases where Rspack does not correctly populate moduleName.
73 lines
3.0 KiB
TypeScript
73 lines
3.0 KiB
TypeScript
/* eslint-env jest */
|
||
|
||
import { isNextStart, nextTestSetup } from 'e2e-utils'
|
||
import { waitForRedbox, getRedboxSource } from 'next-test-utils'
|
||
|
||
describe('CSS Import from node_modules', () => {
|
||
const { next, skipped, isTurbopack, isRspack } = nextTestSetup({
|
||
files: __dirname,
|
||
skipStart: isNextStart,
|
||
skipDeployment: true,
|
||
dependencies: { sass: '1.54.0' },
|
||
})
|
||
|
||
if (skipped) {
|
||
return
|
||
}
|
||
|
||
if (isNextStart) {
|
||
it('should fail the build', async () => {
|
||
const { exitCode, cliOutput } = await next.build()
|
||
expect(exitCode).not.toBe(0)
|
||
if (isRspack) {
|
||
expect(cliOutput).toMatch(
|
||
/RspackResolver\(NotFound\(\\?"nprogress\/nprogress.css\\?"\)\)/
|
||
)
|
||
} else {
|
||
expect(cliOutput).toMatch(/Can't resolve '[^']*?nprogress[^']*?'/)
|
||
}
|
||
expect(cliOutput).toMatch(/Build failed|Build error occurred/)
|
||
})
|
||
} else {
|
||
it('should show a build error', async () => {
|
||
const browser = await next.browser('/')
|
||
|
||
await waitForRedbox(browser)
|
||
const errorSource = await getRedboxSource(browser)
|
||
|
||
if (isTurbopack) {
|
||
expect(errorSource).toMatchInlineSnapshot(`
|
||
"./styles/global.scss.css (1:9)
|
||
Module not found: Can't resolve 'nprogress/nprogress.css'
|
||
> 1 | @import 'nprogress/nprogress.css';
|
||
| ^
|
||
2 |
|
||
|
||
Import trace:
|
||
Browser:
|
||
./styles/global.scss.css
|
||
./pages/_app.js
|
||
|
||
https://nextjs.org/docs/messages/module-not-found"
|
||
`)
|
||
} else if (isRspack) {
|
||
expect(errorSource).toMatchInlineSnapshot(`
|
||
"./node_modules/.pnpm/next@file+..+next-repo-8fa5cfcca6029b56fbac0f566cc3851341e4c064ae33fb2a225547c1fab39f23+packa_apujtevk23v6mt6lxsvypt6azu/node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[9].oneOf[14].use[1]!./node_modules/.pnpm/next@file+..+next-repo-8fa5cfcca6029b56fbac0f566cc3851341e4c064ae33fb2a225547c1fab39f23+packa_apujtevk23v6mt6lxsvypt6azu/node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[9].oneOf[14].use[2]!./node_modules/.pnpm/next@file+..+next-repo-8fa5cfcca6029b56fbac0f566cc3851341e4c064ae33fb2a225547c1fab39f23+packa_apujtevk23v6mt6lxsvypt6azu/node_modules/next/dist/build/webpack/loaders/resolve-url-loader/index.js??ruleSet[1].rules[9].oneOf[14].use[3]!./node_modules/.pnpm/next@file+..+next-repo-8fa5cfcca6029b56fbac0f566cc3851341e4c064ae33fb2a225547c1fab39f23+packa_apujtevk23v6mt6lxsvypt6azu/node_modules/next/dist/compiled/sass-loader/cjs.js??ruleSet[1].rules[9].oneOf[14].use[4]!./styles/global.scss
|
||
╰─▶ × Error: RspackResolver(NotFound("nprogress/nprogress.css"))"
|
||
`)
|
||
} else {
|
||
expect(errorSource).toMatchInlineSnapshot(`
|
||
"./styles/global.scss
|
||
Module not found: Can't resolve 'nprogress/nprogress.css'
|
||
|
||
https://nextjs.org/docs/messages/module-not-found
|
||
|
||
Import trace for requested module:
|
||
./styles/global.scss
|
||
./pages/_app.js"
|
||
`)
|
||
}
|
||
})
|
||
}
|
||
})
|