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

Provide more accurate error prompts when the import path does not exist #4769

Closed
Tracked by #3459
Ninglo opened this issue Nov 24, 2023 · 4 comments
Closed
Tracked by #3459
Assignees
Labels
A-resolver Area: resolver feat New feature or request good first issue Good for newcomers

Comments

@Ninglo
Copy link

Ninglo commented Nov 24, 2023

When I try to compile a project with a non-existent path in import, rspack will display an error message like this:

error[internal]: Resolve error
  ┌─ src/main/index.ts:1:1
  │  
1 │ ╭ import './non-existent/path'
2 │ │ 
  │ ╰^ Failed to resolve ./non-existent/path in typescript|<my_entry_path>

This error is emphasized on typescript, but typescript has absolutely nothing to do with the cause of this problem.
Especially in a non-code resource, such an error message will make people think that it is a loader problem rather than a path problem. For example:

error[internal]: Resolve error
  ┌─ src/main/index.ts:1:1
  │  
1 │ ╭ import './non-existent/path/foo.node'
2 │ │ 
  │ ╰^ Failed to resolve ./non-existent/foo.node in typescript|<my_entry_path>
@Ninglo
Copy link
Author

Ninglo commented Nov 24, 2023

System:
    OS: macOS 13.6.1 (22G313)
    CPU: 2.6 GHz 6-Core Intel Core i7
    Memory: 32 GB 2667 MHz DDR4
  npmPackages:
    @rsbuild/cli: 0.3.14

@Ninglo
Copy link
Author

Ninglo commented Nov 24, 2023

Source code:

// src/main/index.ts
import './non-existent/path/foo.node'
// rspack.config.js
const path = require('path');

/**
 * @type {import ('@rspack/cli').Configuration}
 */
const config = {
    entry: {
        index: path.join(__dirname, 'src/main/index.ts'),
    },
    output: {
        path: path.resolve(__dirname, 'dist'),
    }
}

@jerrykingxyz jerrykingxyz added feat New feature or request A-resolver Area: resolver labels Nov 24, 2023
@Boshen Boshen self-assigned this Nov 24, 2023
@Boshen Boshen added the good first issue Good for newcomers label Nov 24, 2023
@Ninglo
Copy link
Author

Ninglo commented Nov 24, 2023

May I be responsible for fulfilling this requirement? @Boshen

@h-a-n-a
Copy link
Contributor

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

You may upgrade to the latest version ;-). It's been fixed.

@h-a-n-a h-a-n-a closed this as completed Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolver Area: resolver feat New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants