Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IIFE/ Minified Rollup Bundler #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ bower_components
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
build

# Dependency directories
node_modules/
Expand Down
File renamed without changes.
38 changes: 38 additions & 0 deletions config/rollup.iife.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { nodeResolve } from "@rollup/plugin-node-resolve";
import commonJS from "@rollup/plugin-commonjs";
import babel from "@rollup/plugin-babel";
import nodePolyfills from "rollup-plugin-node-polyfills"
import { terser } from "rollup-plugin-terser"

const empty = "export default {}";

export default {
input: "main.js",
output: {
file: "build/circomlibjs.js",
format: "iife",
sourcemap: "inline",
name: "circomlibjs"
},
plugins: [
commonJS(),
nodePolyfills(),
babel({
exclude: "node_modules/**",
presets: ["@babel/preset-react"],
babelHelpers: "bundled"
}),
terser(),
nodeResolve({
browser: true,
exportConditions: ['browser', 'default', 'module', 'require']
})
],
onwarn: warning => {
if (
warning.code === 'THIS_IS_UNDEFINED'
|| warning.code === 'CIRCULAR_DEPENDENCY'
) { return; }
console.warn(warning.message);
}
};
10 changes: 10 additions & 0 deletions config/rollup.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import config from './rollup.iife.js';

export default {
...config,
output: {
...config.output,
file: "build/circomlibjs.min.js",
sourcemap: false,
}
};
17 changes: 14 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"scripts": {
"test": "mocha",
"poseidonOptimizeConstants": "node tools/poseidon_optimize_constants.js",
"build": "rollup -c rollup.cjs.config.js"
"build:cjs": "yarn rollup -c config/rollup.config.js",
"build:iife": "rollup -c config/rollup.iife.js",
"build:min": "rollup -c config/rollup.min.js"
},
"repository": {
"type": "git",
Expand All @@ -34,14 +36,23 @@
},
"homepage": "https://github.com/iden3/circomlibjs#readme",
"devDependencies": {
"@babel/core": "^7.17.7",
"@babel/preset-react": "^7.16.7",
"@rollup/plugin-babel": "^5.3.1",
"@rollup/plugin-commonjs": "^21.0.2",
"@rollup/plugin-node-resolve": "^13.1.3",
"chai": "^4.3.4",
"ganache-cli": "^6.12.2",
"mocha": "^9.1.3"
"mocha": "^9.1.3",
"rollup-plugin-node-polyfills": "^0.2.1",
"rollup-plugin-terser": "^7.0.2"
},
"dependencies": {
"blake-hash": "^2.0.0",
"blake2b": "^2.1.3",
"ethers": "^5.5.1",
"ffjavascript": "^0.2.45"
"ffjavascript": "^0.2.45",
"global": "^4.4.0",
"rollup": "^2.70.1"
}
}
Loading