echarts
Advanced tools
Comparing version 5.5.0-rc.1 to 5.5.0-rc.2
@@ -114,9 +114,28 @@ #!/usr/bin/env node | ||
const types = buildType.split(',').map(a => a.trim()); | ||
const cfgs = types.map(type => | ||
config.createECharts({ | ||
...opt, | ||
type | ||
}) | ||
); | ||
await build(cfgs); | ||
// Since 5.5.0, echarts/package.json added `{"type": "module"}`, and added | ||
// echarts/dist/package.json with `{"type": "commonjs"}`, both of which makes | ||
// echarts/dist/echarts.esm.js can not be recognized as esm any more (at least | ||
// in webpack5 and nodejs) any more. So we provides echarts/dist/echarts.esm.mjs. | ||
// But for backward compat, we still provide provides echarts/dist/echarts.esm.js. | ||
const isBuildingDistESM = (opt.format || '').toLowerCase() === 'esm'; | ||
if (isBuildingDistESM) { | ||
await makeConfigAndBuild(opt, '.js'); | ||
await makeConfigAndBuild(opt, '.mjs'); | ||
} | ||
else { | ||
await makeConfigAndBuild(opt); | ||
} | ||
async function makeConfigAndBuild(opt, fileExtension) { | ||
const cfgs = types.map(type => | ||
config.createECharts({ | ||
...opt, | ||
type, | ||
fileExtension | ||
}) | ||
); | ||
await build(cfgs); | ||
} | ||
} | ||
@@ -123,0 +142,0 @@ } |
@@ -41,3 +41,3 @@ /* | ||
function createOutputs(basename, { min }, commonOutputOpts) { | ||
function createOutputs(basename, { min, fileExtension }, commonOutputOpts) { | ||
commonOutputOpts = { | ||
@@ -63,3 +63,3 @@ format: 'umd', | ||
], | ||
file: basename + '.js' | ||
file: basename + (fileExtension || '.js') | ||
}]; | ||
@@ -78,3 +78,3 @@ | ||
], | ||
file: basename + '.min.js' | ||
file: basename + '.min' + (fileExtension || '.js') | ||
}) | ||
@@ -92,2 +92,3 @@ } | ||
* @param {boolean} [opt.addBundleVersion=false] Only for debug in watch, prompt that the two build is different. | ||
* @param {string} [opt.fileExtension=undefined] output file extension, default is '.js'. Should start with '.'. | ||
*/ | ||
@@ -94,0 +95,0 @@ exports.createECharts = function (opt = {}) { |
{ | ||
"name": "echarts", | ||
"version": "5.5.0-rc.1", | ||
"version": "5.5.0-rc.2", | ||
"description": "Apache ECharts is a powerful, interactive charting and data visualization library for browser", | ||
@@ -110,3 +110,3 @@ "license": "Apache-2.0", | ||
"import": "./index.js", | ||
"require": "./index.js" | ||
"require": "./dist/echarts.js" | ||
}, | ||
@@ -204,4 +204,16 @@ "./core": "./core.js", | ||
"./lib/component/visualMapPiecewise": "./lib/component/visualMapPiecewise.js", | ||
"./dist/echarts.common": "./dist/echarts.common.js", | ||
"./dist/echarts.common.min": "./dist/echarts.common.min.js", | ||
"./dist/echarts.esm": "./dist/echarts.esm.mjs", | ||
"./dist/echarts.esm.min": "./dist/echarts.esm.min.mjs", | ||
"./dist/echarts": "./dist/echarts.js", | ||
"./dist/echarts.min": "./dist/echarts.min.js", | ||
"./dist/echarts.simple": "./dist/echarts.simple.js", | ||
"./dist/echarts.simple.min": "./dist/echarts.simple.min.js", | ||
"./dist/extension/bmap": "./dist/extension/bmap.js", | ||
"./dist/extension/bmap.min": "./dist/extension/bmap.min.js", | ||
"./dist/extension/dataTool": "./dist/extension/dataTool.js", | ||
"./dist/extension/dataTool.min": "./dist/extension/dataTool.min.js", | ||
"./*": "./*" | ||
} | ||
} |
# NOTICE about package.json | ||
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 . | ||
## Public and private | ||
Only these entries are officially exported to users: | ||
@@ -23,4 +28,11 @@ + `'echarts'` | ||
## File extension fully specified | ||
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 . | ||
## Use physical entry file or alias in `"exports"` of `package.json` | ||
Although using `"exports"` of `package.json` we can make alias (or say, route) to physical file (for example: `{ "exports": { "./xxx": "./yyy/zzz.js" } }` enables `import 'echarts/xxx'` to route to `'echarts/yyy/zzz.js'`), at present we can not make sure all the versions of bundle tools and runtimes in use do it consistently. So we do not use the alias setting, but keep providing physical file for each public entry. For example, for an official public entry `'echarts/core'`, we provide a file `echarts/core.js` (and `echarts/core.d.ts`). | ||
52846045
1277
522118