web-infra-dev / rsbuild

The Rspack-based build tool. It's fast, out-of-the-box and extensible.
https://rsbuild.dev/
MIT License
1.62k stars 129 forks source link

[Bug]: Compilation errors occur when using `extensionAlias` with package names ending in `*.js` #3557

Open Fitz6 opened 3 weeks ago

Fitz6 commented 3 weeks ago

Version

Browsers:
  Edge: Chromium (127.0.2651.74)
npmPackages:
  @rsbuild/core: 1.0.6 => 1.0.6

Details

In version 1.0.6, I noticed that the rspack.config.js generated by rsbuild includes an extensionAlias configuration. If you install packageA, which has dependencies with package names ending in *.js, and packageA includes a node_modules folder, you'll encounter a compilation error.

 × All of the aliased extensions are not found for ....

You can reproduce it through the following steps:

# Choose the vanilla-ts template
npm create rsbuild@latest

npm install mathjs && mkdir node_modules/mathjs/node_modules
# or
pnpm install mathjs
// src/index.ts
import 'mathjs'
npm run build

Reproduce link

https://rsbuild.dev/guide/start/quick-start

Reproduce Steps

As mentioned above.

chenjiahan commented 3 weeks ago

I still cannot reproduce this issue, but the edge case bugs seem to exist and I will revert the feature before we fix it.

abenhamdine commented 3 weeks ago

I also get the same error message with module @ant-design/pro-layout

Fitz6 commented 3 weeks ago

I still cannot reproduce this issue, but the edge case bugs seem to exist and I will revert the feature before we fix it.

Perhaps you missed some steps, such as not adding import 'mathjs' in src/index.ts, or there is no node_modules folder under the node_modules/mathjs directory. I just tried it on both Linux and MacOS, and I can reproduce the same issue.

Fitz6 commented 3 weeks ago

I also get the same error message with module @ant-design/pro-layout

This is the same issue because @ant-design/pro-layout depends on omit.js.

SoonIter commented 3 weeks ago

let me reproduce it and fix in rspack-resolver