Skip to content

Commit

Permalink
ES module browser fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Kolezhniuk committed Oct 13, 2023
1 parent e1fcd1e commit e74e466
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 38 deletions.
13 changes: 5 additions & 8 deletions config/rollup.browser.esm.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { nodeResolve } from "@rollup/plugin-node-resolve";
import commonJS from "@rollup/plugin-commonjs";
import virtual from "@rollup/plugin-virtual";
import replace from "@rollup/plugin-replace";
import visualizer from "rollup-plugin-visualizer";
// Needed by fastfile
import { O_TRUNC, O_CREAT, O_RDWR, O_EXCL, O_RDONLY } from "constants";

Expand All @@ -20,14 +19,14 @@ export default {
input: "main.js",
output: {
file: "build/esm.js",
format: "es"
format: "es",
},
external: ['ffjavascript'],
external: ["ffjavascript"],
plugins: [
replace({
// The current default is false, but they are changing it next version
preventAssignment: false,
"process.browser": true
"process.browser": true,
}),
virtual({
fs: empty,
Expand All @@ -43,13 +42,11 @@ export default {
nodeResolve({
browser: true,
preferBuiltins: false,
exportConditions: ["module"]
exportConditions: ["module"],
}),
commonJS(),
// terser(),
visualizer(),
],
treeshake: {
preset: "smallest",
}
},
};
43 changes: 15 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,22 @@
"files": [
"COPYING",
"README.md",
"config",
"build/",
"cli.js",
"main.js",
"src/",
"templates/"
],
"scripts": {
"prepare": "npm run build:browser:esm",
"test": "mocha",
"testv12": "mocha test/fflonk.test.js test/fullprocess.js test/keypar_test.js test/polynomial.test.js",
"build": "rollup -c config/rollup.cjs.config.js",
"buildcli": "rollup -c config/rollup.cli.config.js",
"buildiife": "BROWSER=true rollup -c config/rollup.iife.config.js",
"buildiifemin": "BROWSER=true rollup -c config/rollup.iife_min.config.js",
"build:esm": "BROWSER=true rollup -c config/rollup.browser.esm.config"
"build:browser:esm": "BROWSER=true rollup -c config/rollup.browser.esm.config"
},
"bin": {
"snarkjs": "build/cli.cjs"
Expand Down Expand Up @@ -61,7 +63,7 @@
"circom_runtime": "0.1.24",
"ejs": "^3.1.6",
"fastfile": "0.0.20",
"ffjavascript": "file:../ffjavascript",
"ffjavascript": "https://github.com/iden3/ffjavascript.git#chore/esm-patch",
"js-sha3": "^0.8.0",
"logplease": "^1.2.15",
"r1csfile": "0.0.47"
Expand Down

0 comments on commit e74e466

Please sign in to comment.