Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: resolve with hint #5178

Merged
merged 3 commits into from
Jan 11, 2024
Merged

feat: resolve with hint #5178

merged 3 commits into from
Jan 11, 2024

Conversation

h-a-n-a
Copy link
Collaborator

@h-a-n-a h-a-n-a commented Jan 2, 2024

Summary

Related #4348
Added resolve hint diagnostics.

prefer-relative:

ERROR in ./index.js
  × Resolve error: Can't resolve 'foo.js' in '<PROJECT_ROOT>/tests/diagnostics/factorize/prefer-relative-resolve-suggestions'
   ╭────
 1 │ import "foo.js";
   ·        ────────
   ╰────
  help: Did you mean './foo.js'?
        
        Requests that should resolve in the current directory need to start with './'.
        Requests that start with a name are treated as module requests and resolve within module directories (node_modules).
        
        If changing the source code is not an option, there is also a resolve options called 'preferRelative'
        which tries to resolve these kind of requests in the current directory too.

fully-specified:

ERROR in ./index.js
  × Resolve error: Can't resolve './foo' in '<PROJECT_ROOT>/tests/diagnostics/factorize/fully-specified-resolve-suggestions'
   ╭────
 1 │ import "./foo";
   ·        ───────
   ╰────
  help: Did you mean './foo.js'?
        
        The request './foo' failed to resolve only because it was resolved as fully specified,
        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.

Test Plan

See snapshot diagnostic changes:

  • rspack/tests/diagnostics/factorize/fully-specified-resolve-suggestions
  • rspack/tests/diagnostics/factorize/prefer-relative-resolve-suggestions

Other snapshot changes are caused by "error.separator!".

Require Documentation?

  • No
  • Yes, the corresponding rspack-website PR is __

Copy link
Collaborator Author

h-a-n-a commented Jan 2, 2024

@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label Jan 2, 2024
Base automatically changed from 12-27-feat_enhanced_resolve_diagnostics to main January 2, 2024 09:47
@h-a-n-a h-a-n-a force-pushed the 01-02-feat_resolve_with_hint branch from f29d066 to 7701e89 Compare January 2, 2024 09:54
@h-a-n-a h-a-n-a self-assigned this Jan 2, 2024
@h-a-n-a h-a-n-a force-pushed the 01-02-feat_resolve_with_hint branch 6 times, most recently from 2a0650d to 5a4f8b5 Compare January 11, 2024 04:20
@h-a-n-a h-a-n-a force-pushed the 01-02-feat_resolve_with_hint branch 4 times, most recently from d4387d3 to da4e3c8 Compare January 11, 2024 11:44
@h-a-n-a h-a-n-a force-pushed the 01-02-feat_resolve_with_hint branch from da4e3c8 to ef46868 Compare January 11, 2024 14:57
@h-a-n-a h-a-n-a marked this pull request as ready for review January 11, 2024 15:10
@h-a-n-a h-a-n-a requested review from a team, LingyuCoder and jerrykingxyz January 11, 2024 15:10
@Boshen Boshen merged commit a3f7ec1 into main Jan 11, 2024
26 checks passed
@Boshen Boshen deleted the 01-02-feat_resolve_with_hint branch January 11, 2024 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release: feature release: feature related release(mr only) team The issue/pr is created by the member of Rspack.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants