You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by su...@apache.org on 2020/10/14 08:10:18 UTC

[incubator-echarts] 08/08: build: move /echarts.*.ts to src/echarts.*.ts . Otherwise if user import from 'echarts.all', it might be confused whether echarts.all.ts or echarts.all.js

This is an automated email from the ASF dual-hosted git repository.

sushuang pushed a commit to branch fix-ut
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git

commit 0d47e96910199d660735e33dccbe494ad32f58d1
Author: 100pah <su...@gmail.com>
AuthorDate: Wed Oct 14 14:06:16 2020 +0800

    build: move /echarts.*.ts to src/echarts.*.ts . Otherwise if user import from 'echarts.all', it might be confused whether echarts.all.ts or echarts.all.js
---
 build/config.js          |   5 +-
 build/pre-publish.js     |  32 +++---
 echarts.all.ts           | 272 -----------------------------------------------
 echarts.blank.ts         |  23 ----
 echarts.common.ts        |  44 --------
 echarts.simple.ts        |  27 -----
 index.d.ts               |   2 +-
 test/ut/core/utHelper.ts |   6 +-
 8 files changed, 21 insertions(+), 390 deletions(-)

diff --git a/build/config.js b/build/config.js
index 1d94ce8..06e88db 100644
--- a/build/config.js
+++ b/build/config.js
@@ -106,13 +106,12 @@ exports.createECharts = function (opt = {}) {
         output = nodePath.resolve(output);
     }
     else {
-        input = nodePath.resolve(ecDir, `echarts${srcType}.ts`);
+        input = nodePath.resolve(ecDir, `src/echarts${srcType}.ts`);
         output = nodePath.resolve(ecDir, `dist/echarts${postfixLang}${postfixType}.js`);
     }
 
     const include = [
-        nodePath.resolve(ecDir, 'src/**/*.ts'),
-        nodePath.resolve(ecDir, 'echarts*.ts')
+        nodePath.resolve(ecDir, 'src/**/*.ts')
     ];
 
     return {
diff --git a/build/pre-publish.js b/build/pre-publish.js
index 12577ca..b3c4b7d 100644
--- a/build/pre-publish.js
+++ b/build/pre-publish.js
@@ -53,11 +53,7 @@ const autoGeneratedFileAlert = `
 
 const mainSrcGlobby = {
     patterns: [
-        'src/**/*.ts',
-        'echarts.all.ts',
-        'echarts.blank.ts',
-        'echarts.common.ts',
-        'echarts.simple.ts'
+        'src/**/*.ts'
     ],
     cwd: ecDir
 };
@@ -99,10 +95,10 @@ const compileWorkList = [
             fsExtra.removeSync(nodePath.resolve(ecDir, 'index.simple.js'));
         },
         after: async function () {
-            fs.renameSync(nodePath.resolve(tmpDir, 'echarts.all.js'), nodePath.resolve(ecDir, 'index.js'));
-            fs.renameSync(nodePath.resolve(tmpDir, 'echarts.blank.js'), nodePath.resolve(ecDir, 'index.blank.js'));
-            fs.renameSync(nodePath.resolve(tmpDir, 'echarts.common.js'), nodePath.resolve(ecDir, 'index.common.js'));
-            fs.renameSync(nodePath.resolve(tmpDir, 'echarts.simple.js'), nodePath.resolve(ecDir, 'index.simple.js'));
+            fs.renameSync(nodePath.resolve(tmpDir, 'src/echarts.all.js'), nodePath.resolve(ecDir, 'index.js'));
+            fs.renameSync(nodePath.resolve(tmpDir, 'src/echarts.blank.js'), nodePath.resolve(ecDir, 'index.blank.js'));
+            fs.renameSync(nodePath.resolve(tmpDir, 'src/echarts.common.js'), nodePath.resolve(ecDir, 'index.common.js'));
+            fs.renameSync(nodePath.resolve(tmpDir, 'src/echarts.simple.js'), nodePath.resolve(ecDir, 'index.simple.js'));
             fs.renameSync(nodePath.resolve(tmpDir, 'src'), nodePath.resolve(ecDir, 'lib'));
 
             transformRootFolderInEntry(nodePath.resolve(ecDir, 'index.js'), 'lib');
@@ -141,10 +137,10 @@ const compileWorkList = [
             fsExtra.removeSync(nodePath.resolve(ecDir, 'echarts.simple.js'));
         },
         after: async function () {
-            fs.renameSync(nodePath.resolve(tmpDir, 'echarts.all.js'), nodePath.resolve(ecDir, 'echarts.all.js'));
-            fs.renameSync(nodePath.resolve(tmpDir, 'echarts.blank.js'), nodePath.resolve(ecDir, 'echarts.blank.js'));
-            fs.renameSync(nodePath.resolve(tmpDir, 'echarts.common.js'), nodePath.resolve(ecDir, 'echarts.common.js'));
-            fs.renameSync(nodePath.resolve(tmpDir, 'echarts.simple.js'), nodePath.resolve(ecDir, 'echarts.simple.js'));
+            fs.renameSync(nodePath.resolve(tmpDir, 'src/echarts.all.js'), nodePath.resolve(ecDir, 'echarts.all.js'));
+            fs.renameSync(nodePath.resolve(tmpDir, 'src/echarts.blank.js'), nodePath.resolve(ecDir, 'echarts.blank.js'));
+            fs.renameSync(nodePath.resolve(tmpDir, 'src/echarts.common.js'), nodePath.resolve(ecDir, 'echarts.common.js'));
+            fs.renameSync(nodePath.resolve(tmpDir, 'src/echarts.simple.js'), nodePath.resolve(ecDir, 'echarts.simple.js'));
             fs.renameSync(nodePath.resolve(tmpDir, 'src'), nodePath.resolve(ecDir, 'esm'));
 
             transformRootFolderInEntry(nodePath.resolve(ecDir, 'echarts.all.js'), 'esm');
@@ -280,14 +276,18 @@ async function tsCompile(compilerOptionsOverride, srcPathList) {
 }
 
 /**
- * Transform `src` root in the entry file to `esm` or `lib`
+ * Transform import/require path in the entry file to `esm` or `lib`.
  */
 function transformRootFolderInEntry(entryFile, replacement) {
     let code = fs.readFileSync(entryFile, 'utf-8');
     // Simple regex replacement
     // TODO More robust way?
-    code = code.replace(/([\"\'])\.\/src\//g, `$1./${replacement}/`)
-        .replace(/([\"\'])src\//g, `$1${replacement}/`);
+    assert(
+        !/(import\s+|from\s+|require\(\s*)["']\.\/echarts\./.test(code)
+        && !/(import\s+|from\s+|require\(\s*)["']echarts\./.test(code),
+        'Import echarts.xxx.ts is not supported.'
+    );
+    code = code.replace(/((import\s+|from\s+|require\(\s*)["'])\.\//g, `$1./${replacement}/`);
     fs.writeFileSync(
         entryFile,
         // Also transform zrender.
diff --git a/echarts.all.ts b/echarts.all.ts
deleted file mode 100644
index 0cd0e89..0000000
--- a/echarts.all.ts
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements.  See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership.  The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License.  You may obtain a copy of the License at
-*
-*   http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied.  See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-
-export * from './src/echarts';
-export * from './src/export';
-
-import './src/component/dataset';
-import './src/component/transform';
-
-// ----------------------------------------------
-// All of the modules that are allowed to be
-// imported are listed below.
-//
-// Users MUST NOT import other modules that are
-// not included in this list.
-// ----------------------------------------------
-
-
-
-// ----------------
-// Charts (series)
-// ----------------
-
-
-
-// All of the series types, for example:
-// chart.setOption({
-//     series: [{
-//         type: 'line' // or 'bar', 'pie', ...
-//     }]
-// });
-
-import './src/chart/line';
-import './src/chart/bar';
-import './src/chart/pie';
-import './src/chart/scatter';
-import './src/chart/radar';
-import './src/chart/map';
-import './src/chart/tree';
-import './src/chart/treemap';
-import './src/chart/graph';
-import './src/chart/gauge';
-import './src/chart/funnel';
-import './src/chart/parallel';
-import './src/chart/sankey';
-import './src/chart/boxplot';
-import './src/chart/candlestick';
-import './src/chart/effectScatter';
-import './src/chart/lines';
-import './src/chart/heatmap';
-import './src/chart/pictorialBar';
-import './src/chart/themeRiver';
-import './src/chart/sunburst';
-import './src/chart/custom';
-
-
-
-// -------------------
-// Coordinate systems
-// -------------------
-
-
-
-// All of the axis modules have been included in the
-// coordinate system module below, do not need to
-// make extra import.
-
-// `cartesian` coordinate system. For some historical
-// reasons, it is named as grid, for example:
-// chart.setOption({
-//     grid: {...},
-//     xAxis: {...},
-//     yAxis: {...},
-//     series: [{...}]
-// });
-import './src/component/grid';
-
-// `polar` coordinate system, for example:
-// chart.setOption({
-//     polar: {...},
-//     radiusAxis: {...},
-//     angleAxis: {...},
-//     series: [{
-//         coordinateSystem: 'polar'
-//     }]
-// });
-import './src/component/polar';
-
-// `geo` coordinate system, for example:
-// chart.setOption({
-//     geo: {...},
-//     series: [{
-//         coordinateSystem: 'geo'
-//     }]
-// });
-import './src/component/geo';
-
-// `singleAxis` coordinate system (notice, it is a coordinate system
-// with only one axis, work for chart like theme river), for example:
-// chart.setOption({
-//     singleAxis: {...}
-//     series: [{type: 'themeRiver', ...}]
-// });
-import './src/component/singleAxis';
-
-// `parallel` coordinate system, only work for parallel series, for example:
-// chart.setOption({
-//     parallel: {...},
-//     parallelAxis: [{...}, ...],
-//     series: [{
-//         type: 'parallel'
-//     }]
-// });
-import './src/component/parallel';
-
-// `calendar` coordinate system. for example,
-// chart.setOptionp({
-//     calendar: {...},
-//     series: [{
-//         coordinateSystem: 'calendar'
-//     }]
-// );
-import './src/component/calendar';
-
-
-
-// ------------------
-// Other components
-// ------------------
-
-
-
-// `graphic` component, for example:
-// chart.setOption({
-//     graphic: {...}
-// });
-import './src/component/graphic';
-
-// `toolbox` component, for example:
-// chart.setOption({
-//     toolbox: {...}
-// });
-import './src/component/toolbox';
-
-// `tooltip` component, for example:
-// chart.setOption({
-//     tooltip: {...}
-// });
-import './src/component/tooltip';
-
-// `axisPointer` component, for example:
-// chart.setOption({
-//     tooltip: {axisPointer: {...}, ...}
-// });
-// Or
-// chart.setOption({
-//     axisPointer: {...}
-// });
-import './src/component/axisPointer';
-
-// `brush` component, for example:
-// chart.setOption({
-//     brush: {...}
-// });
-// Or
-// chart.setOption({
-//     tooltip: {feature: {brush: {...}}
-// })
-import './src/component/brush';
-
-// `title` component, for example:
-// chart.setOption({
-//     title: {...}
-// });
-import './src/component/title';
-
-// `timeline` component, for example:
-// chart.setOption({
-//     timeline: {...}
-// });
-import './src/component/timeline';
-
-// `markPoint` component, for example:
-// chart.setOption({
-//     series: [{markPoint: {...}}]
-// });
-import './src/component/markPoint';
-
-// `markLine` component, for example:
-// chart.setOption({
-//     series: [{markLine: {...}}]
-// });
-import './src/component/markLine';
-
-// `markArea` component, for example:
-// chart.setOption({
-//     series: [{markArea: {...}}]
-// });
-import './src/component/markArea';
-
-// `legend` component scrollable, for example:
-// chart.setOption({
-//     legend: {type: 'scroll'}
-// });
-import './src/component/legendScroll';
-
-// `legend` component not scrollable. for example:
-// chart.setOption({
-//     legend: {...}
-// });
-import './src/component/legend';
-
-// `dataZoom` component including both `dataZoomInside` and `dataZoomSlider`.
-import './src/component/dataZoom';
-
-// `dataZoom` component providing drag, pinch, wheel behaviors
-// inside coodinate system, for example:
-// chart.setOption({
-//     dataZoom: {type: 'inside'}
-// });
-import './src/component/dataZoomInside';
-
-// `dataZoom` component providing a slider bar, for example:
-// chart.setOption({
-//     dataZoom: {type: 'slider'}
-// });
-import './src/component/dataZoomSlider';
-
-// `dataZoom` component including both `visualMapContinuous` and `visualMapPiecewise`.
-import './src/component/visualMap';
-
-// `visualMap` component providing continuous bar, for example:
-// chart.setOption({
-//     visualMap: {type: 'continuous'}
-// });
-import './src/component/visualMapContinuous';
-
-// `visualMap` component providing pieces bar, for example:
-// chart.setOption({
-//     visualMap: {type: 'piecewise'}
-// });
-import './src/component/visualMapPiecewise';
-
-
-
-// -----------------
-// Render engines
-// -----------------
-
-
-
-// Provide IE 6,7,8 compatibility.
-// import 'zrender/src/vml/vml';
-
-// Render via SVG rather than canvas.
-import 'zrender/src/svg/svg';
diff --git a/echarts.blank.ts b/echarts.blank.ts
deleted file mode 100644
index 41faa5a..0000000
--- a/echarts.blank.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements.  See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership.  The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License.  You may obtain a copy of the License at
-*
-*   http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied.  See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-
-export * from './src/echarts';
-export * from './src/export';
-
-import './src/component/dataset';
diff --git a/echarts.common.ts b/echarts.common.ts
deleted file mode 100644
index 760c9f5..0000000
--- a/echarts.common.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements.  See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership.  The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License.  You may obtain a copy of the License at
-*
-*   http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied.  See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-
-export * from './src/echarts';
-export * from './src/export';
-
-import './src/component/dataset';
-
-import './src/chart/line';
-import './src/chart/bar';
-import './src/chart/pie';
-import './src/chart/scatter';
-import './src/component/graphic';
-import './src/component/tooltip';
-import './src/component/axisPointer';
-import './src/component/legendScroll';
-
-import './src/component/grid';
-import './src/component/title';
-
-import './src/component/markPoint';
-import './src/component/markLine';
-import './src/component/markArea';
-import './src/component/dataZoom';
-import './src/component/toolbox';
-
-// import 'zrender/src/vml/vml';
-import 'zrender/src/svg/svg';
\ No newline at end of file
diff --git a/echarts.simple.ts b/echarts.simple.ts
deleted file mode 100644
index 4968b75..0000000
--- a/echarts.simple.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements.  See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership.  The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License.  You may obtain a copy of the License at
-*
-*   http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied.  See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-
-export * from './src/echarts';
-
-import './src/component/dataset';
-
-import './src/chart/line';
-import './src/chart/bar';
-import './src/chart/pie';
-import './src/component/gridSimple';
\ No newline at end of file
diff --git a/index.d.ts b/index.d.ts
index 603e951..fb3704e 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -22,6 +22,6 @@
 /// Make sure run it before edit this file.                         ///
 ///////////////////////////////////////////////////////////////////////
 
-export * from './types/echarts.all';
+export * from './types/src/echarts.all';
 
 export {EChartsFullOption as EChartsOption} from './types/src/option';
\ No newline at end of file
diff --git a/test/ut/core/utHelper.ts b/test/ut/core/utHelper.ts
index 38eadad..dcfdb1b 100755
--- a/test/ut/core/utHelper.ts
+++ b/test/ut/core/utHelper.ts
@@ -17,9 +17,7 @@
 * under the License.
 */
 
-// PENDING: should resolve that no `.ts` suffix.
-// @ts-ignore
-import { init, EChartsType } from '../../../echarts.all.ts';
+import { init, EChartsType } from '../../../src/echarts.all';
 
 import {
     curry as zrUtilCurry,
@@ -120,7 +118,7 @@ export function getGraphicElements(
         return (chartOrGroup as Group).children();
     }
     else {
-        const viewGroup = getViewGroup(chartOrGroup, mainType, index);
+        const viewGroup = getViewGroup(chartOrGroup as EChartsType, mainType, index);
         if (viewGroup) {
             const list: Element[] = [viewGroup];
             viewGroup.traverse(function (el: Element) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org