diff --git a/crates/rspack_plugin_lightning_css_minimizer/src/lib.rs b/crates/rspack_plugin_lightning_css_minimizer/src/lib.rs index 37b78ec4d17..3f93e9b9ea6 100644 --- a/crates/rspack_plugin_lightning_css_minimizer/src/lib.rs +++ b/crates/rspack_plugin_lightning_css_minimizer/src/lib.rs @@ -125,9 +125,9 @@ async fn process_assets(&self, compilation: &mut Compilation) -> Result<()> { .map_err(|e| error!(e.to_string()))?; let warnings = warnings.read().expect("should lock"); all_warnings.write().expect("should lock").extend( - warnings - .iter() - .map(|e| Diagnostic::error("Css minimize error".to_string(), e.to_string())), + warnings.iter().map(|e| { + Diagnostic::warn("LightningCSS minimize warning".to_string(), e.to_string()) + }), ); result }; diff --git a/packages/rspack-test-tools/src/case/diagnostic.ts b/packages/rspack-test-tools/src/case/diagnostic.ts index 7a6c0bbd872..d3d13869797 100644 --- a/packages/rspack-test-tools/src/case/diagnostic.ts +++ b/packages/rspack-test-tools/src/case/diagnostic.ts @@ -14,7 +14,7 @@ const creator = new BasicCaseCreator({ format: (output: string) => { // TODO: change to stats.errorStack // TODO: add `errorStack: false` - return output.replace(/[│\s]*at([│\s]|.)*/g, ""); + return output.replace(/(│.* at ).*/g, "$1xxx"); } }) ] diff --git a/packages/rspack-test-tools/tests/__snapshots__/Defaults.test.js.snap b/packages/rspack-test-tools/tests/__snapshots__/Defaults.test.js.snap index 8bdf0f06172..f438e5b1abc 100644 --- a/packages/rspack-test-tools/tests/__snapshots__/Defaults.test.js.snap +++ b/packages/rspack-test-tools/tests/__snapshots__/Defaults.test.js.snap @@ -249,7 +249,7 @@ Object { "browserslist": Array [ "defaults", ], - "errorRecovery": false, + "errorRecovery": true, "removeUnusedLocalIdents": true, "unusedSymbols": Array [], }, diff --git a/packages/rspack-test-tools/tests/__snapshots__/StatsAPI.test.js.snap b/packages/rspack-test-tools/tests/__snapshots__/StatsAPI.test.js.snap index 3cce7db75d3..699ecd41bb8 100644 --- a/packages/rspack-test-tools/tests/__snapshots__/StatsAPI.test.js.snap +++ b/packages/rspack-test-tools/tests/__snapshots__/StatsAPI.test.js.snap @@ -41,7 +41,7 @@ Object { "files": Array [ "main.js", ], - "hash": "f2bc7a8c0bdc1f7b62f2", + "hash": "90a887a17a80d0e19be5", "id": "909", "idHints": Array [], "initial": true, @@ -157,7 +157,7 @@ Object { "errors": Array [], "errorsCount": 0, "filteredModules": undefined, - "hash": "ee11b48ddc40a1c0f1c4", + "hash": "c54fcee237a48276e019", "modules": Array [ Object { "assets": Array [], @@ -287,7 +287,7 @@ Object { "files": Array [ "main.js", ], - "hash": "e1a612615a3947e12730", + "hash": "5c934183f195b15a0942", "id": "909", "idHints": Array [], "initial": true, @@ -623,7 +623,7 @@ Object { "errors": Array [], "errorsCount": 0, "filteredModules": undefined, - "hash": "9ec361d93943966f85ad", + "hash": "c361435884d1304f092d", "modules": Array [ Object { "assets": Array [], @@ -1321,7 +1321,7 @@ Object { "files": Array [ "main.js", ], - "hash": "f2bc7a8c0bdc1f7b62f2", + "hash": "90a887a17a80d0e19be5", "id": "909", "idHints": Array [], "initial": true, @@ -1421,7 +1421,7 @@ Object { "files": Array [ "main.js", ], - "hash": "289e5d4472c8b47aba57", + "hash": "405eb59ae1d20f89b39f", "id": "909", "idHints": Array [], "initial": true, @@ -1741,7 +1741,7 @@ exports.c = require(\\"./c?c=3\\"); "errors": Array [], "errorsCount": 0, "filteredModules": undefined, - "hash": "891879cb580b1ccbf8ab", + "hash": "38e04132ef7ebc852f6a", "modules": Array [ Object { "assets": Array [], diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/factorize/cannot-resolve-context/index.js b/packages/rspack-test-tools/tests/diagnosticsCases/factorize/cannot-resolve-context/index.js index ab61f7c29d2..ee5fd59c1a8 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/factorize/cannot-resolve-context/index.js +++ b/packages/rspack-test-tools/tests/diagnosticsCases/factorize/cannot-resolve-context/index.js @@ -1,4 +1,4 @@ -// should not panic at crates/rspack_plugin_javascript/src/dependency/context/require_context_dependency.rs +// should not panic require.context("./test", false, /\.test\.js$/); diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/factorize/cannot-resolve-context/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/factorize/cannot-resolve-context/stats.err index 05695ad14a2..227adfc7135 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/factorize/cannot-resolve-context/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/factorize/cannot-resolve-context/stats.err @@ -1,4 +1,9 @@ ERROR in ./index.js × Resolve error: Can't resolve './test' in '/tests/diagnosticsCases/factorize/cannot-resolve-context' ╭─[1:1] - 1 │ // should not panic \ No newline at end of file + 1 │ // should not panic + 2 │ + 3 │ require.context("./test", false, //.test/.js$/); + · ─────────────────────────────────────────────── + 4 │ + ╰──── \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/factorize/cannot-resolve-with-concatenate-conflict/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/factorize/cannot-resolve-with-concatenate-conflict/stats.err index f4d4ca36523..42670f93c2d 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/factorize/cannot-resolve-with-concatenate-conflict/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/factorize/cannot-resolve-with-concatenate-conflict/stats.err @@ -1,2 +1,15 @@ ERROR in ./node_modules/some-module/a.ts - × Resolve error: Can't resolve './b.js' in '/tests/diagnosticsCases/factorize/cannot-resolve-with-conc \ No newline at end of file + × Resolve error: Can't resolve './b.js' in '/tests/diagnosticsCases/factorize/cannot-resolve-with-concatenate-conflict/node_modules/some-module' + ╭─[1:1] + 1 │ export * from "./b.js"; + · ──────── + 2 │ export * from "./c.js"; + ╰──── + +ERROR in ./node_modules/some-module/a.ts + × Resolve error: Can't resolve './c.js' in '/tests/diagnosticsCases/factorize/cannot-resolve-with-concatenate-conflict/node_modules/some-module' + ╭─[1:1] + 1 │ export * from "./b.js"; + 2 │ export * from "./c.js"; + · ──────── + ╰──── \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/factorize/cannot-resolve-with-concatenate-import/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/factorize/cannot-resolve-with-concatenate-import/stats.err index f4d4ca36523..dacdcfb3145 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/factorize/cannot-resolve-with-concatenate-import/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/factorize/cannot-resolve-with-concatenate-import/stats.err @@ -1,2 +1,6 @@ ERROR in ./node_modules/some-module/a.ts - × Resolve error: Can't resolve './b.js' in '/tests/diagnosticsCases/factorize/cannot-resolve-with-conc \ No newline at end of file + × Resolve error: Can't resolve './b.js' in '/tests/diagnosticsCases/factorize/cannot-resolve-with-concatenate-import/node_modules/some-module' + ╭──── + 1 │ export * from "./b.js"; + · ──────── + ╰──── \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/factorize/css-module-request-prefix/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/factorize/css-module-request-prefix/stats.err index 79853c16fb7..de24f5fb8c9 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/factorize/css-module-request-prefix/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/factorize/css-module-request-prefix/stats.err @@ -1,3 +1,22 @@ WARNING in ./index.css ⚠ Module parse warning: - ╰─▶ ⚠ CSS parsing warning: '@import' or 'url()' with a request starts with '~' is deprec \ No newline at end of file + ╰─▶ ⚠ CSS parsing warning: '@import' or 'url()' with a request starts with '~' is deprecated. + ╭─[1:1] + 1 │ @import "~pkg"; + · ─────────────── + 2 │ + 3 │ .class { + ╰──── + help: Remove '~' from the request. + +WARNING in ./index.css + ⚠ Module parse warning: + ╰─▶ ⚠ CSS parsing warning: '@import' or 'url()' with a request starts with '~' is deprecated. + ╭─[2:1] + 2 │ + 3 │ .class { + 4 │ background-image: url(~pkg/img.png); + · ───────────────── + 5 │ } + ╰──── + help: Remove '~' from the request. \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/factorize/dynamic-import-non-exist-module/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/factorize/dynamic-import-non-exist-module/stats.err index da665cee535..3888e52d760 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/factorize/dynamic-import-non-exist-module/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/factorize/dynamic-import-non-exist-module/stats.err @@ -5,4 +5,6 @@ ERROR in ./index.js 3 │ try { 4 │ await import("./non-exist") · ───────────────────── - 5 │ } c \ No newline at end of file + 5 │ } catch (err) { + 6 │ errored = true + ╰──── \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/factorize/fully-specified-resolve-suggestions/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/factorize/fully-specified-resolve-suggestions/stats.err index 37c477fac24..3d7af2a863a 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/factorize/fully-specified-resolve-suggestions/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/factorize/fully-specified-resolve-suggestions/stats.err @@ -10,4 +10,5 @@ ERROR in ./index.js probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"'. - The extension in the request is mand \ No newline at end of file + The extension in the request is mandatory for it to be fully specified. + Add the extension to the request. \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/factorize/mismatched-module-type/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/factorize/mismatched-module-type/stats.err index b111bc1116f..8bcf07a0ba2 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/factorize/mismatched-module-type/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/factorize/mismatched-module-type/stats.err @@ -1,3 +1,94 @@ ERROR in ./app.js × Module parse failed: - ╰─▶ × JavaScript parsing error: Untermin \ No newline at end of file + ╰─▶ × JavaScript parsing error: Unterminated regexp literal + ╭─[2:1] + 2 │ createElement() {} + 3 │ }; + 4 │ export const App = () =>
; + · ────── + ╰──── + + help: + You may need an appropriate loader to handle this file type. + +ERROR in ./app.js + × Module parse failed: + ╰─▶ × JavaScript parsing error: Expression expected + ╭─[2:1] + 2 │ createElement() {} + 3 │ }; + 4 │ export const App = () =>
; + · ─ + ╰──── + + help: + You may need an appropriate loader to handle this file type. + +ERROR in ./app.js + × Module parse failed: + ╰─▶ × JavaScript parsing error: Expression expected + ╭─[2:1] + 2 │ createElement() {} + 3 │ }; + 4 │ export const App = () =>
; + · ─ + ╰──── + + help: + You may need an appropriate loader to handle this file type. + +ERROR in ./app.jsx + × Module parse failed: + ╰─▶ × JavaScript parsing error: Unterminated regexp literal + ╭─[2:1] + 2 │ createElement() {} + 3 │ }; + 4 │ export const App = () =>
; + · ────── + ╰──── + + help: + You may need an appropriate loader to handle this file type. + +ERROR in ./app.jsx + × Module parse failed: + ╰─▶ × JavaScript parsing error: Expression expected + ╭─[2:1] + 2 │ createElement() {} + 3 │ }; + 4 │ export const App = () =>
; + · ─ + ╰──── + + help: + You may need an appropriate loader to handle this file type. + +ERROR in ./app.jsx + × Module parse failed: + ╰─▶ × JavaScript parsing error: Expression expected + ╭─[2:1] + 2 │ createElement() {} + 3 │ }; + 4 │ export const App = () =>
; + · ─ + ╰──── + + help: + You may need an appropriate loader to handle this file type. + +ERROR in ./app.ts + × Module parse failed: + ╰─▶ × JavaScript parsing error: Expected ',', got ':' + ╭─[1:1] + 1 │ const React = { + 2 │ createElement(elm: any) {} + · ─ + 3 │ }; + 4 │ function Component() { + ╰──── + + help: + You may need an appropriate loader to handle this file type. + +ERROR in ./index.js + × No parser registered for 'ts' \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/factorize/missing-config-build-failed/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/factorize/missing-config-build-failed/stats.err index d37a02e96b5..b7d1a09c6a2 100644 Binary files a/packages/rspack-test-tools/tests/diagnosticsCases/factorize/missing-config-build-failed/stats.err and b/packages/rspack-test-tools/tests/diagnosticsCases/factorize/missing-config-build-failed/stats.err differ diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/factorize/missing-module/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/factorize/missing-module/stats.err index 68ac991e071..82503124841 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/factorize/missing-module/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/factorize/missing-module/stats.err @@ -5,4 +5,6 @@ WARNING in ./index.js 3 │ try { 4 │ require("./missing-module"); · ─────────────────────────── - 5 │ } c \ No newline at end of file + 5 │ } catch (err) { + 6 │ errored = true; + ╰──── \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/factorize/optional-context-dependency/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/factorize/optional-context-dependency/stats.err index 5fc757c23c7..ed9605d8673 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/factorize/optional-context-dependency/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/factorize/optional-context-dependency/stats.err @@ -5,4 +5,11 @@ WARNING in ./locale.js 3 │ try { 4 │ locale = require('./locale/' + name); · ─────────────────────────── - 5 │ } c \ No newline at end of file + 5 │ } catch (e) { + 6 │ } + ╰──── + help: Found module './locale.js'. However, it's not possible to request this module without the extension + if its extension was not listed in the `resolve.extensions`. Here're some possible solutions: + + 1. add the extension `".js"` to `resolve.extensions` in your rspack configuration + 2. use './locale.js' instead of './locale' \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/factorize/prefer-relative-resolve-suggestions/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/factorize/prefer-relative-resolve-suggestions/stats.err index e2ad641d614..b9c12d7abcf 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/factorize/prefer-relative-resolve-suggestions/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/factorize/prefer-relative-resolve-suggestions/stats.err @@ -1,2 +1,13 @@ ERROR in ./index.js - × Resolve error: Can't resolve 'foo.js' in '/tests/diagnosticsCases/factorize/prefer-rel \ No newline at end of file + × Resolve error: Can't resolve 'foo.js' in '/tests/diagnosticsCases/factorize/prefer-relative-resolve-suggestions' + ╭──── + 1 │ import "foo.js" + · ──────── + ╰──── + help: Did you mean './foo.js'? + + Requests that should resolve in the current directory need to start with './'. + Requests that start with a name are treated as module requests and resolve within module directories (node_modules). + + If changing the source code is not an option, there is also a resolve options called 'preferRelative' + which tries to resolve these kind of requests in the current directory too. \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/factorize/resolve-extensions-error/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/factorize/resolve-extensions-error/stats.err index 8e54a1f5c5e..ac749d11d1a 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/factorize/resolve-extensions-error/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/factorize/resolve-extensions-error/stats.err @@ -7,4 +7,33 @@ ERROR in ./err/index.js help: Found module '../a.txt'. However, it's not possible to request this module without the extension if its extension was not listed in the `resolve.extensions`. Here're some possible solutions: - 1. add the extension `".txt"` to `resolve.extensions` in your rspack configur \ No newline at end of file + 1. add the extension `".txt"` to `resolve.extensions` in your rspack configuration + 2. use '../a.txt' instead of '../a' + +ERROR in ./index.js + × Resolve error: Can't resolve './test' in '/tests/diagnosticsCases/factorize/resolve-extensions-error' + ╭─[1:1] + 1 │ import './err'; + 2 │ import './test'; + · ──────── + 3 │ import a from './a'; + ╰──── + help: Found module './test/index.txt'. However, it's not possible to request this module without the extension + if its extension was not listed in the `resolve.extensions`. Here're some possible solutions: + + 1. add the extension `".txt"` to `resolve.extensions` in your rspack configuration + 2. use './test/index.txt' instead of './test' + +ERROR in ./index.js + × Resolve error: Can't resolve './a' in '/tests/diagnosticsCases/factorize/resolve-extensions-error' + ╭─[1:1] + 1 │ import './err'; + 2 │ import './test'; + 3 │ import a from './a'; + · ───── + ╰──── + help: Found module './a.txt'. However, it's not possible to request this module without the extension + if its extension was not listed in the `resolve.extensions`. Here're some possible solutions: + + 1. add the extension `".txt"` to `resolve.extensions` in your rspack configuration + 2. use './a.txt' instead of './a' \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/minimize/lightning-css-invalid/invalid.css b/packages/rspack-test-tools/tests/diagnosticsCases/minimize/lightning-css-invalid/invalid.css index 090b6dfe802..db848d5688a 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/minimize/lightning-css-invalid/invalid.css +++ b/packages/rspack-test-tools/tests/diagnosticsCases/minimize/lightning-css-invalid/invalid.css @@ -3,4 +3,12 @@ .a { color: red; -} \ No newline at end of file +} + +.b { + color; blue; +} + +.c<>c { + color: green; +} diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/minimize/lightning-css-invalid/rspack.config.js b/packages/rspack-test-tools/tests/diagnosticsCases/minimize/lightning-css-invalid/rspack.config.js index 2563c027015..c75a3b3e0ce 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/minimize/lightning-css-invalid/rspack.config.js +++ b/packages/rspack-test-tools/tests/diagnosticsCases/minimize/lightning-css-invalid/rspack.config.js @@ -7,9 +7,7 @@ module.exports = { optimization: { minimize: true, minimizer: [ - new rspack.LightningCssMinimizerRspackPlugin({ - errorRecovery: true, - }), + new rspack.LightningCssMinimizerRspackPlugin(), ] }, experiments: { diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/minimize/lightning-css-invalid/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/minimize/lightning-css-invalid/stats.err index 4195da110fe..5fade03425b 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/minimize/lightning-css-invalid/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/minimize/lightning-css-invalid/stats.err @@ -1 +1,7 @@ -ERROR in × Unknown \ No newline at end of file +WARNING in ⚠ Unknown at rule: @apply at main.css:4:7 + +WARNING in ⚠ Unexpected end of input at main.css:12:8 + +WARNING in ⚠ Unexpected end of input at main.css:12:14 + +WARNING in ⚠ Unexpected token Delim('<') at main.css:15:3 \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/asset-module-build-failed/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/asset-module-build-failed/stats.err index 37b18f04352..f831c274bea 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/asset-module-build-failed/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/asset-module-build-failed/stats.err @@ -1,3 +1,11 @@ ERROR in ./logo.svg × Module build failed: - ╰─▶ × Error: Failed to load \ No newline at end of file + ╰─▶ × Error: Failed to load + │ at xxx + │ at xxx + │ at xxx + │ at xxx + │ at xxx + │ at xxx + │ at xxx + │ \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/loader-throw-error/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/loader-throw-error/stats.err index 8417bf7d40a..7ca692e1000 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/loader-throw-error/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/loader-throw-error/stats.err @@ -1,3 +1,11 @@ ERROR in ./lib.js × Module build failed: - ╰─▶ × Error: Failed to load \ No newline at end of file + ╰─▶ × Error: Failed to load + │ at xxx + │ at xxx + │ at xxx + │ at xxx + │ at xxx + │ at xxx + │ at xxx + │ \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/unhandled-scheme-error/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/unhandled-scheme-error/stats.err index 3af5367dc02..d84118add78 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/unhandled-scheme-error/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/unhandled-scheme-error/stats.err @@ -1,4 +1,11 @@ ERROR in bar:baz × Module build failed: ╰─▶ × Reading from "bar:baz" is not handled by plugins (Unhandled scheme). - │ Rspack supports "d \ No newline at end of file + │ Rspack supports "data:" and "file:" URIs by default. + │ You may need an additional plugin to handle "bar:" URIs. + +ERROR in foo:bar + × Module build failed: + ╰─▶ × Reading from "foo:bar" is not handled by plugins (Unhandled scheme). + │ Rspack supports "data:" and "file:" URIs by default. + │ You may need an additional plugin to handle "foo:" URIs. \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/at-import-in-the-middle/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/at-import-in-the-middle/stats.err index 713d1fa2144..6b5c62acf97 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/at-import-in-the-middle/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/at-import-in-the-middle/stats.err @@ -11,4 +11,34 @@ ERROR in ./b.css ╰──── help: - You may need an appropri \ No newline at end of file + You may need an appropriate loader to handle this file type. + +ERROR in ./c.css + × Module parse failed: + ╰─▶ × CSS parsing error: Any '@import' rules must precede all other rules + ╭─[2:1] + 2 │ background: red; + 3 │ } + 4 │ @import "./a.css"; + · ─────── + 5 │ @import url("https://some/other/external/css"); + 6 │ + ╰──── + + help: + You may need an appropriate loader to handle this file type. + +ERROR in ./c.css + × Module parse failed: + ╰─▶ × CSS parsing error: Any '@import' rules must precede all other rules + ╭─[3:1] + 3 │ } + 4 │ @import "./a.css"; + 5 │ @import url("https://some/other/external/css"); + · ─────── + 6 │ + 7 │ .c { + ╰──── + + help: + You may need an appropriate loader to handle this file type. \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/basic/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/basic/stats.err index 79f18d5adf1..7bf8afa1f4d 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/basic/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/basic/stats.err @@ -9,4 +9,4 @@ ERROR in ./index.js ╰──── help: - You may need an appropri \ No newline at end of file + You may need an appropriate loader to handle this file type. \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/json/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/json/stats.err index 7a03f085317..0f6ad25a648 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/json/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/json/stats.err @@ -9,4 +9,4 @@ ERROR in ./syntax-error.json ╰──── help: - You may need an appropri \ No newline at end of file + You may need an appropriate loader to handle this file type. \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/lack-equal/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/lack-equal/stats.err index c32a3e58975..97f9b4f4e87 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/lack-equal/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/lack-equal/stats.err @@ -9,4 +9,18 @@ ERROR in ./index.js ╰──── help: - You may need an appropri \ No newline at end of file + You may need an appropriate loader to handle this file type. + +ERROR in ./index.js + × Module parse failed: + ╰─▶ × JavaScript parsing error: Expected a semicolon + ╭─[1:1] + 1 │ const CONST = 9000 % 2; + 2 │ const D { + · ─ + 3 │ d = 10 + 4 │ g = CONST + ╰──── + + help: + You may need an appropriate loader to handle this file type. \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/lexically_name_error/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/lexically_name_error/stats.err index 21d93f71e6a..88480552d45 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/lexically_name_error/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/lexically_name_error/stats.err @@ -7,4 +7,4 @@ ERROR in ./index.js ╰──── help: - You may need an appropri \ No newline at end of file + You may need an appropriate loader to handle this file type. \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/module-parse-error/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/module-parse-error/stats.err index 14a82becf69..2ede7de9223 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/module-parse-error/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/module-parse-error/stats.err @@ -7,4 +7,15 @@ ERROR in ./non-recoverable.js ╰──── help: - You may need an appropri \ No newline at end of file + You may need an appropriate loader to handle this file type. + +ERROR in ./recoverable.js + × Module parse failed: + ╰─▶ × JavaScript parsing error: Expected a semicolon + ╭──── + 1 │ const foo {}; + · ─ + ╰──── + + help: + You may need an appropriate loader to handle this file type. \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/multi_json_syntax_error/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/multi_json_syntax_error/stats.err index 12100cc1f50..54b0769e96a 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/multi_json_syntax_error/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/multi_json_syntax_error/stats.err @@ -9,4 +9,15 @@ ERROR in ./a.json ╰──── help: - You may need an appropri \ No newline at end of file + You may need an appropriate loader to handle this file type. + +ERROR in ./b.json + × Module parse failed: + ╰─▶ × Json parsing error: Unexpected end of JSON + ╭──── + 1 │ "测试utf8/" + · ▲ + ╰──── + + help: + You may need an appropriate loader to handle this file type. \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/multiple_file_syntax_error/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/multiple_file_syntax_error/stats.err index ba1ebb0638d..a1165be88c1 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/multiple_file_syntax_error/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/multiple_file_syntax_error/stats.err @@ -9,4 +9,180 @@ ERROR in ./a.js ╰──── help: - You may need an appropri \ No newline at end of file + You may need an appropriate loader to handle this file type. + +ERROR in ./a.js + × Module parse failed: + ╰─▶ × JavaScript parsing error: Expected a semicolon + ╭─[1:1] + 1 │ const CONST = 9000 % 2; + 2 │ const D { + · ─ + 3 │ // Comma is required, but parser can recover because of the newline. + 4 │ d = 10 + ╰──── + + help: + You may need an appropriate loader to handle this file type. + +ERROR in ./b.js + × Module parse failed: + ╰─▶ × JavaScript parsing error: Expression expected + ╭─[4:1] + 4 │ d = 10 + 5 │ g = CONST + 6 │ } + · ▲ + ╰──── + + help: + You may need an appropriate loader to handle this file type. + +ERROR in ./b.js + × Module parse failed: + ╰─▶ × JavaScript parsing error: Expected a semicolon + ╭─[1:1] + 1 │ const CONST = 9000 % 2; + 2 │ const D { + · ─ + 3 │ // Comma is required, but parser can recover because of the newline. + 4 │ d = 10 + ╰──── + + help: + You may need an appropriate loader to handle this file type. + +ERROR in ./c.js + × Module parse failed: + ╰─▶ × JavaScript parsing error: Expression expected + ╭─[4:1] + 4 │ d = 10 + 5 │ g = CONST + 6 │ } + · ▲ + ╰──── + + help: + You may need an appropriate loader to handle this file type. + +ERROR in ./c.js + × Module parse failed: + ╰─▶ × JavaScript parsing error: Expected a semicolon + ╭─[1:1] + 1 │ const CONST = 9000 % 2; + 2 │ const D { + · ─ + 3 │ // Comma is required, but parser can recover because of the newline. + 4 │ d = 10 + ╰──── + + help: + You may need an appropriate loader to handle this file type. + +ERROR in ./d.js + × Module parse failed: + ╰─▶ × JavaScript parsing error: Expression expected + ╭─[4:1] + 4 │ d = 10 + 5 │ g = CONST + 6 │ } + · ▲ + ╰──── + + help: + You may need an appropriate loader to handle this file type. + +ERROR in ./d.js + × Module parse failed: + ╰─▶ × JavaScript parsing error: Expected a semicolon + ╭─[1:1] + 1 │ const CONST = 9000 % 2; + 2 │ const D { + · ─ + 3 │ // Comma is required, but parser can recover because of the newline. + 4 │ d = 10 + ╰──── + + help: + You may need an appropriate loader to handle this file type. + +ERROR in ./e.js + × Module parse failed: + ╰─▶ × JavaScript parsing error: Expression expected + ╭─[4:1] + 4 │ d = 10 + 5 │ g = CONST + 6 │ } + · ▲ + ╰──── + + help: + You may need an appropriate loader to handle this file type. + +ERROR in ./e.js + × Module parse failed: + ╰─▶ × JavaScript parsing error: Expected a semicolon + ╭─[1:1] + 1 │ const CONST = 9000 % 2; + 2 │ const D { + · ─ + 3 │ // Comma is required, but parser can recover because of the newline. + 4 │ d = 10 + ╰──── + + help: + You may need an appropriate loader to handle this file type. + +ERROR in ./f.js + × Module parse failed: + ╰─▶ × JavaScript parsing error: Expression expected + ╭─[4:1] + 4 │ d = 10 + 5 │ g = CONST + 6 │ } + · ▲ + ╰──── + + help: + You may need an appropriate loader to handle this file type. + +ERROR in ./f.js + × Module parse failed: + ╰─▶ × JavaScript parsing error: Expected a semicolon + ╭─[1:1] + 1 │ const CONST = 9000 % 2; + 2 │ const D { + · ─ + 3 │ // Comma is required, but parser can recover because of the newline. + 4 │ d = 10 + ╰──── + + help: + You may need an appropriate loader to handle this file type. + +ERROR in ./g.js + × Module parse failed: + ╰─▶ × JavaScript parsing error: Expression expected + ╭─[4:1] + 4 │ d = 10 + 5 │ g = CONST + 6 │ } + · ▲ + ╰──── + + help: + You may need an appropriate loader to handle this file type. + +ERROR in ./g.js + × Module parse failed: + ╰─▶ × JavaScript parsing error: Expected a semicolon + ╭─[1:1] + 1 │ const CONST = 9000 % 2; + 2 │ const D { + · ─ + 3 │ // Comma is required, but parser can recover because of the newline. + 4 │ d = 10 + ╰──── + + help: + You may need an appropriate loader to handle this file type. \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/reserved_name_error/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/reserved_name_error/stats.err index 04a9c17ec1f..526c4e35101 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/reserved_name_error/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/reserved_name_error/stats.err @@ -8,4 +8,4 @@ ERROR in ./index.js ╰──── help: - You may need an appropri \ No newline at end of file + You may need an appropriate loader to handle this file type. \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/return-outside-function/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/return-outside-function/stats.err index 44f613729fc..a64607f5a73 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/return-outside-function/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/return-outside-function/stats.err @@ -1,3 +1,10 @@ ERROR in ./b.js × Module parse failed: - ╰─▶ × JavaScript parsing error: Return st \ No newline at end of file + ╰─▶ × JavaScript parsing error: Return statement is not allowed here + ╭──── + 1 │ return + · ────── + ╰──── + + help: + You may need an appropriate loader to handle this file type. \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/tla_disable_error/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/tla_disable_error/stats.err index 688c9b670b7..d1f75e88aec 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/tla_disable_error/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/tla_disable_error/stats.err @@ -11,4 +11,17 @@ ERROR in ./index.js ╰──── help: - You may need an appropri \ No newline at end of file + You may need an appropriate loader to handle this file type. + +ERROR in ./index.js + × Module parse failed: + ╰─▶ × JavaScript parsing error: The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it) + ╭─[1:1] + 1 │ const a = await Promise.resolve("aaa"); + · ───── + 2 │ + 3 │ for await (const _ of [Promise.resolve("bbbb")]) { } + ╰──── + + help: + You may need an appropriate loader to handle this file type. \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/tla_esm_error/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/tla_esm_error/stats.err index 9ca3b92adc8..0368b778374 100644 --- a/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/tla_esm_error/stats.err +++ b/packages/rspack-test-tools/tests/diagnosticsCases/module-parse-failed/tla_esm_error/stats.err @@ -9,4 +9,17 @@ ERROR in ./index.js ╰──── help: - You may need an appropri \ No newline at end of file + You may need an appropriate loader to handle this file type. + +ERROR in ./index.js + × Module parse failed: + ╰─▶ × JavaScript parsing error: Top-level-await is only supported in EcmaScript Modules + ╭─[1:1] + 1 │ await Promise.resolve("aaa"); + · ───── + 2 │ + 3 │ for await (const _ of [Promise.resolve("bbbb")]) { } + ╰──── + + help: + You may need an appropriate loader to handle this file type. \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/statsAPICases/basic.js b/packages/rspack-test-tools/tests/statsAPICases/basic.js index 240b52566f3..8db05b3e421 100644 --- a/packages/rspack-test-tools/tests/statsAPICases/basic.js +++ b/packages/rspack-test-tools/tests/statsAPICases/basic.js @@ -39,7 +39,7 @@ module.exports = { entry ./fixtures/a cjs self exports reference self [585] - Rspack compiled successfully (ee11b48ddc40a1c0f1c4)" + Rspack compiled successfully (c54fcee237a48276e019)" `); } }; diff --git a/packages/rspack-test-tools/tests/statsAPICases/chunks.js b/packages/rspack-test-tools/tests/statsAPICases/chunks.js index 417d474e7a5..566bb764012 100644 --- a/packages/rspack-test-tools/tests/statsAPICases/chunks.js +++ b/packages/rspack-test-tools/tests/statsAPICases/chunks.js @@ -26,7 +26,7 @@ module.exports = { "files": Array [ "chunkB.js", ], - "hash": "5cd998f6ef0b696b9ab9", + "hash": "e9b9cfaf734ee7b137b7", "id": "250", "idHints": Array [], "initial": false, @@ -134,7 +134,7 @@ module.exports = { "files": Array [ "main.js", ], - "hash": "759f98a96408013402e1", + "hash": "209a370004f0d25de9b5", "id": "909", "idHints": Array [], "initial": true, diff --git a/packages/rspack/src/builtin-plugin/LightningCssMiminizerRspackPlugin.ts b/packages/rspack/src/builtin-plugin/LightningCssMiminizerRspackPlugin.ts index 245c794e270..5665623fbb3 100644 --- a/packages/rspack/src/builtin-plugin/LightningCssMiminizerRspackPlugin.ts +++ b/packages/rspack/src/builtin-plugin/LightningCssMiminizerRspackPlugin.ts @@ -14,7 +14,7 @@ export const LightningCssMinimizerRspackPlugin = create( options?: LightningCssMinimizerRspackPluginOptions ): RawLightningCssMinimizerRspackPluginOptions => { return { - errorRecovery: options?.errorRecovery ?? false, + errorRecovery: options?.errorRecovery ?? true, unusedSymbols: options?.unusedSymbols ?? [], removeUnusedLocalIdents: options?.removeUnusedLocalIdents ?? true, browserslist: options?.browserslist ?? ["defaults"] diff --git a/website/docs/en/plugins/rspack/lightning-css-minimizer-rspack-plugin.mdx b/website/docs/en/plugins/rspack/lightning-css-minimizer-rspack-plugin.mdx index 09f8667a271..46600c0b13c 100644 --- a/website/docs/en/plugins/rspack/lightning-css-minimizer-rspack-plugin.mdx +++ b/website/docs/en/plugins/rspack/lightning-css-minimizer-rspack-plugin.mdx @@ -20,7 +20,7 @@ module.exports = { ### errorRecovery - **Type:** `boolean` -- **Default:** `false` +- **Default:** `true` Whether to ignore invalid rules and declarations rather than erroring. diff --git a/website/docs/zh/plugins/rspack/lightning-css-minimizer-rspack-plugin.mdx b/website/docs/zh/plugins/rspack/lightning-css-minimizer-rspack-plugin.mdx index bd684eb9a7e..04df61e3116 100644 --- a/website/docs/zh/plugins/rspack/lightning-css-minimizer-rspack-plugin.mdx +++ b/website/docs/zh/plugins/rspack/lightning-css-minimizer-rspack-plugin.mdx @@ -20,7 +20,7 @@ module.exports = { ### errorRecovery - **类型:** `boolean` -- **默认值:** `false` +- **默认值:** `true` 是否忽略无效的规则和声明而不进行报错。