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 esm module support #226

Merged
merged 2 commits into from
Aug 14, 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
9 changes: 9 additions & 0 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@
"rollup-plugin-commonjs": "^10.0.1",
"rollup-plugin-eslint": "^7.0.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-polyfill": "^3.0.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-terser": "^5.1.1",
"sinon": "^7.3.2"
},
"engines": {
"npm": ">=4.0.0",
"node": ">=6.0.0"
"node": ">=8.0.0"
},
"scripts": {
"postinstall": "lerna bootstrap --hoist --nohoist=core-js --no-ci",
Expand Down
1 change: 0 additions & 1 deletion packages/imask/.babelrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const presetOptions = {
modules: false,
useBuiltIns: 'entry',
corejs: '3',
};
Expand Down
12 changes: 5 additions & 7 deletions packages/imask/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"homepage": "https://imask.js.org/",
"description": "vanilla javascript input mask",
"main": "dist/imask.js",
"module": "dist/imask.esm.js",
"repository": "https://github.com/uNmAnNeR/imaskjs",
"types": "index.d.ts",
"engines": {
Expand All @@ -16,13 +17,10 @@
"test": "cross-env NODE_ENV=test nyc mocha --exit --recursive",
"pretest": "flow check",
"watch": "rollup -c -w",
"build": "npm run build:dev && npm run build:prod",
"build:dev": "npm run build:dev:es && npm run build:dev:umd",
"build:prod": "npm run build:prod:es && npm run build:prod:umd",
"build:dev:es": "cross-env BABEL_ENV=es rollup -c",
"build:dev:umd": "rollup -c",
"build:prod:es": "cross-env NODE_ENV=production BABEL_ENV=es rollup -c",
"build:prod:umd": "cross-env NODE_ENV=production rollup -c",
"build": "npm run build:umd && npm run build:es && npm run build:esm",
"build:umd": "rollup -c",
"build:es": "cross-env BABEL_ENV=es rollup -c",
"build:esm": "cross-env BABEL_ENV=esm rollup -c",
"flow": "flow",
"coveralls": "nyc report --reporter=text-lcov | coveralls"
},
Expand Down
24 changes: 10 additions & 14 deletions packages/imask/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,19 @@ import { terser } from 'rollup-plugin-terser';
import { eslint } from 'rollup-plugin-eslint';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import polyfill from 'rollup-plugin-polyfill';


const isProd = process.env.NODE_ENV === 'production';
const format = process.env.BABEL_ENV || 'umd';

const isES = format === 'es';
const file = 'dist/imask' +
(format !== 'umd' ? '.' + format : '') +
(isProd ? '.min' : '') +
'.js';
const isES = format.indexOf('es') === 0;
const basePath = 'dist/imask' + (format !== 'umd' ? '.' + format : '');

const input = isES ? 'src/imask.js' : 'src/imask.shim.js';


export default {
input,
export default [false, true].map(min => ({
input: 'src/imask.js',
output: {
file,
file: `${basePath}${min ? '.min' : ''}.js`,
format,
name: 'IMask',
sourcemap: true,
Expand All @@ -30,6 +25,7 @@ export default {
resolve(),
babel(),
!isES && commonjs(),
isProd && terser()
]
}
!isES && polyfill(['./polyfills.js']),
min && terser(),
],
}));
3 changes: 0 additions & 3 deletions packages/imask/src/imask.shim.js

This file was deleted.