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 2021/01/05 09:09:21 UTC

[incubator-echarts] branch improve-build created (now 40b4c84)

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

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


      at 40b4c84  chore: simplify build script. add type checking in husky

This branch includes the following new commits:

     new 40b4c84  chore: simplify build script. add type checking in husky

The 1 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.



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


[incubator-echarts] 01/01: chore: simplify build script. add type checking in husky

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

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

commit 40b4c841b5d63d8a1106c0922b9d5e71638b6447
Author: pissang <bm...@gmail.com>
AuthorDate: Tue Jan 5 16:57:26 2021 +0800

    chore: simplify build script. add type checking in husky
---
 .github/workflows/nodejs.yml |   5 +-
 .huskyrc                     |   2 +-
 README.md                    |  21 +---
 build/build.js               | 238 +++++++-------------------------------
 build/config.js              | 268 +++++++++++++++----------------------------
 build/pre-publish.js         |   5 +-
 build/progress.js            |  62 ----------
 build/release.js             |  81 -------------
 package.json                 |  18 +--
 9 files changed, 157 insertions(+), 543 deletions(-)

diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml
index fc9985a..db60873 100644
--- a/.github/workflows/nodejs.yml
+++ b/.github/workflows/nodejs.yml
@@ -33,11 +33,12 @@ jobs:
       - name: jshint
         run: |
           jshint
+      - name: check type
+        run: |
+          npm run checktype
       - name: build release
         run: |
           npm run release
-        env:
-          CI: true
 
   test:
     runs-on: ubuntu-latest
diff --git a/.huskyrc b/.huskyrc
index d4c92d5..92e4551 100644
--- a/.huskyrc
+++ b/.huskyrc
@@ -1,5 +1,5 @@
 {
   "hooks": {
-    "pre-commit": "npm run lint",
+    "pre-commit": "npm run lint && npm run checktype",
   }
 }
diff --git a/README.md b/README.md
index d59afa1..d0a9752 100644
--- a/README.md
+++ b/README.md
@@ -53,23 +53,14 @@ Execute the instructions in the root directory of the echarts:
 # Install the dependencies from NPM:
 npm install
 
-# If intending to build and get all types of the "production" files:
-npm run release
-# The same as `node build/build.js --release`
-
-# If only intending to get `dist/echarts.js`, which is usually
-# enough in dev or running the tests:
-npm run build
-# The same as `node build/build.js`
+# Rebuild source code immediately in watch mode when changing the source code.
+npm run dev
 
-# Get the same "production" files as `node build/build.js`, while
-# watching the editing of the source code. Usually used in dev.
-npm run watch
-# The same as `node build/build.js -w`
+# Check correctness of TypeScript code.
+npm run checktype
 
-# Check the manual:
-npm run help
-# The same as `node build/build.js --help`
+# If intending to build and get all types of the "production" files:
+npm run release
 ```
 
 Then the "production" files are generated in the `dist` directory.
diff --git a/build/build.js b/build/build.js
index 42bb096..d8e37a3 100755
--- a/build/build.js
+++ b/build/build.js
@@ -26,10 +26,7 @@ const chalk = require('chalk');
 const rollup = require('rollup');
 const prePublish = require('./pre-publish');
 const transformDEV = require('./transform-dev');
-const UglifyJS = require("uglify-js");
 const preamble = require('./preamble');
-const {buildI18n} = require('./build-i18n')
-const terser = require('terser');
 
 async function run() {
 
@@ -67,11 +64,6 @@ async function run() {
                 + '\n' + descIndent + '# Take `<cwd>/my/index.js` as input and generate `<cwd>/my/bundle.js`,'
         ].join('\n'))
         .option(
-            '-w, --watch', [
-            'Watch modifications of files and auto-compile to dist file. For example,',
-            descIndent + '`echarts/dist/echarts.js`.'
-        ].join('\n'))
-        .option(
             '--prepublish',
             'Build all for release'
         )
@@ -81,84 +73,63 @@ async function run() {
         )
         .option(
             '--type <type name>', [
-            'Can be "simple" or "common" or "" (default). For example,',
+            'Can be "simple" or "common" or "all" (default). Or can be simple,common,all to build multiple. For example,',
             descIndent + '`--type ""` or `--type "common"`.'
         ].join('\n'))
         .option(
-            '--sourcemap',
-            'Whether output sourcemap.'
-        )
-        .option(
             '--format <format>',
             'The format of output bundle. Can be "umd", "amd", "iife", "cjs", "esm".'
         )
-        .option(
-            '-i, --input <input file path>',
-            'If input file path is specified, output file path must be specified too.'
-        )
-        .option(
-            '-o, --output <output file path>',
-            'If output file path is specified, input file path must be specified too.'
-        )
-        .option(
-            '--clean',
-            'If cleaning build without cache. Maybe useful if some unexpected happens.'
-        )
         .parse(process.argv);
 
-    let isWatch = !!commander.watch;
-    let isRelease = !!commander.release;
     let isPrePublish = !!commander.prepublish;
+    let buildType = commander.type || 'all';
 
     let opt = {
         min: commander.min,
-        type: commander.type || '',
-        input: commander.input,
-        output: commander.output,
-        format: commander.format,
-        sourcemap: commander.sourcemap,
-        addBundleVersion: isWatch,
-        // Force to disable cache in release build.
-        // TODO npm run build also disable cache?
-        clean: commander.clean || isRelease
+        format: commander.format || 'umd'
     };
 
     validateIO(opt.input, opt.output);
 
-    if (isWatch) {
-        watch(config.createECharts(opt), opt.sourcemap);
-    }
-    else if (isPrePublish) {
+    if (isPrePublish) {
         await prePublish();
     }
-    else if (opt.type === 'extension') {
+    else if (buildType === 'extension') {
         const cfgs = [
-            config.createBMap(),
-            config.createDataTool()
+            config.createBMap(opt),
+            config.createDataTool(opt)
         ];
-        await build(cfgs, opt.min, opt.sourcemap);
+        await build(cfgs);
     }
-    else if (opt.type === 'myTransform') {
+    else if (buildType === 'myTransform') {
         const cfgs = [
-            config.createMyTransform()
+            config.createMyTransform(opt)
         ];
-        await build(cfgs, opt.min, opt.sourcemap);
+        await build(cfgs);
     }
     else {
-        const cfg = config.createECharts(opt);
-        await build([cfg], opt.min, opt.sourcemap);
-        checkBundleCode(cfg);
+        const types = buildType.split(',').map(a => a.trim());
+        const cfgs = types.map(type =>
+            config.createECharts({
+                ...opt,
+                type
+            })
+        );
+        await build(cfgs);
     }
 }
 
 function checkBundleCode(cfg) {
-    // Make sure __DEV__ is eliminated.
-    let code = fs.readFileSync(cfg.output.file, {encoding: 'utf-8'});
-    if (!code) {
-        throw new Error(`${cfg.output.file} is empty`);
+    // Make sure process.env.NODE_ENV is eliminated.
+    for (let output of cfg.output) {
+        let code = fs.readFileSync(output.file, {encoding: 'utf-8'});
+        if (!code) {
+            throw new Error(`${output.file} is empty`);
+        }
+        transformDEV.recheckDEV(code);
+        console.log(chalk.green.dim('Check code: correct.'));
     }
-    transformDEV.recheckDEV(code);
-    console.log(chalk.green.dim('Check code: correct.'));
 }
 
 function validateIO(input, output) {
@@ -177,169 +148,44 @@ function validateIO(input, output) {
  *      {
  *          ...inputOptions,
  *          output: [outputOptions],
- *          watch: {chokidar, include, exclude}
  *      },
  *      ...
  *  ]
  */
-async function build(configs, min, sourcemap) {
-    // buildI18n JSON before build when build
-    buildI18n();
+async function build(configs) {
+    console.log(chalk.yellow(`
+    NOTICE: If you are using 'npm run build'. Run 'npm run prepublish' before build !!!
+`));
 
-    // ensureZRenderCode.prepare();
+    console.log(chalk.yellow(`
+    NOTICE: If you are using syslink on zrender. Run 'npm run prepublish' in zrender first !!
+`));
 
     for (let singleConfig of configs) {
-
         console.log(
             chalk.cyan.dim('\Bundling '),
-            chalk.cyan(singleConfig.input),
-            chalk.cyan.dim('=>'),
-            chalk.cyan(singleConfig.output.file),
-            chalk.cyan.dim(' ...')
+            chalk.cyan(singleConfig.input)
         );
 
-        console.time('rollup build');
         const bundle = await rollup.rollup(singleConfig);
-        console.timeEnd('rollup build');
-
-        await bundle.write(singleConfig.output);
-        const sourceCode = fs.readFileSync(singleConfig.output.file, 'utf-8');
-        // Convert __DEV__ to true;
-        const transformResult = transformDEV.transform(sourceCode, sourcemap, 'true');
-        fs.writeFileSync(singleConfig.output.file, transformResult.code, 'utf-8');
-        if (transformResult.map) {
-            fs.writeFileSync(singleConfig.output.file + '.map', JSON.stringify(transformResult.map), 'utf-8');
-        }
-
-        console.log(
-            chalk.green.dim('Created '),
-            chalk.green(singleConfig.output.file),
-            chalk.green.dim(' successfully.')
-        );
 
-        if (min) {
-            const fileMinPath = singleConfig.output.file.replace(/.js$/, '.min.js');
-            console.log(
-                chalk.cyan.dim('Minifying '),
-                chalk.cyan(singleConfig.output.file),
-                chalk.cyan.dim('=>'),
-                chalk.cyan(fileMinPath),
-                chalk.cyan.dim(' ...')
-            )
-            console.time('Minify');
-            // Convert __DEV__ to false and let uglify remove the dead code;
-            const transformedCode = transformDEV.transform(sourceCode, false, 'false').code;
-            let minifyResult;
-            if (singleConfig.output.format !== 'esm') {
-                minifyResult = UglifyJS.minify(transformedCode, {
-                    output: {
-                        preamble: preamble.js
-                    }
-                });
-                if (minifyResult.error) {
-                    throw new Error(minifyResult.error);
-                }
-            }
-            else {
-                // Use terser for esm minify because uglify doesn't support esm code.
-                minifyResult = await terser.minify(transformedCode, {
-                    format: {
-                        preamble: preamble.js
-                    }
-                })
-            }
-            fs.writeFileSync(fileMinPath, minifyResult.code, 'utf-8');
-
-            console.timeEnd('Minify');
+        for (let output of singleConfig.output) {
             console.log(
                 chalk.green.dim('Created '),
-                chalk.green(fileMinPath),
+                chalk.green(output.file),
                 chalk.green.dim(' successfully.')
             );
-        }
 
-    }
+            await bundle.write(output);
 
-    // ensureZRenderCode.clear();
-}
-
-/**
- * @param {Object} singleConfig A single rollup config:
- *  See: <https://rollupjs.org/#big-list-of-options>
- *  For example:
- *  {
- *      ...inputOptions,
- *      output: [outputOptions],
- *      watch: {chokidar, include, exclude}
- *  }
- */
-function watch(singleConfig, sourcemap) {
-
-    let watcher = rollup.watch(singleConfig);
-
-    watcher.on('event', function (event) {
-        // event.code can be one of:
-        //   START        — the watcher is (re)starting
-        //   BUNDLE_START — building an individual bundle
-        //   BUNDLE_END   — finished building a bundle
-        //   END          — finished building all bundles
-        //   ERROR        — encountered an error while bundling
-        //   FATAL        — encountered an unrecoverable error
-        if (event.code !== 'START' && event.code !== 'END') {
-            console.log(
-                chalk.blue('[' + getTimeString() + ']'),
-                chalk.blue.dim('build'),
-                event.code.replace(/_/g, ' ').toLowerCase()
-            );
-        }
-        if (event.code === 'ERROR' || event.code === 'FATAL') {
-            printCodeError(event.error);
-        }
-        if (event.code === 'BUNDLE_END') {
+            console.time('rollup build');
+            console.timeEnd('rollup build');
+        };
 
-            const sourceCode = fs.readFileSync(singleConfig.output.file, 'utf-8');
-            // Convert __DEV__ to true;
-            const transformResult = transformDEV.transform(sourceCode, sourcemap, 'true');
-            fs.writeFileSync(singleConfig.output.file, transformResult.code, 'utf-8');
-
-            printWatchResult(event);
-        }
-    });
-}
-
-function printWatchResult(event) {
-    console.log(
-        chalk.green.dim('Created'),
-        chalk.green(event.output.join(', ')),
-        chalk.green.dim('in'),
-        chalk.green(event.duration),
-        chalk.green.dim('ms.')
-    );
-}
-
-function printCodeError(error) {
-    console.log('\n' + error.code);
-    if (error.code === 'PARSE_ERROR') {
-        console.log(
-            'line',
-            chalk.cyan(error.loc.line),
-            'column',
-            chalk.cyan(error.loc.column),
-            'in',
-            chalk.cyan(error.loc.file)
-        );
-    }
-    if (error.frame) {
-        console.log('\n' + chalk.red(error.frame));
+        checkBundleCode(singleConfig);
     }
-    console.log(chalk.red.dim('\n' + error.stack));
 }
 
-function getTimeString() {
-    return (new Date()).toLocaleString();
-}
-
-
 async function main() {
     try {
         await run();
diff --git a/build/config.js b/build/config.js
index b19ecbc..98bbe5b 100644
--- a/build/config.js
+++ b/build/config.js
@@ -17,225 +17,143 @@
 * under the License.
 */
 
-const assert = require('assert');
 const nodeResolvePlugin = require('@rollup/plugin-node-resolve').default;
 const nodePath = require('path');
 const ecDir = nodePath.resolve(__dirname, '..');
-const typescriptPlugin = require('rollup-plugin-typescript2');
-const fs = require('fs');
-const progress = require('./progress');
+const {terser} = require('rollup-plugin-terser');
+const replace = require('@rollup/plugin-replace');
 
-function preparePlugins(
-    {sourcemap, addBundleVersion, totalFiles, clean},
-    {include, exclude}
-) {
-    assert(include);
-
-    // In case node_modules/zrender is a symlink
-    const zrNodeModulePath = nodePath.resolve(ecDir, 'node_modules/zrender');
-    const zrRealPath = fs.realpathSync(zrNodeModulePath);
-    // if (zrRealPath !== zrNodeModulePath) {
-    //     include.push(zrRealPath + '/**/*.ts');
-    // }
-    include.push(zrRealPath + '/src/**/*.ts');
-
-    if (clean) {
-        console.log('Built in clean mode without cache.');
+function createOutputs(basename, { min }, commonOutputOpts) {
+    commonOutputOpts = {
+        format: 'umd',
+        ...commonOutputOpts
     }
-
-    let plugins = [
-        typescriptPlugin({
-            tsconfig: nodePath.resolve(ecDir, 'tsconfig.json'),
-            tsconfigOverride: {
-                // See: https://www.typescriptlang.org/docs/handbook/compiler-options.html
-                compilerOptions: {
-                    // By default: target === "ES3" or "ES5" ? "CommonJS" : "ES6".
-                    // But rollup don't use CommonJS.
-                    module: 'ES2015',
-                    sourceMap: !!sourcemap,
-                    // Use the esm d.ts
-                    declaration: false
-                }
-                // include: include,
-                // exclude: exclude || []
-            },
-            clean: clean || false,
-            include: include,
-            exclude: exclude || []
-        }),
-        nodeResolvePlugin(),
-        progress({
-            scope: {
-                total: totalFiles || 0
-            }
+    function createReplacePlugin(replacement) {
+        const plugin = replace({
+            'process.env.NODE_ENV': JSON.stringify(replacement)
+        });
+        // Remove transform hook. It will have warning when using in output
+        delete plugin.transform;
+        return plugin;
+    }
+    const output = [{
+        ...commonOutputOpts,
+        // Disable sourcemap in
+        sourcemap: true,
+        plugins: [
+            createReplacePlugin('development')
+        ],
+        file: basename + '.js'
+    }];
+
+    if (min) {
+        output.push({
+            ...commonOutputOpts,
+            // Disable sourcemap in min file.
+            sourcemap: false,
+            // TODO preamble
+            plugins: [
+                createReplacePlugin('production'),
+                terser()
+            ],
+            file: basename + '.min.js'
         })
-    ];
-
-    addBundleVersion && plugins.push({
-        outro: function () {
-            return 'exports.bundleVersion = \'' + (+new Date()) + '\';';
-        }
-    });
-
-    return plugins;
+    }
+    return output;
 }
 
 /**
  * @param {Object} [opt]
- * @param {string} [opt.type=''] '' or 'simple' or 'common'
- * @param {string} [opt.input=undefined] If set, `opt.output` is required too, and `opt.type` is ignored.
- * @param {string} [opt.output=undefined] If set, `opt.input` is required too, and `opt.type` is ignored.
+ * @param {string} [opt.type=''] 'all' or 'simple' or 'common', default is 'all'
  * @param {boolean} [opt.sourcemap] If set, `opt.input` is required too, and `opt.type` is ignored.
  * @param {string} [opt.format='umd'] If set, `opt.input` is required too, and `opt.type` is ignored.
+ * @param {string} [opt.min=false] If build minified output
  * @param {boolean} [opt.addBundleVersion=false] Only for debug in watch, prompt that the two build is different.
- * @param {Object} [opt.totalFiles] Total files to bundle
  */
 exports.createECharts = function (opt = {}) {
-    let srcType = opt.type ? '.' + opt.type : '.all';
-    let postfixType = opt.type ? '.' + opt.type : '';
-    let input = opt.input;
-    let output = opt.output;
-    let sourcemap = opt.sourcemap;
-    let format = opt.format || 'umd';
-    let postfixFormat = (format !== 'umd') ? '.' + format.toLowerCase() : '';
-
-    if (input != null || output != null) {
-        // Based on process.cwd();
-        input = nodePath.resolve(input);
-        output = nodePath.resolve(output);
-    }
-    else {
-        input = nodePath.resolve(ecDir, `src/echarts${srcType}.ts`);
-        output = nodePath.resolve(ecDir, `dist/echarts${postfixFormat}${postfixType}.js`);
-    }
+    const srcType = opt.type !== 'all' ? '.' + opt.type : '';
+    const postfixType = srcType;
+    const format = opt.format || 'umd';
+    const postfixFormat = (format !== 'umd') ? '.' + format.toLowerCase() : '';
 
-    const include = [
-        nodePath.resolve(ecDir, 'src/**/*.ts')
-    ];
+    const input = nodePath.resolve(ecDir, `index${srcType}.js`);
 
     return {
-        plugins: preparePlugins(opt, {
-            include
-        }),
+        plugins: [nodeResolvePlugin()],
         treeshake: {
             moduleSideEffects: false
         },
-        // external: ['zrender'],
-        // external: id => ['zrender'].includes(id),
 
         input: input,
-        // FIXME ??? ie8 support removed since rollup 0.60
-        // legacy: true, // Support IE8-
 
-        // onwarn ({loc, frame, message}) {
-        //     if (loc) {
-        //         console.warn(`${loc.file} (${loc.line}:${loc.column}) ${message}`);
-        //         if (frame) {
-        //             console.warn(frame);
-        //         }
-        //     }
-        //     else {
-        //         console.warn(message);
-        //     }
-        // },
-
-        output: {
-            name: 'echarts',
-            format: format,
-            sourcemap: sourcemap,
-            // legacy: true, // Must be declared both in inputOptions and outputOptions.
-            file: output
-        },
-        watch: {
-            include
-        }
+        output: createOutputs(
+            nodePath.resolve(ecDir, `dist/echarts${postfixFormat}${postfixType}`),
+            opt,
+            {
+                name: 'echarts',
+                // Ignore default exports, which is only for compitable code like:
+                // import echarts from 'echarts/lib/echarts';
+                exports: 'named',
+                format: format
+            }
+        )
     };
 };
 
-exports.createBMap = function () {
-    let input = nodePath.resolve(ecDir, `extension-src/bmap/bmap.ts`);
+exports.createBMap = function (opt) {
+    const input = nodePath.resolve(ecDir, `extension/bmap/bmap.js`);
 
     return {
-        plugins: preparePlugins({
-            // Always clean
-            clean: true
-        }, {
-            include: [
-                nodePath.resolve(ecDir, 'extension-src/bmap/**/*.ts')
-            ]
-        }),
+        plugins: [nodeResolvePlugin()],
         input: input,
-        legacy: true, // Support IE8-
         external: ['echarts'],
-        output: {
-            name: 'bmap',
-            format: 'umd',
-            sourcemap: true,
-            legacy: true, // Must be declared both in inputOptions and outputOptions.
-            globals: {
-                // For UMD `global.echarts`
-                echarts: 'echarts'
-            },
-            file: nodePath.resolve(ecDir, `dist/extension/bmap.js`)
-        },
-        watch: {
-            include: [nodePath.resolve(ecDir, 'extension-src/bmap/**')]
-        }
+        output: createOutputs(
+            nodePath.resolve(ecDir, `dist/extension/bmap`),
+            opt,
+            {
+                name: 'bmap',
+                globals: {
+                    // For UMD `global.echarts`
+                    echarts: 'echarts'
+                }
+            }
+        )
     };
 };
 
-exports.createDataTool = function () {
-    let input = nodePath.resolve(ecDir, `extension-src/dataTool/index.ts`);
+exports.createDataTool = function (opt) {
+    let input = nodePath.resolve(ecDir, `extension/dataTool/index.js`);
 
     return {
-        plugins: preparePlugins({
-            clean: true
-        }, {
-            include: [
-                nodePath.resolve(ecDir, 'extension-src/dataTool/**/*.ts')
-            ]
-        }),
+        plugins: [nodeResolvePlugin()],
         input: input,
-        legacy: true, // Support IE8-
         external: ['echarts'],
-        output: {
-            name: 'dataTool',
-            format: 'umd',
-            sourcemap: true,
-            legacy: true, // Must be declared both in inputOptions and outputOptions.
-            globals: {
-                // For UMD `global.echarts`
-                echarts: 'echarts'
-            },
-            file: nodePath.resolve(ecDir, `dist/extension/dataTool.js`)
-        },
-        watch: {
-            include: [nodePath.resolve(ecDir, 'extension-src/dataTool/**')]
-        }
+        output: createOutputs(
+            nodePath.resolve(ecDir, `dist/extension/dataTool`),
+            opt,
+            {
+                name: 'dataTool',
+                globals: {
+                    // For UMD `global.echarts`
+                    echarts: 'echarts'
+                }
+            }
+        )
     };
 };
 
-exports.createMyTransform = function () {
+exports.createMyTransform = function (opt) {
     let input = nodePath.resolve(ecDir, `test/lib/myTransform/src/index.ts`);
 
     return {
-        plugins: preparePlugins({
-            clean: true
-        }, {
-            include: [
-                nodePath.resolve(ecDir, 'test/lib/myTransform/src/**/*.ts'),
-                nodePath.resolve(ecDir, 'src/**/*.ts')
-            ]
-        }),
+        plugins: [nodeResolvePlugin()],
         input: input,
-        output: {
-            name: 'myTransform',
-            format: 'umd',
-            sourcemap: true,
-            file: nodePath.resolve(ecDir, `test/lib/myTransform/dist/myTransform.js`)
-        },
-        watch: {
-            include: [nodePath.resolve(ecDir, 'test/lib/myTransform/src/**')]
-        }
+        output: createOutputs(
+            nodePath.resolve(ecDir, `test/lib/myTransform/dist/myTransform`),
+            opt,
+            {
+                name: 'myTransform'
+            }
+        )
     };
 };
diff --git a/build/pre-publish.js b/build/pre-publish.js
index 8f58459..3243f1e 100644
--- a/build/pre-publish.js
+++ b/build/pre-publish.js
@@ -46,7 +46,6 @@ const tmpDir = nodePath.resolve(ecDir, 'pre-publish-tmp');
 const tsConfig = readTSConfig();
 
 const autoGeneratedFileAlert = `
-
 /**
  * AUTO-GENERATED FILE. DO NOT MODIFY.
  */
@@ -221,8 +220,8 @@ async function tsCompile(compilerOptionsOverride, srcPathList) {
 
     let compilerOptions = {
         ...tsConfig.compilerOptions,
-        ...compilerOptionsOverride,
-        sourceMap: false
+        ...compilerOptionsOverride
+        // sourceMap: true
     };
 
     runTsCompile(ts, compilerOptions, srcPathList);
diff --git a/build/progress.js b/build/progress.js
deleted file mode 100644
index 76a9890..0000000
--- a/build/progress.js
+++ /dev/null
@@ -1,62 +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.
-*/
-const chalk = require('chalk');
-const path = require('path');
-
-module.exports = function progress(options = {}) {
-    const scope = options.scope || {};
-    scope.finished = scope.finished || 0;
-    scope.total = scope.total || 0;
-
-    return {
-        name: 'progress',
-
-        buildStart() {
-            scope.finished = 0;
-            scope.total = 0;
-        },
-
-        load() {
-            // TODO More accurate total number
-            scope.total++;
-        },
-
-        transform(code, id) {
-            scope.finished++;
-            const filePath = path.relative(process.cwd(), id).split(path.sep).join('/');
-
-            const output = `[${scope.finished}/${scope.total}]: ${chalk.grey(filePath)}`;
-            if (process.stdout.isTTY) {
-                process.stdout.clearLine();
-                process.stdout.cursorTo(0);
-                process.stdout.write(output);
-            }
-            else {
-                console.log(output);
-            }
-        },
-
-        buildEnd() {
-            if (process.stdout.isTTY) {
-                process.stdout.clearLine();
-                process.stdout.cursorTo(0);
-            }
-        }
-    };
-};
diff --git a/build/release.js b/build/release.js
deleted file mode 100644
index 2a4e070..0000000
--- a/build/release.js
+++ /dev/null
@@ -1,81 +0,0 @@
-#!/usr/bin/env node
-
-/*
-* 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.
-*/
-
-const spawn = require('cross-spawn');
-const path = require('path');
-const chalk = require('chalk');
-const fsExtra = require('fs-extra');
-
-
-function release() {
-    fsExtra.removeSync(path.resolve(__dirname, '../dist'));
-
-    let idx = 0;
-
-    const logs = [];
-
-    function updateLog() {
-        if (process.stdout.isTTY) {
-            process.stdout.cursorTo(0, 0);
-            process.stdout.clearScreenDown();
-            for (let i = 0; i < logs.length; i++) {
-                process.stdout.write(logs[i] || '');
-            }
-        }
-    }
-
-    const argsList = ['', 'simple', 'common', 'extension'].map((type) => {
-        return [
-            '--type',
-            type,
-            '--clean',
-            '--sourcemap',
-            '--min'
-        ];
-    });
-
-    argsList.push([
-        '--type', '', '--clean', '--sourcemap', '--min', '--format', 'esm'
-    ])
-
-    argsList.forEach(function (args) {
-
-        const p = spawn(path.join(__dirname, 'build.js'), args);
-
-        let scope = `[${args[1] || 'all'}]`;
-        if (args[6]) {
-            scope += `[${args[6]}]`;
-        }
-
-        function createOnDataHandler(idx)  {
-            return function (data) {
-                logs[idx] = `${chalk.gray(scope)}: ${data}`;
-                updateLog();
-            }
-        }
-
-        p.stdout.on('data', createOnDataHandler(idx));
-
-        idx++;
-    });
-}
-
-release();
diff --git a/package.json b/package.json
index 69a1fb5..0a5536d 100644
--- a/package.json
+++ b/package.json
@@ -39,13 +39,14 @@
     "i18n/*.js"
   ],
   "scripts": {
-    "prepublish": "node build/build.js --prepublish",
-    "build": "node build/build.js",
+    "build": "node build/build.js --type all,common,simple --min",
+    "build:esm": "node build/build.js --type all --min --format esm",
     "build:i18n": "node build/build-i18n.js",
-    "build:full": "node build/build.js --clean",
-    "watch": "node build/build.js --watch",
+    "build:lib": "node build/build.js --prepublish",
     "dev:fast": "node build/build-i18n.js && node build/dev-fast.js",
-    "release": "node build/release.js",
+    "dev": "npm run dev:fast",
+    "prepublish": "npm run build:lib",
+    "release": "npm run build:lib && npm run build:i18n && npm run build && npm run build:esm",
     "help": "node build/build.js --help",
     "test:visual": "node test/runTest/server.js",
     "test:visual:report": "node test/runTest/genReport.js",
@@ -54,6 +55,7 @@
     "test:dts": "node build/testDts.js",
     "mktest": "node test/build/mktest.js",
     "mktest:help": "node test/build/mktest.js -h",
+    "checktype": "./node_modules/.bin/tsc --noEmit",
     "lint": "./node_modules/.bin/eslint src/**/*.ts extension-src/**/*.ts",
     "lint:fix": "./node_modules/.bin/eslint --fix src/**/*.ts extension-src/**/*.ts",
     "lint:dist": "echo 'It might take a while. Please wait ...' && ./node_modules/.bin/jshint --config .jshintrc-dist dist/echarts.js"
@@ -72,6 +74,7 @@
     "@microsoft/api-extractor": "7.7.2",
     "@rollup/plugin-commonjs": "^17.0.0",
     "@rollup/plugin-node-resolve": "^11.0.0",
+    "@rollup/plugin-replace": "^2.3.4",
     "@types/jest": "^26.0.14",
     "@typescript-eslint/eslint-plugin": "^4.9.1",
     "@typescript-eslint/parser": "^4.9.1",
@@ -94,7 +97,7 @@
     "pixelmatch": "5.0.2",
     "pngjs": "3.4.0",
     "rollup": "2.34.2",
-    "rollup-plugin-typescript2": "0.25.3",
+    "rollup-plugin-terser": "^7.0.2",
     "seedrandom": "3.0.3",
     "semver": "6.3.0",
     "serve-handler": "6.1.1",
@@ -102,7 +105,6 @@
     "socket.io": "2.2.0",
     "terser": "^5.3.8",
     "ts-jest": "^26.4.3",
-    "typescript": "^4.1.2",
-    "uglify-js": "^3.10.0"
+    "typescript": "^4.1.2"
   }
 }


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