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/07/27 09:01:08 UTC

[incubator-echarts] branch next updated: chore(devfast): fix umd may be wrapped multiple times bug.

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

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


The following commit(s) were added to refs/heads/next by this push:
     new 236e0eb  chore(devfast): fix umd may be wrapped multiple times bug.
236e0eb is described below

commit 236e0eb762c1954e7c89e3d13d2c9ed90015c466
Author: pissang <bm...@gmail.com>
AuthorDate: Mon Jul 27 17:00:55 2020 +0800

    chore(devfast): fix umd may be wrapped multiple times bug.
---
 build/dev-fast.js | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/build/dev-fast.js b/build/dev-fast.js
index d11b5f5..7438fdd 100644
--- a/build/dev-fast.js
+++ b/build/dev-fast.js
@@ -3,11 +3,12 @@ const path = require('path');
 const {build} = require('esbuild');
 const fs = require('fs');
 const debounce = require('lodash.debounce');
-// const sourceMap = require('source-map');
 
 const outFilePath = path.resolve(__dirname, '../dist/echarts.js');
 
+const umdMark = '// ------------- WRAPPED UMD --------------- //';
 const umdWrapperHead = `
+${umdMark}
 (function (root, factory) {
     if (typeof define === 'function' && define.amd) {
         // AMD. Register as an anonymous module.
@@ -26,18 +27,11 @@ const umdWrapperTail = `
 }));`;
 
 async function wrapUMDCode() {
-    // const consumer = await new sourceMap.SourceMapConsumer(fs.readFileSync(outFilePath + '.map', 'utf8'));
-    // const node = sourceMap.SourceNode.fromStringWithSourceMap(fs.readFileSync(outFilePath, 'utf-8'), consumer);
-    // // add six empty lines
-    // node.prepend(umdWrapperHead);
-    // node.add(umdWrapperTail);
-    // const res = node.toStringWithSourceMap({
-    //     file: outFilePath
-    // });
-    // fs.writeFileSync(outFilePath, res.code, 'utf-8');
-    // fs.writeFileSync(outFilePath + '.map', res.map.toString(), 'utf-8');
-
     const code = fs.readFileSync(outFilePath, 'utf-8');
+    if (code.indexOf(umdMark) >= 0) {
+        return;
+    }
+
     fs.writeFileSync(outFilePath, umdWrapperHead + code + umdWrapperTail, 'utf-8');
 
     const sourceMap = JSON.parse(fs.readFileSync(outFilePath + '.map', 'utf-8'));


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