From d403486dadb46addf6d584208d48ac34293df8f4 Mon Sep 17 00:00:00 2001 From: 100pah Date: Thu, 25 Jan 2024 03:26:18 +0800 Subject: [PATCH] fix: (1) fix that some old version bundler (like rollup) do not recognize wildcard that not at the end of the patter string (e.g. "exports: {"./*.js": "xxx"}"). (2) Add readme to package.json. --- build/pre-publish.js | 2 +- package.README.md | 25 +++++++++++++++ package.json | 76 ++++++++++++++++++++++++++++++++++++++------ 3 files changed, 92 insertions(+), 11 deletions(-) create mode 100644 package.README.md diff --git a/build/pre-publish.js b/build/pre-publish.js index 9f6b68149d..e73525901f 100644 --- a/build/pre-publish.js +++ b/build/pre-publish.js @@ -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'); diff --git a/package.README.md b/package.README.md new file mode 100644 index 0000000000..014af704ea --- /dev/null +++ b/package.README.md @@ -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 . diff --git a/package.json b/package.json index 3fc7aa42c1..cb5a85f8ad 100644 --- a/package.json +++ b/package.json @@ -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", + "./*": "./*" } -} \ No newline at end of file +}