From a124d73e4ddbfb70536d518609b167acee7339db Mon Sep 17 00:00:00 2001 From: Hana Date: Tue, 19 Nov 2024 16:46:59 +0800 Subject: [PATCH 1/2] ci(release): fix release pull request (#8472) --- .github/workflows/release-pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-pull-request.yml b/.github/workflows/release-pull-request.yml index 16428470be7..1a9221606b6 100644 --- a/.github/workflows/release-pull-request.yml +++ b/.github/workflows/release-pull-request.yml @@ -47,7 +47,7 @@ jobs: # https://github.com/rspack-contrib/rspack-action uses: rspack-contrib/rspack-action@rspack with: - version: node ./x version ${{inputs.version || 'patch'}} --pre ${{inputs.prerelease || ''}} + version: node ./x version ${{inputs.version || 'patch'}} --pre ${{inputs.prerelease || 'none'}} createGithubReleases: false env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 522c39e740fffb61b6b4dfd7751a2e8565ba6a62 Mon Sep 17 00:00:00 2001 From: Gengkun Date: Tue, 19 Nov 2024 19:27:31 +0800 Subject: [PATCH 2/2] fix: modify css loading runtime panic (#8475) --- .../rspack_plugin_extract_css/src/plugin.rs | 3 +- .../index.css | 3 ++ .../index.js | 4 +++ .../rspack.config.js | 35 +++++++++++++++++++ 4 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 packages/rspack-test-tools/tests/configCases/hooks/modify-extract-css-loading-runtime/index.css create mode 100644 packages/rspack-test-tools/tests/configCases/hooks/modify-extract-css-loading-runtime/index.js create mode 100644 packages/rspack-test-tools/tests/configCases/hooks/modify-extract-css-loading-runtime/rspack.config.js diff --git a/crates/rspack_plugin_extract_css/src/plugin.rs b/crates/rspack_plugin_extract_css/src/plugin.rs index ba2f3d86096..7ab1b7ed3a3 100644 --- a/crates/rspack_plugin_extract_css/src/plugin.rs +++ b/crates/rspack_plugin_extract_css/src/plugin.rs @@ -476,8 +476,7 @@ fn runtime_requirement_in_tree( |_| false, move |chunk, compilation| { chunk - .content_hash(&compilation.chunk_hashes_results) - .expect("should have content hash") + .content_hash(&compilation.chunk_hashes_results)? .contains_key(&SOURCE_TYPE[0]) .then(|| { if chunk.can_be_initial(&compilation.chunk_group_by_ukey) { diff --git a/packages/rspack-test-tools/tests/configCases/hooks/modify-extract-css-loading-runtime/index.css b/packages/rspack-test-tools/tests/configCases/hooks/modify-extract-css-loading-runtime/index.css new file mode 100644 index 00000000000..5451a331f9c --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/hooks/modify-extract-css-loading-runtime/index.css @@ -0,0 +1,3 @@ +.a { + color: red; +} diff --git a/packages/rspack-test-tools/tests/configCases/hooks/modify-extract-css-loading-runtime/index.js b/packages/rspack-test-tools/tests/configCases/hooks/modify-extract-css-loading-runtime/index.js new file mode 100644 index 00000000000..d4c94ab73c5 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/hooks/modify-extract-css-loading-runtime/index.js @@ -0,0 +1,4 @@ +it("should modify runtime module source in main", async () => { + await import("./index.css"); + expect(__webpack_require__.f.miniCss.test).toBeTruthy(); +}); diff --git a/packages/rspack-test-tools/tests/configCases/hooks/modify-extract-css-loading-runtime/rspack.config.js b/packages/rspack-test-tools/tests/configCases/hooks/modify-extract-css-loading-runtime/rspack.config.js new file mode 100644 index 00000000000..8ebc3250149 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/hooks/modify-extract-css-loading-runtime/rspack.config.js @@ -0,0 +1,35 @@ +const webpack = require("@rspack/core"); + +class Plugin { + apply(compiler) { + compiler.hooks.compilation.tap("TestFakePlugin", compilation => { + compilation.hooks.runtimeModule.tap("TestFakePlugin", (module, chunk) => { + if (module.constructorName === "CssLoadingRuntimeModule") { + const originSource = module.source.source.toString("utf-8"); + module.source.source = Buffer.from( + `${originSource}\n__webpack_require__.f.miniCss.test = true;\n`, + "utf-8" + ); + } + }); + }); + } +} + +/**@type {import("@rspack/core").Configuration}*/ +module.exports = { + target: "web", + module: { + rules: [ + { + test: /\.css$/, + use: [webpack.CssExtractRspackPlugin.loader, "css-loader"], + type: "javascript/auto" + } + ] + }, + plugins: [ + new webpack.CssExtractRspackPlugin(), + new Plugin(), + ] +};