From 6b0e319a620873a14c6ce319a2009ba4297b8aef Mon Sep 17 00:00:00 2001 From: Fy <1114550440@qq.com> Date: Tue, 3 Dec 2024 17:58:12 +0800 Subject: [PATCH 1/2] fix: importModule should have err (#8590) * fix: importModule should have err * fix: importModule should have err --- crates/rspack_binding_values/src/compilation/mod.rs | 1 + .../loader-import-syntax-error/index.js | 3 +++ .../loader-import-syntax-error/loader.js | 11 +++++++++++ .../loader-import-syntax-error/rspack.config.js | 13 +++++++++++++ .../loader-import-syntax-error/stats.err | 12 ++++++++++++ .../loader-import-syntax-error/syntax-error.js | 1 + .../rspack/src/builtin-plugin/css-extract/loader.ts | 1 + packages/rspack/src/loader-runner/index.ts | 2 +- 8 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/loader-import-syntax-error/index.js create mode 100644 packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/loader-import-syntax-error/loader.js create mode 100644 packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/loader-import-syntax-error/rspack.config.js create mode 100644 packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/loader-import-syntax-error/stats.err create mode 100644 packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/loader-import-syntax-error/syntax-error.js diff --git a/crates/rspack_binding_values/src/compilation/mod.rs b/crates/rspack_binding_values/src/compilation/mod.rs index 12bc12173a4..b10509c8b24 100644 --- a/crates/rspack_binding_values/src/compilation/mod.rs +++ b/crates/rspack_binding_values/src/compilation/mod.rs @@ -650,6 +650,7 @@ impl JsCompilation { original_module.map(ModuleIdentifier::from), ) .await; + let js_result = JsExecuteModuleResult { cacheable: res.cacheable, file_dependencies: res diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/loader-import-syntax-error/index.js b/packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/loader-import-syntax-error/index.js new file mode 100644 index 00000000000..0041c02292d --- /dev/null +++ b/packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/loader-import-syntax-error/index.js @@ -0,0 +1,3 @@ +it("should compile", (done) => { + done() +}); diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/loader-import-syntax-error/loader.js b/packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/loader-import-syntax-error/loader.js new file mode 100644 index 00000000000..73ecdb61765 --- /dev/null +++ b/packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/loader-import-syntax-error/loader.js @@ -0,0 +1,11 @@ +/** @type {import("../../../../dist").PitchLoaderDefinitionFunction} */ +module.exports = async function () { + try { + const result = await this.importModule("./syntax-error.js"); + + // here should be unreachable + expect(result).toBe(Symbol('unreachable')); + } catch (e) { + expect(e).toBeDefined() + } +}; diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/loader-import-syntax-error/rspack.config.js b/packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/loader-import-syntax-error/rspack.config.js new file mode 100644 index 00000000000..eb80c9caef6 --- /dev/null +++ b/packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/loader-import-syntax-error/rspack.config.js @@ -0,0 +1,13 @@ +/** @type {import("@rspack/core").Configuration} */ +module.exports = { + entry: "./index.js", + module: { + rules: [ + { + test: /index\.js/, + loader: "./loader", + options: {} + } + ] + }, +}; diff --git a/packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/loader-import-syntax-error/stats.err b/packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/loader-import-syntax-error/stats.err new file mode 100644 index 00000000000..e15f3805f21 --- /dev/null +++ b/packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/loader-import-syntax-error/stats.err @@ -0,0 +1,12 @@ +ERROR in ./index.js + × Module build failed: + ╰─▶ × Final loader(/tests/diagnosticsCases/module-build-failed/loader-import-syntax-error/loader.js??ruleSet[1].rules[0].use[0]) didn't return a Buffer or String + +ERROR in × Module parse failed: + ╰─▶ × JavaScript parsing error: Unexpected eof + ╭──── + 1 │ console.log( + ╰──── + + 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-build-failed/loader-import-syntax-error/syntax-error.js b/packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/loader-import-syntax-error/syntax-error.js new file mode 100644 index 00000000000..7e457fc4510 --- /dev/null +++ b/packages/rspack-test-tools/tests/diagnosticsCases/module-build-failed/loader-import-syntax-error/syntax-error.js @@ -0,0 +1 @@ +console.log( diff --git a/packages/rspack/src/builtin-plugin/css-extract/loader.ts b/packages/rspack/src/builtin-plugin/css-extract/loader.ts index b87b44044b8..184e91f4834 100644 --- a/packages/rspack/src/builtin-plugin/css-extract/loader.ts +++ b/packages/rspack/src/builtin-plugin/css-extract/loader.ts @@ -103,6 +103,7 @@ export const pitch: LoaderDefinition["pitch"] = function (request, _, data) { const callback = this.async(); const filepath = this.resourcePath; const parseMeta = this.__internal__parseMeta; + this.addDependency(filepath); let { publicPath } = this._compilation!.outputOptions; diff --git a/packages/rspack/src/loader-runner/index.ts b/packages/rspack/src/loader-runner/index.ts index 942df724adf..99794a3a84c 100644 --- a/packages/rspack/src/loader-runner/index.ts +++ b/packages/rspack/src/loader-runner/index.ts @@ -439,7 +439,7 @@ export async function runLoaders( } if (res.error) { - reject(new Error(err)); + reject(new Error(res.error)); } else { resolve( compiler.__internal__getModuleExecutionResult(res.id) From 08ddcdd0284f671d8b085a401e9da91deff1f68e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 3 Dec 2024 18:23:45 +0800 Subject: [PATCH 2/2] release:1.1.5 (#8599) Release Packages:1.1.5 Co-authored-by: github-actions[bot] Co-authored-by: Cong-Cong Pan --- crates/node_binding/package.json | 2 +- npm/darwin-arm64/package.json | 2 +- npm/darwin-x64/package.json | 2 +- npm/linux-x64-gnu/package.json | 2 +- npm/win32-x64-msvc/package.json | 2 +- package.json | 2 +- packages/create-rspack/package.json | 2 +- packages/rspack-cli/package.json | 2 +- packages/rspack-test-tools/package.json | 2 +- packages/rspack/package.json | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/node_binding/package.json b/crates/node_binding/package.json index 34d2722e72c..0222b914315 100644 --- a/crates/node_binding/package.json +++ b/crates/node_binding/package.json @@ -1,6 +1,6 @@ { "name": "@rspack/binding", - "version": "1.1.4", + "version": "1.1.5", "license": "MIT", "description": "Node binding for rspack", "main": "binding.js", diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json index 88de7a1ba4f..400315247ad 100644 --- a/npm/darwin-arm64/package.json +++ b/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "@rspack/binding-darwin-arm64", - "version": "1.1.4", + "version": "1.1.5", "license": "MIT", "description": "Node binding for rspack", "main": "rspack.darwin-arm64.node", diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json index e12f343864c..2245d68e2d7 100644 --- a/npm/darwin-x64/package.json +++ b/npm/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "@rspack/binding-darwin-x64", - "version": "1.1.4", + "version": "1.1.5", "license": "MIT", "description": "Node binding for rspack", "main": "rspack.darwin-x64.node", diff --git a/npm/linux-x64-gnu/package.json b/npm/linux-x64-gnu/package.json index 7b758113c45..6646d22e779 100644 --- a/npm/linux-x64-gnu/package.json +++ b/npm/linux-x64-gnu/package.json @@ -1,6 +1,6 @@ { "name": "@rspack/binding-linux-x64-gnu", - "version": "1.1.4", + "version": "1.1.5", "license": "MIT", "description": "Node binding for rspack", "main": "rspack.linux-x64-gnu.node", diff --git a/npm/win32-x64-msvc/package.json b/npm/win32-x64-msvc/package.json index 223786fbd21..1ddfba9c504 100644 --- a/npm/win32-x64-msvc/package.json +++ b/npm/win32-x64-msvc/package.json @@ -1,6 +1,6 @@ { "name": "@rspack/binding-win32-x64-msvc", - "version": "1.1.4", + "version": "1.1.5", "license": "MIT", "description": "Node binding for rspack", "main": "rspack.win32-x64-msvc.node", diff --git a/package.json b/package.json index 6fdcec16c4f..4b53a3d2ad3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "monorepo", - "version": "1.1.4", + "version": "1.1.5", "license": "MIT", "description": "The fast Rust-based web bundler with webpack-compatible API", "private": true, diff --git a/packages/create-rspack/package.json b/packages/create-rspack/package.json index 9a3f831fb5d..28a82098734 100644 --- a/packages/create-rspack/package.json +++ b/packages/create-rspack/package.json @@ -1,6 +1,6 @@ { "name": "create-rspack", - "version": "1.1.4", + "version": "1.1.5", "homepage": "https://rspack.dev", "bugs": "https://github.com/web-infra-dev/rspack/issues", "repository": { diff --git a/packages/rspack-cli/package.json b/packages/rspack-cli/package.json index 4991bc8e9fd..ffb7d2e3cda 100644 --- a/packages/rspack-cli/package.json +++ b/packages/rspack-cli/package.json @@ -1,6 +1,6 @@ { "name": "@rspack/cli", - "version": "1.1.4", + "version": "1.1.5", "description": "CLI for rspack", "homepage": "https://rspack.dev", "bugs": "https://github.com/web-infra-dev/rspack/issues", diff --git a/packages/rspack-test-tools/package.json b/packages/rspack-test-tools/package.json index 340d6023157..2709377eb11 100644 --- a/packages/rspack-test-tools/package.json +++ b/packages/rspack-test-tools/package.json @@ -1,6 +1,6 @@ { "name": "@rspack/test-tools", - "version": "1.1.4", + "version": "1.1.5", "license": "MIT", "description": "Test tools for rspack", "main": "dist/index.js", diff --git a/packages/rspack/package.json b/packages/rspack/package.json index 96b3d6b1fac..c7e323cf811 100644 --- a/packages/rspack/package.json +++ b/packages/rspack/package.json @@ -1,6 +1,6 @@ { "name": "@rspack/core", - "version": "1.1.4", + "version": "1.1.5", "webpackVersion": "5.75.0", "license": "MIT", "description": "The fast Rust-based web bundler with webpack-compatible API",