Add Babel to fix Node <14 compat

This commit is contained in:
Jason Miller
2020-10-05 22:45:36 -04:00
parent 09f65d0cd7
commit 4487da9e9e
5 changed files with 1725 additions and 17 deletions

View 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');
}
}
};
};

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

@ -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",

View File

@ -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
});