Skip to content

Commit

Permalink
support build of es modules (#570)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimniels authored May 9, 2022
1 parent d0c7891 commit 9cd9662
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
"build": "yarn lint && rollup -c && yarn test:build",
"build:ci": "rollup -c && yarn test:build",
"build:web": "yarn lint && rollup -c rollup.config.web.js && yarn test:build:web",
"build:esm": "yarn lint && rollup -c rollup.config.esm.js && yarn test:build:esm",
"build:esm:ci": "rollup -c rollup.config.esm.js && yarn test:build:esm",
"build:web:ci": "rollup -c rollup.config.web.js && yarn test:build:web",
"release": "yarn build && yarn build:web",
"build:generator": "rollup -c scripts/rollup.config.js",
Expand All @@ -44,6 +46,7 @@
"test:web": "node ./node_modules/karma/bin/karma start karma.conf.js --auto-watch",
"test:build": "cd ./scripts && jest check-build.test.js",
"test:build:web": "node ./scripts/proxy-browser-test.js",
"test:build:esm": "node ./scripts/proxy-browser-test.js",
"watch:test": "jest --watch",
"generate-parser": "node ./dist/generate-custom-parser.js"
},
Expand Down Expand Up @@ -104,6 +107,7 @@
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-node-globals": "^1.4.0",
"rollup-plugin-node-resolve": "^2.0.0",
"rollup-plugin-terser": "^6.1.0",
"rollup-plugin-uglify": "^6.0.1",
"watchify": "^3.11.1"
},
Expand Down
32 changes: 32 additions & 0 deletions rollup.config.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import nodeResolve from 'rollup-plugin-node-resolve';
import globals from 'rollup-plugin-node-globals';
import { terser } from 'rollup-plugin-terser'; // eslint-disable-line import/extensions
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';

export default {
input: 'src/mercury.js',
plugins: [
babel({
runtimeHelpers: true,
exclude: './node_modules#<{(|*',
}),
commonjs({
ignoreGlobal: true,
}),
globals(),
nodeResolve({
browser: true,
preferBuiltins: false,
}),
terser(),
],
treeshake: true,
output: {
file: process.env.MERCURY_TEST_BUILD
? 'dist/mercury_test.esm.js'
: 'dist/mercury.esm.js',
format: 'es',
sourceMap: true,
},
};

0 comments on commit 9cd9662

Please sign in to comment.