Merge pull request #84 from phated/rollup-cleanup

chore: update rollup patterns
This commit is contained in:
Jordi Baylina 2021-02-10 09:48:50 +01:00 committed by GitHub
commit 9a71b7d756
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 81 deletions

View File

@ -1,5 +1,7 @@
import { nodeResolve } from "@rollup/plugin-node-resolve"; import fs from "fs";
import commonJS from "@rollup/plugin-commonjs"; import { builtinModules as builtin } from "module";
const pkg = JSON.parse(fs.readFileSync("./package.json"));
export default { export default {
input: "main.js", input: "main.js",
@ -8,26 +10,7 @@ export default {
format: "cjs", format: "cjs",
}, },
external: [ external: [
"fs", ...Object.keys(pkg.dependencies),
"os", ...builtin,
"worker_threads",
"readline",
"crypto",
"path",
"big-integer",
"wasmsnark",
"circom_runtime",
"blake2b-wasm",
"ffjavascript",
"keccak",
"yargs",
"logplease"
],
plugins: [
nodeResolve({ preferBuiltins: true }),
commonJS({
preserveSymlinks: true
}),
] ]
}; };

View File

@ -1,6 +1,7 @@
import { nodeResolve } from "@rollup/plugin-node-resolve"; import fs from "fs";
import commonJS from "@rollup/plugin-commonjs"; import { builtinModules as builtin } from "module";
import json from '@rollup/plugin-json';
const pkg = JSON.parse(fs.readFileSync("./package.json"));
export default { export default {
input: "cli.js", input: "cli.js",
@ -10,31 +11,7 @@ export default {
banner: "#! /usr/bin/env node\n", banner: "#! /usr/bin/env node\n",
}, },
external: [ external: [
"fs", ...Object.keys(pkg.dependencies),
"os", ...builtin,
"worker_threads",
"readline",
"crypto",
"path",
"big-integer",
"wasmsnark",
"circom_runtime",
"blake2b-wasm",
"ffjavascript",
"keccak",
"yargs",
"logplease",
],
plugins: [
nodeResolve({
preferBuiltins: true,
}),
commonJS({
preserveSymlinks: true,
include: "node_modules/**",
exclude: "node_modules/big-integer/**"
}),
json()
] ]
}; };

View File

@ -23,10 +23,11 @@ export default {
os: empty, os: empty,
crypto: empty, crypto: empty,
readline: empty, readline: empty,
worker_threads: empty,
}), }),
nodeResolve({ nodeResolve({
browser: true browser: true,
preferBuiltins: false,
exportConditions: ['browser', 'default', 'module', 'require']
}), }),
commonJS(), commonJS(),
replace({ replace({

View File

@ -1,36 +1,15 @@
import { nodeResolve } from "@rollup/plugin-node-resolve"; import config from './rollup.iife.config';
import commonJS from "@rollup/plugin-commonjs";
import virtual from '@rollup/plugin-virtual';
import replace from '@rollup/plugin-replace';
import { terser } from "rollup-plugin-terser"; import { terser } from "rollup-plugin-terser";
const empty = 'export default {}';
export default { export default {
input: "main.js", ...config,
output: { output: {
...config.output,
file: "build/snarkjs.min.js", file: "build/snarkjs.min.js",
format: "iife", sourcemap: false,
globals: {
os: "null"
},
name: "snarkjs"
}, },
plugins: [ plugins: [
virtual({ ...config.plugins,
fs: empty, terser(),
os: empty,
crypto: empty,
readline: empty,
worker_threads: empty,
}),
nodeResolve({
browser: true
}),
commonJS(),
replace({
"process.browser": !!process.env.BROWSER
}),
terser()
] ]
}; };