mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-13 01:07:18 +00:00
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"];
|
const reservedKeys = ["public"];
|
||||||
|
|
||||||
export default function ejsAssetPlugin() {
|
export default function jsonPlugin() {
|
||||||
return {
|
return {
|
||||||
name: "json-plugin",
|
name: "json-plugin",
|
||||||
async resolveId(id, importer) {
|
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"
|
"web-streams-polyfill": "^3.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"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-commonjs": "^15.0.0",
|
||||||
"@rollup/plugin-node-resolve": "^9.0.0",
|
"@rollup/plugin-node-resolve": "^9.0.0",
|
||||||
"commander": "^6.0.0",
|
"commander": "^6.0.0",
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
import resolve from "@rollup/plugin-node-resolve";
|
import resolve from "@rollup/plugin-node-resolve";
|
||||||
import cjs from "@rollup/plugin-commonjs";
|
import cjs from "@rollup/plugin-commonjs";
|
||||||
import { terser } from "rollup-plugin-terser";
|
|
||||||
import asset from "./lib/asset-plugin.js";
|
import asset from "./lib/asset-plugin.js";
|
||||||
import json from "./lib/json-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",
|
input: "src/index.js",
|
||||||
output: {
|
output: {
|
||||||
dir: "build",
|
dir: "build",
|
||||||
@@ -18,19 +21,22 @@ export default {
|
|||||||
resolve(),
|
resolve(),
|
||||||
cjs(),
|
cjs(),
|
||||||
asset(),
|
asset(),
|
||||||
|
autojson(),
|
||||||
json(),
|
json(),
|
||||||
null &&
|
getBabelOutputPlugin({
|
||||||
terser({
|
babelrc: false,
|
||||||
mangle: true
|
configFile: false,
|
||||||
})
|
minified: true,
|
||||||
|
comments: false,
|
||||||
|
presets: [
|
||||||
|
['@babel/preset-env', {
|
||||||
|
targets: {
|
||||||
|
node: 12
|
||||||
|
},
|
||||||
|
loose: true
|
||||||
|
}]
|
||||||
|
]
|
||||||
|
})
|
||||||
],
|
],
|
||||||
external: [
|
external: builtinModules
|
||||||
"os",
|
});
|
||||||
"path",
|
|
||||||
"fs",
|
|
||||||
"worker_threads",
|
|
||||||
"events",
|
|
||||||
"child_process",
|
|
||||||
"crypto"
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|||||||
Reference in New Issue
Block a user