Skip to content

Commit

Permalink
Merge pull request #19543 from apache/module_default_esm_fix
Browse files Browse the repository at this point in the history
Fix package.json exports
  • Loading branch information
Ovilia authored Jan 25, 2024
2 parents f996884 + d403486 commit 61af513
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build/pre-publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const transformDEVUtil = require('./transform-dev');
const preamble = require('./preamble');
const dts = require('@lang/rollup-plugin-dts').default;
const rollup = require('rollup');
const { transformImport } = require('zrender/build/transformImport');
const { transformImport } = require('zrender/build/transformImport.js');

const ecDir = nodePath.resolve(__dirname, '..');
const tmpDir = nodePath.resolve(ecDir, 'pre-publish-tmp');
Expand Down
25 changes: 25 additions & 0 deletions package.README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# NOTICE about package.json

Only these entries are officially exported to users:
+ `'echarts'`
+ `'echarts/index.js'`
+ `'echarts/index.blank.js'`
+ `'echarts/index.common.js'`
+ `'echarts/index.simple.js'`
+ `'echarts/core.js'`
+ `'echarts/charts.js'`
+ `'echarts/components.js'`
+ `'echarts/features.js'`
+ `'echarts/renderers.js'`
+ `'echarts/i18n/*`
+ `'echarts/theme/*`
+ `'echarts/types/*`
+ `'echarts/extension/*`
+ `'echarts/dist/*`
+ `'echarts/ssr/client/index.js'`

The other entries listed in the `"exports"` field of `package.json` make the internal files visible, but they are legacy usages, not recommended but not forbidden (for the sake of keeping backward compatible). These entries are made from the search in github about which internal files are imported.

Since `v5.5.0`, `"type": "module"` and `"exports: {...}"` are added to `package.json`. When upgrading to `v5.5.0+`, if you meet some problems about "can not find/resolve xxx" when importing `echarts/i18n/xxx` or `echarts/theme/xxx` or some internal files, it probably because of the issue "file extension not fully specified". Please try to make the file extension fully specified (that is, `import 'xxx/xxx/xxx.js'` rather than `import 'xxx/xxx/xxx'`), or change the config of you bundler tools to support auto adding file extensions.

See more details about in the "exports" field of `package.json` and why it is written like that in https://github.com/apache/echarts/pull/19513 .
76 changes: 66 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,23 +127,79 @@
"./index.simple.js": "./index.simple.js",
"./index": "./index.js",
"./index.js": "./index.js",
"./theme/*": "./theme/*",
"./i18n/*": "./i18n/*",
"./ssr/client/index": {
"types": "./ssr/client/index.d.ts",
"import": "./ssr/client/index.js",
"require": "./ssr/client/dist/index.js"
},
"./extension/dataTool": "./extension/dataTool/index.js",
"./extension/dataTool/index": "./extension/dataTool/index.js",
"./extension/dataTool/index.js": "./extension/dataTool/index.js",
"./extension/dataTool/gexf": "./extension/dataTool/gexf.js",
"./extension/dataTool/gexf.js": "./extension/dataTool/gexf.js",
"./extension/dataTool/prepareBoxplotData": "./extension/dataTool/prepareBoxplotData.js",
"./extension/dataTool/prepareBoxplotData.js": "./extension/dataTool/prepareBoxplotData.js",
"./extension/bmap/bmap": "./extension/bmap/bmap.js",
"./extension/bmap/bmap.js": "./extension/bmap/bmap.js",
"./lib/echarts": "./lib/echarts.js",
"./lib/echarts.js": "./lib/echarts.js",
"./lib/extension": "./lib/extension.js",
"./lib/extension.js": "./lib/extension.js",
"./ssr/client/index": {
"types": "./ssr/client/index.d.ts",
"import": "./ssr/client/index.js",
"require": "./ssr/client/dist/index.js"
},
"./*.js": "./*.js",
"./*.ts": "./*.ts",
"./*.json": "./*.json",
"./*": "./*.js"
"./lib/chart/bar": "./lib/chart/bar.js",
"./lib/chart/boxplot": "./lib/chart/boxplot.js",
"./lib/chart/candlestick": "./lib/chart/candlestick.js",
"./lib/chart/custom": "./lib/chart/custom.js",
"./lib/chart/effectScatter": "./lib/chart/effectScatter.js",
"./lib/chart/funnel": "./lib/chart/funnel.js",
"./lib/chart/gauge": "./lib/chart/gauge.js",
"./lib/chart/graph": "./lib/chart/graph.js",
"./lib/chart/heatmap": "./lib/chart/heatmap.js",
"./lib/chart/line": "./lib/chart/line.js",
"./lib/chart/lines": "./lib/chart/lines.js",
"./lib/chart/map": "./lib/chart/map.js",
"./lib/chart/parallel": "./lib/chart/parallel.js",
"./lib/chart/pictorialBar": "./lib/chart/pictorialBar.js",
"./lib/chart/pie": "./lib/chart/pie.js",
"./lib/chart/radar": "./lib/chart/radar.js",
"./lib/chart/sankey": "./lib/chart/sankey.js",
"./lib/chart/scatter": "./lib/chart/scatter.js",
"./lib/chart/sunburst": "./lib/chart/sunburst.js",
"./lib/chart/themeRiver": "./lib/chart/themeRiver.js",
"./lib/chart/tree": "./lib/chart/tree.js",
"./lib/chart/treemap": "./lib/chart/treemap.js",
"./lib/component/aria": "./lib/component/aria.js",
"./lib/component/axisPointer": "./lib/component/axisPointer.js",
"./lib/component/brush": "./lib/component/brush.js",
"./lib/component/calendar": "./lib/component/calendar.js",
"./lib/component/dataZoom": "./lib/component/dataZoom.js",
"./lib/component/dataZoomInside": "./lib/component/dataZoomInside.js",
"./lib/component/dataZoomSelect": "./lib/component/dataZoomSelect.js",
"./lib/component/dataZoomSlider": "./lib/component/dataZoomSlider.js",
"./lib/component/dataset": "./lib/component/dataset.js",
"./lib/component/geo": "./lib/component/geo.js",
"./lib/component/graphic": "./lib/component/graphic.js",
"./lib/component/grid": "./lib/component/grid.js",
"./lib/component/gridSimple": "./lib/component/gridSimple.js",
"./lib/component/legend": "./lib/component/legend.js",
"./lib/component/legendPlain": "./lib/component/legendPlain.js",
"./lib/component/legendScroll": "./lib/component/legendScroll.js",
"./lib/component/markArea": "./lib/component/markArea.js",
"./lib/component/markLine": "./lib/component/markLine.js",
"./lib/component/markPoint": "./lib/component/markPoint.js",
"./lib/component/parallel": "./lib/component/parallel.js",
"./lib/component/polar": "./lib/component/polar.js",
"./lib/component/radar": "./lib/component/radar.js",
"./lib/component/singleAxis": "./lib/component/singleAxis.js",
"./lib/component/timeline": "./lib/component/timeline.js",
"./lib/component/title": "./lib/component/title.js",
"./lib/component/toolbox": "./lib/component/toolbox.js",
"./lib/component/tooltip": "./lib/component/tooltip.js",
"./lib/component/transform": "./lib/component/transform.js",
"./lib/component/visualMap": "./lib/component/visualMap.js",
"./lib/component/visualMapContinuous": "./lib/component/visualMapContinuous.js",
"./lib/component/visualMapPiecewise": "./lib/component/visualMapPiecewise.js",
"./*": "./*"
}
}
}

0 comments on commit 61af513

Please sign in to comment.