[Bug] Cannot import v5 theme if using esbuild
- Dominant language
- TypeScript
- Stars
- 67.3k
- Forks
- 19.8k
- Avg merge
- 11d 14h
- Merged PRs (30d)
- 8
Description
### Version
6.0.0
### Link to Minimal Reproduction
https://codesandbox.io/p/devbox/xp6t44
### Steps to Reproduce
1. Open the linked CodeSandbox
2. Open a new Terminal
3. Run `node build.js`
### Current Behavior
Attempting the build results in an import error:
```
Import from "echarts/theme/v5.js" to get the file "node_modules/echarts/theme/v5.js":
index.js:1:24:
1 │ import "echarts/theme/v5";
│ ^
╵ .js
You can mark the path "echarts/theme/v5" as external to exclude it from the bundle, which will
remove this error and leave the unresolved path in the bundle.
1 error
/project/workspace/node_modules/esbuild/lib/main.js:1477
let error = new Error(text);
^
Error: Build failed with 1 error:
index.js:1:7: ERROR: Could not resolve "echarts/theme/v5"
at failureErrorWithLog (/project/workspace/node_modules/esbuild/lib/main.js:1477:15)
at /project/workspace/node_modules/esbuild/lib/main.js:946:25
at /project/workspace/node_modules/esbuild/lib/main.js:898:52
at buildResponseToResult (/project/workspace/node_modules/esbuild/lib/main.js:944:7)
at /project/workspace/node_modules/esbuild/lib/main.js:971:16
at responseCallbacks. (/project/workspace/node_modules/esbuild/lib/main.js:623:9)
at handleIncomingPacket (/project/workspace/node_modules/esbuild/lib/main.js:678:12)
at Socket.readFromStdout (/project/workspace/node_modules/esbuild/lib/main.js:601:7)
at Socket.emit (node:events:518:28)
at addChunk (node:internal/streams/readable:559:12) {
errors: [Getter/Setter],
warnings: [Getter/Setter]
}
```
### Expected Behavior
I would expect the build to work! It works in other build tools, like Rspack. Changing the import path to `"echarts/theme/v5.js";` fixes the error in esbuild.
### Environment
```markdown
```
### Any additional comments?
I believe this is because of the `export` configuration in `package.json`. The `theme` wildcards are missing `.js`, I think the export needs to be changed to ` "./theme/*": "./theme/*.js",`. Strangely, this fails in esbuild, but not in other build tools like Rspack. This is not a major issue and has a simple workaround, but I thought it'd be good to report this. Thank you!
Contributor guide
Assessment
This issue has not been assessed yet.