Unverified Commit 1a188847 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Turbopack Build: Implement helpful error for missing sass package (#80155)

## What?

Implements the same error message that we add to the webpack handling. I'm not super happy about this solution (though it matches what we do for webpack) ideally we improve the sass-loader error itself in the future but that requires upgrading sass-loader as well and introducing a breaking change. For now this unblocks the test passing.
parent 6cbe40fb
...@@ -190,7 +190,17 @@ export function formatIssue(issue: Issue) { ...@@ -190,7 +190,17 @@ export function formatIssue(issue: Issue) {
} }
if (description) { if (description) {
message += renderStyledStringToErrorAnsi(description) + '\n\n' if (
description.type === 'text' &&
description.value.includes(`Cannot find module 'sass'`)
) {
message +=
"To use Next.js' built-in Sass support, you first need to install `sass`.\n"
message += 'Run `npm i sass` or `yarn add sass` inside your workspace.\n'
message += '\nLearn more: https://nextjs.org/docs/messages/install-sass'
} else {
message += renderStyledStringToErrorAnsi(description) + '\n\n'
}
} }
// TODO: make it possible to enable this for debugging, but not in tests. // TODO: make it possible to enable this for debugging, but not in tests.
......
...@@ -24,7 +24,6 @@ describe('SCSS Support', () => { ...@@ -24,7 +24,6 @@ describe('SCSS Support', () => {
'Learn more: https://nextjs.org/docs/messages/install-sass' 'Learn more: https://nextjs.org/docs/messages/install-sass'
) )
expect(cliOutput).toContain('Failed to compile.')
expect(cliOutput).not.toContain('css-loader') expect(cliOutput).not.toContain('css-loader')
expect(cliOutput).not.toContain('sass-loader') expect(cliOutput).not.toContain('sass-loader')
}) })
......
...@@ -5320,10 +5320,10 @@ ...@@ -5320,10 +5320,10 @@
"runtimeError": false "runtimeError": false
}, },
"test/e2e/app-dir/scss/webpack-error/webpack-error.test.ts": { "test/e2e/app-dir/scss/webpack-error/webpack-error.test.ts": {
"passed": [], "passed": [
"failed": [
"SCSS Support Friendly Webpack Error should be a friendly error successfully" "SCSS Support Friendly Webpack Error should be a friendly error successfully"
], ],
"failed": [],
"pending": [], "pending": [],
"flakey": [], "flakey": [],
"runtimeError": false "runtimeError": false
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment