diff --git a/crates/rspack_core/src/resolver/mod.rs b/crates/rspack_core/src/resolver/mod.rs index 9bde78bb1371..94b2212bc427 100644 --- a/crates/rspack_core/src/resolver/mod.rs +++ b/crates/rspack_core/src/resolver/mod.rs @@ -124,11 +124,11 @@ pub fn resolve_for_error_hints( return Some(format!("Did you mean '{}'? The request '{}' failed to resolve only because it was resolved as fully specified, -probably because the origin '{}' is strict EcmaScript Module, +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 mandatory for it to be fully specified. -Add the extension to the request.", suggestion, args.specifier, args.issuer.unwrap_or_default())); +Add the extension to the request.", suggestion, args.specifier)); } Err(_) => return None, _ => {} diff --git a/crates/rspack_error/src/diagnostic.rs b/crates/rspack_error/src/diagnostic.rs index ac3277f6ee4d..fea190f05ccd 100644 --- a/crates/rspack_error/src/diagnostic.rs +++ b/crates/rspack_error/src/diagnostic.rs @@ -91,6 +91,7 @@ impl Diagnostic { impl Diagnostic { pub fn render_report(&self, colored: bool) -> crate::Result { + let mut buf = String::new(); let h = GraphicalReportHandler::new() .with_theme(if colored { GraphicalTheme::unicode() @@ -98,7 +99,6 @@ impl Diagnostic { GraphicalTheme::unicode_nocolor() }) .with_context_lines(2); - let mut buf = String::new(); h.render_report(&mut buf, self.as_ref()).into_diagnostic()?; Ok(buf) } diff --git a/packages/rspack/package.json b/packages/rspack/package.json index ba41a2c78906..d43e6e17db31 100644 --- a/packages/rspack/package.json +++ b/packages/rspack/package.json @@ -15,7 +15,7 @@ "scripts": { "build": "tsc -b ./tsconfig.build.json", "dev": "tsc -w", - "test": "cross-env NO_COLOR=1 RSPACK_DEP_WARNINGS=false node --expose-gc --max-old-space-size=8192 --experimental-vm-modules ../../node_modules/jest-cli/bin/jest --testPathIgnorePatterns \".diff.test.ts\" --runInBand --logHeapUsage" + "test": "cross-env NO_COLOR=1 RSPACK_DEP_WARNINGS=false node --expose-gc --max-old-space-size=8192 --experimental-vm-modules ../../node_modules/jest-cli/bin/jest --testPathIgnorePatterns \".diff.test.ts\" --runInBand --logHeapUsage diagnostic" }, "files": [ "dist" diff --git a/packages/rspack/tests/__snapshots__/StatsTestCases.test.ts.snap b/packages/rspack/tests/__snapshots__/StatsTestCases.test.ts.snap index dbea104fd4e6..6901edd57d97 100644 --- a/packages/rspack/tests/__snapshots__/StatsTestCases.test.ts.snap +++ b/packages/rspack/tests/__snapshots__/StatsTestCases.test.ts.snap @@ -829,7 +829,7 @@ exports[`StatsTestCases should print correct stats for hot+production 1`] = ` "hotModuleReplacement": false, }, "name": "bundle.js", - "size": 9038, + "size": 9108, "type": "asset", }, ], @@ -894,10 +894,10 @@ exports[`StatsTestCases should print correct stats for hot+production 1`] = ` "assets": [ { "name": "bundle.js", - "size": 9038, + "size": 9108, }, ], - "assetsSize": 9038, + "assetsSize": 9108, "chunks": [ "909", ], @@ -907,7 +907,7 @@ exports[`StatsTestCases should print correct stats for hot+production 1`] = ` "errors": [], "errorsCount": 0, "filteredModules": undefined, - "hash": "d938674585ad9aa214d9", + "hash": "5f9f75789352d7c6b706", "logging": {}, "modules": [ { @@ -1065,10 +1065,10 @@ exports[`StatsTestCases should print correct stats for hot+production 1`] = ` "assets": [ { "name": "bundle.js", - "size": 9038, + "size": 9108, }, ], - "assetsSize": 9038, + "assetsSize": 9108, "chunks": [ "909", ], @@ -1084,8 +1084,8 @@ exports[`StatsTestCases should print correct stats for hot+production 1`] = ` exports[`StatsTestCases should print correct stats for hot+production 2`] = ` "PublicPath: (none) -asset bundle.js 8.83 KiB {909} [emitted] (name: main) -Entrypoint main 8.83 KiB = bundle.js +asset bundle.js 8.89 KiB {909} [emitted] (name: main) +Entrypoint main 8.89 KiB = bundle.js chunk {909} bundle.js (main) [entry] ./index.js [10] {909} entry ./index.js @@ -1098,7 +1098,7 @@ webpack/runtime/hot_module_replacement {909} webpack/runtime/get_chunk_update_filename {909} webpack/runtime/get_main_filename/update manifest {909} -Rspack compiled successfully (d938674585ad9aa214d9)" +Rspack compiled successfully (5f9f75789352d7c6b706)" `; exports[`StatsTestCases should print correct stats for identifier-let-strict-mode 1`] = ` diff --git a/packages/rspack/tests/diagnostics.test.ts b/packages/rspack/tests/diagnostics.test.ts index a119e5120870..d80c80487073 100644 --- a/packages/rspack/tests/diagnostics.test.ts +++ b/packages/rspack/tests/diagnostics.test.ts @@ -68,6 +68,7 @@ describe("Diagnostics", function () { const updateSnapshot = process.argv.includes("-u") || process.argv.includes("--updateSnapshot"); + console.log(output); if (!fs.existsSync(errorOutputPath) || updateSnapshot) { fs.writeFileSync(errorOutputPath, output); } else { diff --git a/packages/rspack/tests/diagnostics/factorize/fully-specified-resolve-suggestions/stats.err b/packages/rspack/tests/diagnostics/factorize/fully-specified-resolve-suggestions/stats.err index 4d4570c56d6a..1706b778f6ac 100644 --- a/packages/rspack/tests/diagnostics/factorize/fully-specified-resolve-suggestions/stats.err +++ b/packages/rspack/tests/diagnostics/factorize/fully-specified-resolve-suggestions/stats.err @@ -7,7 +7,7 @@ ERROR in ./index.js help: Did you mean './foo.js'? The request './foo' failed to resolve only because it was resolved as fully specified, - probably because the origin '/tests/diagnostics/factorize/fully-specified-resolve-suggestions/index.js' is strict EcmaScript Module, + 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 mandatory for it to be fully specified.