Add Babel to fix Node <14 compat
This commit is contained in:
12
cli/lib/autojson-plugin.js
Normal file
12
cli/lib/autojson-plugin.js
Normal file
@ -0,0 +1,12 @@
|
||||
import { promises as fsp } from 'fs';
|
||||
|
||||
export default function autojsonPlugin() {
|
||||
return {
|
||||
name: 'autojson-plugin',
|
||||
async load(id) {
|
||||
if (id.endsWith('.json') && !id.startsWith('json:')) {
|
||||
return 'export default ' + await fsp.readFile(id, 'utf8');
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
@ -4,7 +4,7 @@ const prefix = "json:";
|
||||
|
||||
const reservedKeys = ["public"];
|
||||
|
||||
export default function ejsAssetPlugin() {
|
||||
export default function jsonPlugin() {
|
||||
return {
|
||||
name: "json-plugin",
|
||||
async resolveId(id, importer) {
|
||||
|
1687
cli/package-lock.json
generated
1687
cli/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -17,6 +17,9 @@
|
||||
"web-streams-polyfill": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.11.6",
|
||||
"@babel/preset-env": "^7.11.5",
|
||||
"@rollup/plugin-babel": "^5.2.1",
|
||||
"@rollup/plugin-commonjs": "^15.0.0",
|
||||
"@rollup/plugin-node-resolve": "^9.0.0",
|
||||
"commander": "^6.0.0",
|
||||
|
@ -1,10 +1,13 @@
|
||||
import resolve from "@rollup/plugin-node-resolve";
|
||||
import cjs from "@rollup/plugin-commonjs";
|
||||
import { terser } from "rollup-plugin-terser";
|
||||
import asset from "./lib/asset-plugin.js";
|
||||
import json from "./lib/json-plugin.js";
|
||||
import autojson from "./lib/autojson-plugin.js";
|
||||
import { getBabelOutputPlugin } from '@rollup/plugin-babel';
|
||||
import { builtinModules } from 'module';
|
||||
|
||||
export default {
|
||||
/** @type {import('rollup').RollupOptions} */
|
||||
export default ({
|
||||
input: "src/index.js",
|
||||
output: {
|
||||
dir: "build",
|
||||
@ -18,19 +21,22 @@ export default {
|
||||
resolve(),
|
||||
cjs(),
|
||||
asset(),
|
||||
autojson(),
|
||||
json(),
|
||||
null &&
|
||||
terser({
|
||||
mangle: true
|
||||
})
|
||||
getBabelOutputPlugin({
|
||||
babelrc: false,
|
||||
configFile: false,
|
||||
minified: true,
|
||||
comments: false,
|
||||
presets: [
|
||||
['@babel/preset-env', {
|
||||
targets: {
|
||||
node: 12
|
||||
},
|
||||
loose: true
|
||||
}]
|
||||
]
|
||||
})
|
||||
],
|
||||
external: [
|
||||
"os",
|
||||
"path",
|
||||
"fs",
|
||||
"worker_threads",
|
||||
"events",
|
||||
"child_process",
|
||||
"crypto"
|
||||
]
|
||||
};
|
||||
external: builtinModules
|
||||
});
|
||||
|
Reference in New Issue
Block a user