echarts 5.5.0-rc.1 → 5.5.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/build.js CHANGED
@@ -111,13 +111,32 @@ async function run() {
111
111
  }
112
112
  else {
113
113
  const types = buildType.split(',').map(a => a.trim());
114
- const cfgs = types.map(type =>
115
- config.createECharts({
116
- ...opt,
117
- type
118
- })
119
- );
120
- await build(cfgs);
114
+
115
+
116
+ // Since 5.5.0, echarts/package.json added `{"type": "module"}`, and added
117
+ // echarts/dist/package.json with `{"type": "commonjs"}`, both of which makes
118
+ // echarts/dist/echarts.esm.js can not be recognized as esm any more (at least
119
+ // in webpack5 and nodejs) any more. So we provides echarts/dist/echarts.esm.mjs.
120
+ // But for backward compat, we still provide provides echarts/dist/echarts.esm.js.
121
+ const isBuildingDistESM = (opt.format || '').toLowerCase() === 'esm';
122
+ if (isBuildingDistESM) {
123
+ await makeConfigAndBuild(opt, '.js');
124
+ await makeConfigAndBuild(opt, '.mjs');
125
+ }
126
+ else {
127
+ await makeConfigAndBuild(opt);
128
+ }
129
+
130
+ async function makeConfigAndBuild(opt, fileExtension) {
131
+ const cfgs = types.map(type =>
132
+ config.createECharts({
133
+ ...opt,
134
+ type,
135
+ fileExtension
136
+ })
137
+ );
138
+ await build(cfgs);
139
+ }
121
140
  }
122
141
  }
123
142
 
package/build/config.js CHANGED
@@ -38,7 +38,7 @@ function createAddLicensePlugin(sourcemap) {
38
38
  }
39
39
  }
40
40
 
41
- function createOutputs(basename, { min }, commonOutputOpts) {
41
+ function createOutputs(basename, { min, fileExtension }, commonOutputOpts) {
42
42
  commonOutputOpts = {
43
43
  format: 'umd',
44
44
  ...commonOutputOpts
@@ -59,7 +59,7 @@ function createOutputs(basename, { min }, commonOutputOpts) {
59
59
  createReplacePlugin('development'),
60
60
  createAddLicensePlugin(true)
61
61
  ],
62
- file: basename + '.js'
62
+ file: basename + (fileExtension || '.js')
63
63
  }];
64
64
 
65
65
  if (min) {
@@ -73,7 +73,7 @@ function createOutputs(basename, { min }, commonOutputOpts) {
73
73
  terser(),
74
74
  createAddLicensePlugin(false)
75
75
  ],
76
- file: basename + '.min.js'
76
+ file: basename + '.min' + (fileExtension || '.js')
77
77
  })
78
78
  }
79
79
  return output;
@@ -86,6 +86,7 @@ function createOutputs(basename, { min }, commonOutputOpts) {
86
86
  * @param {string} [opt.format='umd'] If set, `opt.input` is required too, and `opt.type` is ignored.
87
87
  * @param {string} [opt.min=false] If build minified output
88
88
  * @param {boolean} [opt.addBundleVersion=false] Only for debug in watch, prompt that the two build is different.
89
+ * @param {string} [opt.fileExtension=undefined] output file extension, default is '.js'. Should start with '.'.
89
90
  */
90
91
  exports.createECharts = function (opt = {}) {
91
92
  const srcType = opt.type !== 'all' ? '.' + opt.type : '';