-
Notifications
You must be signed in to change notification settings - Fork 19.6k
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
[Bug] package.json is missing a package "type": "module" description #16709
Comments
I'm sorry to close this issue for it lacks the necessary title. Please provide a descriptive and as concise as possible title to describe your problems or requests and then the maintainers or I will reopen this issue. Every good bug report or feature request starts with a title. Your issue title is a critical element as it's the first thing maintainers see. A good issue title makes it easier for maintainers to understand what the issue is, easily locate it, and know what steps they'll need to take to fix it. Moreover, it's better to include keywords, as this makes it easier to find the issue self and similar issues in searches. |
This is a bug. export * from './lib/export/core.js';
^^^^^^
SyntaxError: Unexpected token 'export'
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1033:15)
at Module._compile (node:internal/modules/cjs/loader:1069:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10) because the content of A proper fix for this requires a major release, as it affects the way current users import (or require) echarts. Alternatively an One possible workaround to fix this within 5.x would be to add files with explicit ps. zrender has a similar issue. |
Cannot make echarts working with vitest because of this issue. Please considering fixing |
Having this only as ESM makes it unusable following the "minimal bundle" instructions when using CRA/using Jest. It is impossible to run tests, but works fine while building or developing ... makes the "minimal bundle" with TypeScripts unusable. |
Bump, this feature is really important as Vite-based framework sometimes does not work with this format. |
@FibreFoX any workaround or fixes to get jest working with minimal bundle? |
@Sujith1799 not yet, the only workaround I know is to not import the page when testing, as suggested here: facebook/create-react-app#12063 (comment) Something like this: // important: exclude this from testing, because Jest is unable to work with Apache EChart
// https://github.com/facebook/create-react-app/issues/12063
const YourComponentWithEcharts = (process.env.NODE_ENV === "test") ? (() => {
return null;
}) : lazy(() => import("./YourComponentWithEcharts")); This does not "make it testable", it just makes jest jump over the problematic stuff (until its fixed). Just remember as this uses the lazy-loading stuff, to wrap a <Suspense fallback={<PageLoadingSkeleton />}>
<YourComponentWithEcharts/>
</Suspense> |
Cool Thanks for this. |
@FibreFoX , when you implemented echarts in your repo, did you face any GC heap out of memory error. Im using NextJs and I keep getting out of memory error during the This is how I have implemented the echarts in my app ` const chartRef = React.useRef(null)
}, [option]); `
|
@Sujith1799 Thats a different topic, please let this thread stay "clean" on the original topic please. (but no, I haven't seen the problem, as I use React with this wrapper component: https://github.com/hustcc/echarts-for-react) |
Hi, any updates for the issue ? I'm also stuck and got this error when i tried to compil my app.
|
similar issue here |
Same problem using Node, Vite and echarts 5.4.2.
|
Same issue for me. Nuxt 3.8.2 & latest echarts. |
Same problem for me. |
Fixed by #19513 |
Version
5.3.1
Link to Minimal Reproduction
No response
Steps to Reproduce
Create app with nuxt bridge
Build that app using nuxi build
preview this app using nuxi preview
Current Behavior
Node throws error while trying import package as cjs module
Expected Behavior
Node import package as esm module
Environment
Any additional comments?
After building the application with nuxt bridge and running the application, Node tryes to import echarts and zrender as CJS modules, but there are ESM, as I can see. After I specified "type": "module" in both packages, the problem has been solved.
Please specify module type in package.json
The text was updated successfully, but these errors were encountered: