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/11/05 10:02:53 UTC

[incubator-echarts] branch bundle-dts updated (663af17 -> e7b7171)

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

shenyi pushed a change to branch bundle-dts
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git.


    from 663af17  fix(sunburst): add an abstraction between callback params and inner structure
     new 7e425d4  fix(type): not leak inner structure in types
     new e7b7171  chore(type): add dts bundle

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 build/pre-publish.js | 108 +++++++++++++++++++++++++++++----------------------
 package.json         |   3 +-
 src/echarts.ts       |   5 ++-
 3 files changed, 66 insertions(+), 50 deletions(-)


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


[incubator-echarts] 01/02: fix(type): not leak inner structure in types

Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

shenyi pushed a commit to branch bundle-dts
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git

commit 7e425d401cf784f0e4bc8d82b77a1f70d898f671
Author: pissang <bm...@gmail.com>
AuthorDate: Thu Nov 5 18:02:08 2020 +0800

    fix(type): not leak inner structure in types
---
 src/echarts.ts | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/echarts.ts b/src/echarts.ts
index b36df31..1e47487 100644
--- a/src/echarts.ts
+++ b/src/echarts.ts
@@ -336,7 +336,8 @@ class ECharts extends Eventful {
     // Can't dispatch action during rendering procedure
     private _pendingActions: Payload[] = [];
 
-    protected _$eventProcessor: ECEventProcessor;
+    // We use unkown here so ECEventProcessor, which may include many unexpected types won't be exposed in the types to developers.
+    protected _$eventProcessor: unknown;
 
     private _disposed: boolean;
 
@@ -1016,7 +1017,7 @@ class ECharts extends Eventful {
                     params.event = e;
                     params.type = eveName;
 
-                    this._$eventProcessor.eventInfo = {
+                    (this._$eventProcessor as ECEventProcessor).eventInfo = {
                         targetEl: el,
                         packedEvent: params,
                         model: model,


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


[incubator-echarts] 02/02: chore(type): add dts bundle

Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

shenyi pushed a commit to branch bundle-dts
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git

commit e7b7171afd8c5c547c4f89e2554785ee9c95467c
Author: pissang <bm...@gmail.com>
AuthorDate: Thu Nov 5 18:02:35 2020 +0800

    chore(type): add dts bundle
---
 build/pre-publish.js | 108 +++++++++++++++++++++++++++++----------------------
 package.json         |   3 +-
 2 files changed, 63 insertions(+), 48 deletions(-)

diff --git a/build/pre-publish.js b/build/pre-publish.js
index b3c4b7d..29982e7 100644
--- a/build/pre-publish.js
+++ b/build/pre-publish.js
@@ -37,6 +37,9 @@ const ts = require('typescript');
 const globby = require('globby');
 const transformDEVUtil = require('./transform-dev');
 const preamble = require('./preamble');
+// NOTE: v1.4.2 is the latest version that supports ts 3.8.3
+const dts = require('rollup-plugin-dts').default;
+const rollup = require('rollup');
 
 const ecDir = nodePath.resolve(__dirname, '..');
 const tmpDir = nodePath.resolve(ecDir, 'pre-publish-tmp');
@@ -72,47 +75,6 @@ const typesDir = nodePath.resolve(ecDir, 'types');
 
 const compileWorkList = [
     {
-        logLabel: 'main ts -> js-cjs',
-        compilerOptionsOverride: {
-            module: 'CommonJS',
-            // `rootDir` Only use to control the output
-            // directory structure with --outDir.
-            rootDir: ecDir,
-            outDir: tmpDir
-        },
-        srcGlobby: mainSrcGlobby,
-        transformOptions: {
-            filesGlobby: {patterns: ['**/*.js'], cwd: tmpDir},
-            preamble: preamble.js,
-            transformDEV: true
-        },
-        before: async function () {
-            fsExtra.removeSync(tmpDir);
-            fsExtra.removeSync(nodePath.resolve(ecDir, 'lib'));
-            fsExtra.removeSync(nodePath.resolve(ecDir, 'index.js'));
-            fsExtra.removeSync(nodePath.resolve(ecDir, 'index.blank.js'));
-            fsExtra.removeSync(nodePath.resolve(ecDir, 'index.common.js'));
-            fsExtra.removeSync(nodePath.resolve(ecDir, 'index.simple.js'));
-        },
-        after: async function () {
-            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');
-            transformRootFolderInEntry(nodePath.resolve(ecDir, 'index.blank.js'), 'lib');
-            transformRootFolderInEntry(nodePath.resolve(ecDir, 'index.common.js'), 'lib');
-            transformRootFolderInEntry(nodePath.resolve(ecDir, 'index.simple.js'), 'lib');
-
-            await transformDistributionFiles(nodePath.resolve(ecDir, 'lib'), 'lib');
-            removeESmoduleMark();
-
-            fsExtra.removeSync(tmpDir);
-        }
-    },
-    {
         logLabel: 'main ts -> js-esm',
         compilerOptionsOverride: {
             module: 'ES2015',
@@ -150,6 +112,48 @@ const compileWorkList = [
 
             await transformDistributionFiles(nodePath.resolve(ecDir, 'esm'), 'esm');
             await transformDistributionFiles(nodePath.resolve(ecDir, 'types'), 'esm');
+            fsExtra.removeSync(tmpDir);
+
+            await bundleDTS();
+        }
+    },
+    {
+        logLabel: 'main ts -> js-cjs',
+        compilerOptionsOverride: {
+            module: 'CommonJS',
+            // `rootDir` Only use to control the output
+            // directory structure with --outDir.
+            rootDir: ecDir,
+            outDir: tmpDir
+        },
+        srcGlobby: mainSrcGlobby,
+        transformOptions: {
+            filesGlobby: {patterns: ['**/*.js'], cwd: tmpDir},
+            preamble: preamble.js,
+            transformDEV: true
+        },
+        before: async function () {
+            fsExtra.removeSync(tmpDir);
+            fsExtra.removeSync(nodePath.resolve(ecDir, 'lib'));
+            fsExtra.removeSync(nodePath.resolve(ecDir, 'index.js'));
+            fsExtra.removeSync(nodePath.resolve(ecDir, 'index.blank.js'));
+            fsExtra.removeSync(nodePath.resolve(ecDir, 'index.common.js'));
+            fsExtra.removeSync(nodePath.resolve(ecDir, 'index.simple.js'));
+        },
+        after: async function () {
+            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');
+            transformRootFolderInEntry(nodePath.resolve(ecDir, 'index.blank.js'), 'lib');
+            transformRootFolderInEntry(nodePath.resolve(ecDir, 'index.common.js'), 'lib');
+            transformRootFolderInEntry(nodePath.resolve(ecDir, 'index.simple.js'), 'lib');
+
+            await transformDistributionFiles(nodePath.resolve(ecDir, 'lib'), 'lib');
+            removeESmoduleMark();
 
             fsExtra.removeSync(tmpDir);
         }
@@ -311,9 +315,9 @@ async function transformDistributionFiles(rooltFolder, replacement) {
         code = singleTransformZRRootFolder(code, replacement);
         // For lower ts version, not use import type
         // TODO Use https://github.com/sandersn/downlevel-dts ?
-        if (fileName.endsWith('.d.ts')) {
-            code = singleTransformImportType(code);
-        }
+        // if (fileName.endsWith('.d.ts')) {
+        //     code = singleTransformImportType(code);
+        // }
         fs.writeFileSync(fileName, code, 'utf-8');
     }
 }
@@ -342,9 +346,9 @@ function singleTransformZRRootFolder(code, replacement) {
     return code.replace(/([\"\'])zrender\/src\//g, `$1zrender/${replacement}/`);
 }
 
-function singleTransformImportType(code) {
-    return code.replace(/import\s+type\s+/g, 'import ');
-}
+// function singleTransformImportType(code) {
+//     return code.replace(/import\s+type\s+/g, 'import ');
+// }
 
 /**
  * @param {Object} transformOptions
@@ -383,6 +387,16 @@ async function readFilePaths({patterns, cwd}) {
     );
 }
 
+async function bundleDTS() {
+    const bundle = await rollup.rollup({
+        input: nodePath.resolve(__dirname, '../index.d.ts'),
+        plugins: [dts()]
+    });
+    await bundle.write({
+        file: nodePath.resolve(__dirname, '../types/dist/echarts.d.ts')
+    });
+}
+
 function readTSConfig() {
     // tsconfig.json may have comment string, which is invalid if
     // using `require('tsconfig.json'). So we use a loose parser.
diff --git a/package.json b/package.json
index 779145a..8c4b761 100644
--- a/package.json
+++ b/package.json
@@ -10,7 +10,7 @@
   "main": "index.js",
   "module": "echarts.all.js",
   "jsdelivr": "dist/echarts.min.js",
-  "types": "index.d.ts",
+  "types": "types/dist/echarts.d.ts",
   "homepage": "http://echarts.apache.org",
   "repository": {
     "type": "git",
@@ -64,6 +64,7 @@
     "pngjs": "3.4.0",
     "rollup": "1.28.0",
     "rollup-plugin-commonjs": "8.4.1",
+    "rollup-plugin-dts": "1.4.2",
     "rollup-plugin-node-resolve": "3.0.0",
     "rollup-plugin-typescript2": "0.25.3",
     "seedrandom": "3.0.3",


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