You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2020/12/22 04:11:34 UTC
[incubator-echarts] branch treeshakable-exports updated: chore: not
mangle internal chunk. optimize dts output
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch treeshakable-exports
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git
The following commit(s) were added to refs/heads/treeshakable-exports by this push:
new ad8f240 chore: not mangle internal chunk. optimize dts output
ad8f240 is described below
commit ad8f2407070b7d4f3489aa2349074e49564e4713
Author: pissang <bm...@gmail.com>
AuthorDate: Tue Dec 22 12:10:40 2020 +0800
chore: not mangle internal chunk. optimize dts output
---
build/pre-publish.js | 46 +++++++++++++++++++++++++++--------------
index.d.ts | 8 +------
src/export/{time.ts => all.ts} | 6 ++++--
src/export/api.ts | 13 +++++++-----
src/export/{ => api}/format.ts | 2 +-
src/export/{ => api}/graphic.ts | 2 +-
src/export/{ => api}/number.ts | 2 +-
src/export/{ => api}/time.ts | 4 ++--
src/export/{ => api}/util.ts | 0
src/export/core.ts | 2 ++
10 files changed, 51 insertions(+), 34 deletions(-)
diff --git a/build/pre-publish.js b/build/pre-publish.js
index a5a821c..17c524d 100644
--- a/build/pre-publish.js
+++ b/build/pre-publish.js
@@ -39,6 +39,7 @@ const transformDEVUtil = require('./transform-dev');
const preamble = require('./preamble');
const dts = require('@lang/rollup-plugin-dts').default;
const rollup = require('rollup');
+const { path } = require('zrender');
const ecDir = nodePath.resolve(__dirname, '..');
const tmpDir = nodePath.resolve(ecDir, 'pre-publish-tmp');
@@ -400,17 +401,8 @@ async function readFilePaths({patterns, cwd}) {
async function bundleDTS() {
- const parts = [
- 'core', 'charts', 'components', 'renderers', 'option'
- ];
- const inputs = {};
- parts.forEach(partName => {
- inputs[partName] = nodePath.resolve(__dirname, `../types/src/export/${partName}.d.ts`)
- });
-
const outDir = nodePath.resolve(__dirname, '../types/dist');
- const bundle = await rollup.rollup({
- input: inputs,
+ const commonConfig = {
onwarn(warning, rollupWarn) {
// Not warn circular dependency
if (warning.code !== 'CIRCULAR_DEPENDENCY') {
@@ -431,15 +423,39 @@ ${chunk.code}`
}
}
]
+ };
+
+ // Bundle chunks.
+ const parts = [
+ 'core', 'charts', 'components', 'renderers', 'option'
+ ];
+ const inputs = {};
+ parts.forEach(partName => {
+ inputs[partName] = nodePath.resolve(__dirname, `../types/src/export/${partName}.d.ts`)
+ });
+
+ const bundle = await rollup.rollup({
+ input: inputs,
+ ...commonConfig
});
let idx = 1;
await bundle.write({
dir: outDir,
- chunkFileNames: (chunkInfo) => {
- const fileName = `common${idx > 1 ? idx : ''}.d.ts`;
- idx++;
- return fileName;
- }
+ minifyInternalExports: false,
+ manualChunks: (id) => {
+ // Only create one chunk.
+ return 'shared';
+ },
+ chunkFileNames: 'shared.d.ts'
+ });
+
+ // Bundle all in one
+ const bundleAllInOne = await rollup.rollup({
+ input: nodePath.resolve(__dirname, `../types/src/export/all.d.ts`),
+ ...commonConfig
+ });
+ await bundleAllInOne.write({
+ file: nodePath.resolve(outDir, 'echarts.d.ts')
});
}
diff --git a/index.d.ts b/index.d.ts
index 012239a..20195af 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -17,10 +17,4 @@
* under the License.
*/
-///////////////////////////////////////////////////////////////////////
-/// NOTE: types folder is generated by `npm run prepublish` command ///
-/// Make sure run it before edit this file. ///
-///////////////////////////////////////////////////////////////////////
-
-export * from './types/dist/core';
-export * from './types/dist/option';
\ No newline at end of file
+export * from './types/dist/echarts';
\ No newline at end of file
diff --git a/src/export/time.ts b/src/export/all.ts
similarity index 84%
copy from src/export/time.ts
copy to src/export/all.ts
index b908350..678c5d5 100644
--- a/src/export/time.ts
+++ b/src/export/all.ts
@@ -17,6 +17,8 @@
* under the License.
*/
-export {parseDate as parse} from '../util/number';
+// This file is for providing types when import whole module.
+// import * as echarts from 'echarts'
-export {format} from '../util/time';
\ No newline at end of file
+export * from './core';
+export * from './option';
\ No newline at end of file
diff --git a/src/export/api.ts b/src/export/api.ts
index 87c6d8a..554b0e2 100644
--- a/src/export/api.ts
+++ b/src/export/api.ts
@@ -16,6 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
+
+// Provide utilities API in echarts. It will be in echarts namespace.
+// Like echarts.util, echarts.graphic
export * as zrender from 'zrender/src/zrender';
export * as matrix from 'zrender/src/core/matrix';
@@ -38,10 +41,10 @@ export {default as env} from 'zrender/src/core/env';
export {default as parseGeoJSON} from '../coord/geo/parseGeoJson';
export {default as parseGeoJson} from '../coord/geo/parseGeoJson';
-export * as number from './number';
-export * as time from './time';
-export * as graphic from './graphic';
+export * as number from './api/number';
+export * as time from './api/time';
+export * as graphic from './api/graphic';
-export * as format from './format';
+export * as format from './api/format';
-export * as util from './util';
\ No newline at end of file
+export * as util from './api/util';
\ No newline at end of file
diff --git a/src/export/format.ts b/src/export/api/format.ts
similarity index 97%
rename from src/export/format.ts
rename to src/export/api/format.ts
index fce3522..ae2a3c8 100644
--- a/src/export/format.ts
+++ b/src/export/api/format.ts
@@ -28,4 +28,4 @@ export {
capitalFirst,
truncateText,
getTextRect
-} from '../util/format';
\ No newline at end of file
+} from '../../util/format';
\ No newline at end of file
diff --git a/src/export/graphic.ts b/src/export/api/graphic.ts
similarity index 97%
rename from src/export/graphic.ts
rename to src/export/api/graphic.ts
index 5a8416e..c6b4712 100644
--- a/src/export/graphic.ts
+++ b/src/export/api/graphic.ts
@@ -41,4 +41,4 @@ export {
LinearGradient,
RadialGradient,
BoundingRect
-} from '../util/graphic';
\ No newline at end of file
+} from '../../util/graphic';
\ No newline at end of file
diff --git a/src/export/number.ts b/src/export/api/number.ts
similarity index 97%
rename from src/export/number.ts
rename to src/export/api/number.ts
index 79f840d..ba8cf7a 100644
--- a/src/export/number.ts
+++ b/src/export/api/number.ts
@@ -36,4 +36,4 @@ export {
reformIntervals,
isNumeric,
numericToNumber
-} from '../util/number';
\ No newline at end of file
+} from '../../util/number';
\ No newline at end of file
diff --git a/src/export/time.ts b/src/export/api/time.ts
similarity index 89%
rename from src/export/time.ts
rename to src/export/api/time.ts
index b908350..41ab2b7 100644
--- a/src/export/time.ts
+++ b/src/export/api/time.ts
@@ -17,6 +17,6 @@
* under the License.
*/
-export {parseDate as parse} from '../util/number';
+export {parseDate as parse} from '../../util/number';
-export {format} from '../util/time';
\ No newline at end of file
+export {format} from '../../util/time';
\ No newline at end of file
diff --git a/src/export/util.ts b/src/export/api/util.ts
similarity index 100%
rename from src/export/util.ts
rename to src/export/api/util.ts
diff --git a/src/export/core.ts b/src/export/core.ts
index c489161..9ce12aa 100644
--- a/src/export/core.ts
+++ b/src/export/core.ts
@@ -17,6 +17,8 @@
* under the License.
*/
+// Core API from echarts/src/echarts
+
import { ComponentOption, ECBasicOption as EChartsCoreOption } from '../util/types';
import { AxisPointerOption } from '../component/axisPointer/AxisPointerModel';
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org