chore: update rollup patterns

This commit is contained in:
Blaine Bublitz 2021-02-09 21:42:05 -07:00
parent 4d1754ad7d
commit 1f85668137
4 changed files with 21 additions and 81 deletions

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

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

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

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