提交 7f53a787 编写于 作者: P pissang

Merge branch 'next' into label-enhancement

......@@ -2,6 +2,8 @@ const chokidar = require('chokidar');
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');
......@@ -23,9 +25,18 @@ const umdWrapperHead = `
const umdWrapperTail = `
}));`;
// attach properties to the exports object to define
// the exported module properties.
exports.action = function () {};
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');
}
function rebuild() {
build({
......@@ -33,20 +44,22 @@ function rebuild() {
entryPoints: [path.resolve(__dirname, '../echarts.all.ts')],
outfile: outFilePath,
format: 'cjs',
sourcemap: true,
bundle: true,
}).catch(e => {
console.error(e.toString());
}).then(() => {
const mainCode = fs.readFileSync(outFilePath, 'utf-8');
fs.writeFileSync(outFilePath, umdWrapperHead + mainCode + umdWrapperTail)
console.time('Wrap UMD');
wrapUMDCode();
console.timeEnd('Wrap UMD');
})
}
const debouncedRebuild = debounce(rebuild, 200);
chokidar.watch([
path.resolve(__dirname, '../src/**/*.ts'),
path.resolve(__dirname, '../node_modules/zrender/src/**/*.ts'),
], {
persistent: true
}).on('change', rebuild).on('ready', function () {
rebuild();
})
\ No newline at end of file
}).on('all', debouncedRebuild);
\ No newline at end of file
......@@ -70,6 +70,12 @@
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
"dev": true
},
"source-map": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=",
"dev": true
}
}
},
......@@ -96,6 +102,12 @@
"lodash": "^4.17.13",
"to-fast-properties": "^2.0.0"
}
},
"source-map": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=",
"dev": true
}
}
},
......@@ -5822,6 +5834,12 @@
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==",
"dev": true
},
"lodash.debounce": {
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz",
"integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168=",
"dev": true
},
"lodash.get": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
......@@ -7441,6 +7459,12 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
"dev": true
},
"source-map": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=",
"dev": true
}
}
},
......@@ -7603,9 +7627,9 @@
}
},
"source-map": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=",
"version": "0.7.3",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz",
"integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==",
"dev": true
},
"source-map-resolve": {
......
......@@ -57,6 +57,7 @@
"jest-canvas-mock": "^2.2.0",
"jsdom": "^15.2.1",
"jshint": "2.10.2",
"lodash.debounce": "^4.0.8",
"open": "6.4.0",
"pixelmatch": "5.0.2",
"pngjs": "3.4.0",
......@@ -70,6 +71,7 @@
"serve-handler": "6.1.1",
"slugify": "1.3.4",
"socket.io": "2.2.0",
"source-map": "^0.7.3",
"typescript": "^3.8.3"
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册