Skip to content

Commit

Permalink
try
Browse files Browse the repository at this point in the history
  • Loading branch information
h-a-n-a committed Jan 11, 2024
1 parent 971fa85 commit ef46868
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions crates/rspack_core/src/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
_ => {}
Expand Down
2 changes: 1 addition & 1 deletion crates/rspack_error/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ impl Diagnostic {

impl Diagnostic {
pub fn render_report(&self, colored: bool) -> crate::Result<String> {
let mut buf = String::new();
let h = GraphicalReportHandler::new()
.with_theme(if colored {
GraphicalTheme::unicode()
} else {
GraphicalTheme::unicode_nocolor()
})
.with_context_lines(2);
let mut buf = String::new();
h.render_report(&mut buf, self.as_ref()).into_diagnostic()?;
Ok(buf)
}
Expand Down
4 changes: 2 additions & 2 deletions packages/rspack/tests/Errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ it("should emit warnings for resolve failure in esm", async () => {
Object {
"errors": Array [
Object {
"formatted": " × Resolve error: Can't resolve './answer' in '<cwd>/tests/fixtures/errors/resolve-fail-esm'\\n ╭────\\n 1 │ import { answer } from './answer';\\n · ──────────\\n ╰────\\n help: Did you mean './answer.js'?\\n \\n The request './answer' failed to resolve only because it was resolved as fully specified,\\n probably because the origin '<cwd>/tests/fixtures/errors/resolve-fail-esm/index.js' is strict EcmaScript Module,\\n e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '\\"type\\": \\"module\\"'.\\n \\n The extension in the request is mandatory for it to be fully specified.\\n Add the extension to the request.\\n",
"message": " × Resolve error: Can't resolve './answer' in '<cwd>/tests/fixtures/errors/resolve-fail-esm'\\n ╭────\\n 1 │ import { answer } from './answer';\\n · ──────────\\n ╰────\\n help: Did you mean './answer.js'?\\n \\n The request './answer' failed to resolve only because it was resolved as fully specified,\\n probably because the origin '<cwd>/tests/fixtures/errors/resolve-fail-esm/index.js' is strict EcmaScript Module,\\n e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '\\"type\\": \\"module\\"'.\\n \\n The extension in the request is mandatory for it to be fully specified.\\n Add the extension to the request.\\n",
"formatted": " × Resolve error: Can't resolve './answer' in '<cwd>/tests/fixtures/errors/resolve-fail-esm'\\n ╭────\\n 1 │ import { answer } from './answer';\\n · ──────────\\n ╰────\\n help: Did you mean './answer.js'?\\n \\n The request './answer' failed to resolve only because it was resolved as fully specified,\\n probably because the origin is strict EcmaScript Module,\\n e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '\\"type\\": \\"module\\"'.\\n \\n The extension in the request is mandatory for it to be fully specified.\\n Add the extension to the request.\\n",
"message": " × Resolve error: Can't resolve './answer' in '<cwd>/tests/fixtures/errors/resolve-fail-esm'\\n ╭────\\n 1 │ import { answer } from './answer';\\n · ──────────\\n ╰────\\n help: Did you mean './answer.js'?\\n \\n The request './answer' failed to resolve only because it was resolved as fully specified,\\n probably because the origin is strict EcmaScript Module,\\n e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '\\"type\\": \\"module\\"'.\\n \\n The extension in the request is mandatory for it to be fully specified.\\n Add the extension to the request.\\n",
"moduleId": "./resolve-fail-esm/index.js",
"moduleIdentifier": "javascript/esm|<cwd>/tests/fixtures/errors/resolve-fail-esm/index.js",
"moduleName": "./resolve-fail-esm/index.js",
Expand Down
18 changes: 9 additions & 9 deletions packages/rspack/tests/__snapshots__/StatsTestCases.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
],
Expand Down Expand Up @@ -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",
],
Expand All @@ -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": [
{
Expand Down Expand Up @@ -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",
],
Expand All @@ -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
Expand All @@ -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`] = `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<PROJECT_ROOT>/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.
Expand Down

0 comments on commit ef46868

Please sign in to comment.