Skip to content

Commit

Permalink
fix: chunk render cache panic on css extract diagnostics (#8562)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahabhgk authored Nov 28, 2024
1 parent 21edaba commit 5f77de0
Show file tree
Hide file tree
Showing 23 changed files with 121 additions and 6 deletions.
2 changes: 1 addition & 1 deletion crates/rspack_core/src/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
Expand Down
6 changes: 3 additions & 3 deletions crates/rspack_core/src/old_cache/occasion/chunk_render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rspack_sources::BoxSource;

use crate::{old_cache::storage, Chunk, Compilation, SourceType};

type Storage = dyn storage::Storage<(BoxSource, Vec<Diagnostic>)>;
type Storage = dyn storage::Storage<BoxSource>;

#[derive(Debug)]
pub struct ChunkRenderOccasion {
Expand Down Expand Up @@ -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)
}
}
Expand Down
3 changes: 1 addition & 2 deletions crates/rspack_plugin_copy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,10 @@ impl CopyRspackPlugin {
}
Err(e) => {
let e: Error = DiagnosticError::from(e.boxed()).into();
let rspack_err: Vec<Diagnostic> = vec![e.into()];
diagnostics
.lock()
.expect("failed to obtain lock of `diagnostics`")
.extend(rspack_err);
.push(e.into());
return None;
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
content: "a";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import "./a.css"
import "./b.css"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
content: "b";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import "./b.css"
import "./a.css"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = [
/Conflicting order\. Following module has been added/,
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// import "./a.css"
import "./b.css"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = []
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import "./a.css"
import "./b.css"
Original file line number Diff line number Diff line change
@@ -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,
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
findBundle(i) {
return ["ab.js", "ba.js"];
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
content: "a";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import "./a.css"
import "./b.css"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
content: "b";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import "./b.css"
import "./a.css"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = [
/Conflicting order between/,
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// import "./a.css"
import "./b.css"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = []
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import "./a.css"
import "./b.css"
Original file line number Diff line number Diff line change
@@ -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,
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
findBundle(i) {
return ["ab.js", "ba.js"];
},
}

1 comment on commit 5f77de0

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ“ Ran ecosystem CI: Open

suite result
modernjs βœ… success
_selftest βœ… success
rsdoctor βœ… success
rspress βœ… success
rslib ❌ failure
rsbuild βœ… success
examples βœ… success
devserver βœ… success
nuxt βœ… success

Please sign in to comment.