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

build: Configure rollup for crypto package build #2853

Merged
merged 4 commits into from Aug 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/crypto/package.json
Expand Up @@ -16,10 +16,11 @@
],
"main": "dist/index",
"module": "dist/index",
"browser": "dist/index",
"browser": "dist/index-browser",
"types": "dist/index",
"scripts": {
"build": "yarn clean && tsc",
"build:rollup": "yarn clean && tsc && rollup -c",
"build:watch": "yarn clean && yarn compile -w",
"clean": "del dist",
"compile": "../../node_modules/typescript/bin/tsc",
Expand Down Expand Up @@ -60,7 +61,12 @@
"@types/node-forge": "^0.8.4",
"@types/otplib": "^7.0.0",
"@types/pluralize": "^0.0.29",
"@types/wif": "^2.0.1"
"@types/wif": "^2.0.1",
"rollup": "^1.17.0",
"rollup-plugin-terser": "^5.1.1",
"rollup-plugin-commonjs": "^10.0.1",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "^5.2.0"
},
"publishConfig": {
"access": "public"
Expand Down
47 changes: 47 additions & 0 deletions packages/crypto/rollup.config.js
@@ -0,0 +1,47 @@
import pkg from "./package.json";
import { terser } from "rollup-plugin-terser";
import commonjs from "rollup-plugin-commonjs";
import nodeResolve from "rollup-plugin-node-resolve";
import json from "rollup-plugin-json";

export default {
input: "dist/index.js", // our source file
output: [
{
file: pkg.main,
format: "cjs"
},
{
file: pkg.module,
format: "es" // the preferred format
},
{
file: pkg.browser,
format: "iife",
name: "ArkCrypto" // the global which can be used in a browser
}
],
external: [
...Object.keys(pkg.dependencies || {})
],
plugins: [
json({
// for tree-shaking, properties will be declared as
// variables, using either `var` or `const`
preferConst: true, // Default: false

// ignores indent and generates the smallest code
compact: true, // Default: false
}),
nodeResolve({
jsnext: true,
main: true
}),
commonjs({
namedExports: {
"dist/index.js": ["__moduleExports"]
}
}),
terser() // minifies generated bundles
]
};