You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2021/10/06 04:10:20 UTC

[GitHub] [echarts] htr3n commented on issue #13700: Tree shaking support

htr3n commented on issue #13700:
URL: https://github.com/apache/echarts/issues/13700#issuecomment-935401250


   @pissang I used ECharts on the server-side based on your example here: https://gist.github.com/pissang/4c32ee30e35c91336af72b129a1a4a73.
   
   I configured my Node project to use ESM by default and wanted to use tree-shaking for small bundle (https://echarts.apache.org/handbook/en/basics/release-note/v5-upgrade-guide/#tree-shaking-api).
   
   Nonetheless, the following line throw an exception
   
   ```javascript
   import * as echarts from 'echarts/core';
   ```
   
   The exception
   ```
   /usr/bin/node /home/alext/Projects/NodeJS/echarts-ssr/demo/main.js
   internal/process/esm_loader.js:74
       internalBinding('errors').triggerUncaughtException(
                                 ^
   
   Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/alext/Projects/NodeJS/echarts-ssr/node_modules/echarts/core' imported from /home/alext/Projects/NodeJS/echarts-ssr/index.js
   Did you mean to import echarts-ssr/node_modules/echarts/core.js?
       at new NodeError (internal/errors.js:322:7)
       at finalizeResolution (internal/modules/esm/resolve.js:308:11)
       at moduleResolve (internal/modules/esm/resolve.js:731:10)
       at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:842:11)
       at Loader.resolve (internal/modules/esm/loader.js:89:40)
       at Loader.getModuleJob (internal/modules/esm/loader.js:242:28)
       at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:76:40)
       at link (internal/modules/esm/module_job.js:75:36) {
     code: 'ERR_MODULE_NOT_FOUND'
   }
   ```
   
   Here is the `package.json` of my project 
   ```json
   {
     "name": "echarts-ssr",
     "description": "",
     "version": "0.0.1",
     "main": "index.js",
     "author": "",
     "license": "MIT",
     "private": true,
     "type": "module",
     "dependencies": {
       "canvas": "^2.8.0",
       "echarts": "^5.2.1",
       "jsdom": "^17.0.0"
     },
     "devDependencies": {
       "@types/node": "^14",
       "tslint": "^6.1.3",
       "typescript": "^4.4.3"
     },
     "packageManager": "yarn@3.0.2"
   }
   ```
   
   How can I import sub-modules of ECharts  as I did in another (React) project?
   
   ```javascript
   import {LineChart} from "echarts/charts";
   import {SVGRenderer} from "echarts/renderers";
   ``` 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org