diff --git a/crates/rspack_core/src/compiler/mod.rs b/crates/rspack_core/src/compiler/mod.rs index 7bc43df7914..c593bee3ab3 100644 --- a/crates/rspack_core/src/compiler/mod.rs +++ b/crates/rspack_core/src/compiler/mod.rs @@ -208,7 +208,7 @@ impl Compiler { .await .err() { - self.compilation.extend_diagnostics(vec![e.into()]); + self.compilation.push_diagnostic(e.into()); } logger.time_end(make_hook_start); self.compilation.make().await?; diff --git a/crates/rspack_core/src/old_cache/occasion/chunk_render.rs b/crates/rspack_core/src/old_cache/occasion/chunk_render.rs index 81803c7c96a..bda2f35f7a4 100644 --- a/crates/rspack_core/src/old_cache/occasion/chunk_render.rs +++ b/crates/rspack_core/src/old_cache/occasion/chunk_render.rs @@ -5,7 +5,7 @@ use rspack_sources::BoxSource; use crate::{old_cache::storage, Chunk, Compilation, SourceType}; -type Storage = dyn storage::Storage<(BoxSource, Vec)>; +type Storage = dyn storage::Storage; #[derive(Debug)] pub struct ChunkRenderOccasion { @@ -41,10 +41,10 @@ impl ChunkRenderOccasion { }; let cache_key = Identifier::from(content_hash.encoded()); if let Some(value) = storage.get(&cache_key) { - Ok(value) + Ok((value, Vec::new())) } else { let res = generator().await?; - storage.set(cache_key, res.clone()); + storage.set(cache_key, res.0.clone()); Ok(res) } } diff --git a/crates/rspack_plugin_copy/src/lib.rs b/crates/rspack_plugin_copy/src/lib.rs index 45a08dffe3f..946357ad77d 100644 --- a/crates/rspack_plugin_copy/src/lib.rs +++ b/crates/rspack_plugin_copy/src/lib.rs @@ -275,11 +275,10 @@ impl CopyRspackPlugin { } Err(e) => { let e: Error = DiagnosticError::from(e.boxed()).into(); - let rspack_err: Vec = vec![e.into()]; diagnostics .lock() .expect("failed to obtain lock of `diagnostics`") - .extend(rspack_err); + .push(e.into()); return None; } }; diff --git a/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/0/a.css b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/0/a.css new file mode 100644 index 00000000000..f86454b2aea --- /dev/null +++ b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/0/a.css @@ -0,0 +1,3 @@ +body { + content: "a"; +} \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/0/ab.js b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/0/ab.js new file mode 100644 index 00000000000..7202aa2ed72 --- /dev/null +++ b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/0/ab.js @@ -0,0 +1,2 @@ +import "./a.css" +import "./b.css" diff --git a/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/0/b.css b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/0/b.css new file mode 100644 index 00000000000..be45967cd87 --- /dev/null +++ b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/0/b.css @@ -0,0 +1,3 @@ +body { + content: "b"; +} \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/0/ba.js b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/0/ba.js new file mode 100644 index 00000000000..413e4d70a36 --- /dev/null +++ b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/0/ba.js @@ -0,0 +1,2 @@ +import "./b.css" +import "./a.css" diff --git a/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/0/warnings.js b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/0/warnings.js new file mode 100644 index 00000000000..9ee3c298cc8 --- /dev/null +++ b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/0/warnings.js @@ -0,0 +1,3 @@ +module.exports = [ + /Conflicting order\. Following module has been added/, +] diff --git a/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/1/ab.js b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/1/ab.js new file mode 100644 index 00000000000..ae4f710b389 --- /dev/null +++ b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/1/ab.js @@ -0,0 +1,2 @@ +// import "./a.css" +import "./b.css" diff --git a/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/1/warnings.js b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/1/warnings.js new file mode 100644 index 00000000000..d7faf17f9b9 --- /dev/null +++ b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/1/warnings.js @@ -0,0 +1 @@ +module.exports = [] diff --git a/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/2/ab.js b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/2/ab.js new file mode 100644 index 00000000000..7202aa2ed72 --- /dev/null +++ b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/2/ab.js @@ -0,0 +1,2 @@ +import "./a.css" +import "./b.css" diff --git a/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/rspack.config.js b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/rspack.config.js new file mode 100644 index 00000000000..b91d0068903 --- /dev/null +++ b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/rspack.config.js @@ -0,0 +1,42 @@ +const rspack = require("@rspack/core"); + +/** @type {import("@rspack/core").Configuration} */ +module.exports = { + entry: { + ab: './ab.js', + ba: './ba.js', + }, + output: { + filename: '[name].js' + }, + optimization: { + splitChunks: { + cacheGroups: { + styles: { + name: "styles", + chunks: "all", + test: /\.css$/, + enforce: true, + }, + }, + }, + }, + plugins: [ + new rspack.CssExtractRspackPlugin({ ignoreOrder: false }), + ], + module: { + rules: [ + { + test: /\.css$/, + use: [ + rspack.CssExtractRspackPlugin.loader, + "css-loader", + ], + type: "javascript/auto", + }, + ], + }, + experiments: { + css: false, + }, +}; diff --git a/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/test.config.js b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/test.config.js new file mode 100644 index 00000000000..69fd10d0785 --- /dev/null +++ b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-css-extract/test.config.js @@ -0,0 +1,5 @@ +module.exports = { + findBundle(i) { + return ["ab.js", "ba.js"]; + }, +} diff --git a/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/0/a.css b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/0/a.css new file mode 100644 index 00000000000..f86454b2aea --- /dev/null +++ b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/0/a.css @@ -0,0 +1,3 @@ +body { + content: "a"; +} \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/0/ab.js b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/0/ab.js new file mode 100644 index 00000000000..7202aa2ed72 --- /dev/null +++ b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/0/ab.js @@ -0,0 +1,2 @@ +import "./a.css" +import "./b.css" diff --git a/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/0/b.css b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/0/b.css new file mode 100644 index 00000000000..be45967cd87 --- /dev/null +++ b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/0/b.css @@ -0,0 +1,3 @@ +body { + content: "b"; +} \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/0/ba.js b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/0/ba.js new file mode 100644 index 00000000000..413e4d70a36 --- /dev/null +++ b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/0/ba.js @@ -0,0 +1,2 @@ +import "./b.css" +import "./a.css" diff --git a/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/0/warnings.js b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/0/warnings.js new file mode 100644 index 00000000000..586493b1b50 --- /dev/null +++ b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/0/warnings.js @@ -0,0 +1,3 @@ +module.exports = [ + /Conflicting order between/, +] diff --git a/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/1/ab.js b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/1/ab.js new file mode 100644 index 00000000000..ae4f710b389 --- /dev/null +++ b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/1/ab.js @@ -0,0 +1,2 @@ +// import "./a.css" +import "./b.css" diff --git a/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/1/warnings.js b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/1/warnings.js new file mode 100644 index 00000000000..d7faf17f9b9 --- /dev/null +++ b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/1/warnings.js @@ -0,0 +1 @@ +module.exports = [] diff --git a/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/2/ab.js b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/2/ab.js new file mode 100644 index 00000000000..7202aa2ed72 --- /dev/null +++ b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/2/ab.js @@ -0,0 +1,2 @@ +import "./a.css" +import "./b.css" diff --git a/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/rspack.config.js b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/rspack.config.js new file mode 100644 index 00000000000..2f8c9f49d0b --- /dev/null +++ b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/rspack.config.js @@ -0,0 +1,28 @@ +const rspack = require("@rspack/core"); + +/** @type {import("@rspack/core").Configuration} */ +module.exports = { + entry: { + ab: './ab.js', + ba: './ba.js', + }, + output: { + filename: '[name].js' + }, + target: "web", + optimization: { + splitChunks: { + cacheGroups: { + styles: { + name: "styles", + chunks: "all", + test: /\.css$/, + enforce: true, + }, + }, + }, + }, + experiments: { + css: true, + }, +}; diff --git a/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/test.config.js b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/test.config.js new file mode 100644 index 00000000000..69fd10d0785 --- /dev/null +++ b/packages/rspack-test-tools/tests/watchCases/css/chunk-render-cache-experiments-css/test.config.js @@ -0,0 +1,5 @@ +module.exports = { + findBundle(i) { + return ["ab.js", "ba.js"]; + }, +}