mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
remove duplicate code in build script
This commit is contained in:
parent
0b26e6f53a
commit
b8ce97e739
@ -203,7 +203,7 @@ async function buildJs(inputFile, outputName) {
|
|||||||
return bundlePath;
|
return bundlePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildJsLegacy(inputFile, outputName) {
|
async function buildJsLegacy(inputFile, outputName, polyfillFile = null) {
|
||||||
// compile down to whatever IE 11 needs
|
// compile down to whatever IE 11 needs
|
||||||
const babelPlugin = babel.babel({
|
const babelPlugin = babel.babel({
|
||||||
babelHelpers: 'bundled',
|
babelHelpers: 'bundled',
|
||||||
@ -219,9 +219,12 @@ async function buildJsLegacy(inputFile, outputName) {
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
if (!polyfillFile) {
|
||||||
|
polyfillFile = 'src/legacy-polyfill.js';
|
||||||
|
}
|
||||||
// create js bundle
|
// create js bundle
|
||||||
const rollupConfig = {
|
const rollupConfig = {
|
||||||
input: ['src/legacy-polyfill.js', inputFile],
|
input: [polyfillFile, inputFile],
|
||||||
plugins: [multi(), commonjs(), nodeResolve(), babelPlugin, removeJsComments({comments: "none"})]
|
plugins: [multi(), commonjs(), nodeResolve(), babelPlugin, removeJsComments({comments: "none"})]
|
||||||
};
|
};
|
||||||
const bundle = await rollup(rollupConfig);
|
const bundle = await rollup(rollupConfig);
|
||||||
@ -235,36 +238,9 @@ async function buildJsLegacy(inputFile, outputName) {
|
|||||||
return bundlePath;
|
return bundlePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildWorkerJsLegacy(inputFile, outputName) {
|
function buildWorkerJsLegacy(inputFile, outputName) {
|
||||||
// compile down to whatever IE 11 needs
|
const polyfillFile = 'src/worker-polyfill.js';
|
||||||
const babelPlugin = babel.babel({
|
return buildJsLegacy(inputFile, outputName, polyfillFile);
|
||||||
babelHelpers: 'bundled',
|
|
||||||
exclude: 'node_modules/**',
|
|
||||||
presets: [
|
|
||||||
[
|
|
||||||
"@babel/preset-env",
|
|
||||||
{
|
|
||||||
useBuiltIns: "entry",
|
|
||||||
corejs: "3",
|
|
||||||
targets: "IE 11"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
]
|
|
||||||
});
|
|
||||||
// create js bundle
|
|
||||||
const rollupConfig = {
|
|
||||||
input: ['src/worker-polyfill.js', inputFile],
|
|
||||||
plugins: [multi(), commonjs(), nodeResolve(), babelPlugin, removeJsComments({comments: "none"})]
|
|
||||||
};
|
|
||||||
const bundle = await rollup(rollupConfig);
|
|
||||||
const {output} = await bundle.generate({
|
|
||||||
format: 'iife',
|
|
||||||
name: `${PROJECT_ID}Bundle`
|
|
||||||
});
|
|
||||||
const code = output[0].code;
|
|
||||||
const bundlePath = resource(outputName, code);
|
|
||||||
await fs.writeFile(bundlePath, code, "utf8");
|
|
||||||
return bundlePath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildOffline(version, assetPaths) {
|
async function buildOffline(version, assetPaths) {
|
||||||
|
Loading…
Reference in New Issue
Block a user