Skip to content

Commit

Permalink
feat: Make UMD build be compatible with IE11
Browse files Browse the repository at this point in the history
Fixes #79
  • Loading branch information
huy-nguyen committed Feb 7, 2019
1 parent e52f075 commit 2780b22
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"clean": "npm run clean:lib && npm run clean:es && npm run clean:dist",
"build:lib": "npm run clean:lib && rollup -c -o lib/index.js -f cjs --environment declaration",
"build:es": "npm run clean:es && rollup -c -o es/index.js -f es",
"build:dist": "npm run clean:dist && rollup -c -o dist/index.js -f umd --name squarify --environment minify",
"build:dist": "npm run clean:dist && rollup -c -o dist/index.js -f umd --name squarify --environment minify --environment es5",
"build": "npm run clean && npm run typecheck && npm run build:lib && npm run build:dist && npm run build:es && npm run generate:typedef",
"tslint": "tslint --project tsconfig.json --config tslint.json",
"tslint:fix": "tslint --project tsconfig.json --config tslint.json --fix",
Expand Down
29 changes: 25 additions & 4 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,33 @@ import resolve from 'rollup-plugin-node-resolve';

const shouldMinify = !!process.env.minify;


const commonBabelPluginOptions = {
exclude: 'node_modules/**',
extensions: ['.ts'],
};
let babelPlugin;
if (process.env.es5) {
// Make UMD build (`dist`) be compatible with IE 11.
babelPlugin = babel({
...commonBabelPluginOptions,
babelrc: false,
presets: [
['@babel/preset-env', {
'targets': 'ie 11',
},
],
'@babel/preset-typescript',
],
});
} else {
// Otherwise,
babelPlugin = babel(commonBabelPluginOptions);
}

let plugins = [
resolve(),
babel({
exclude: 'node_modules/**',
extensions: ['.ts'],
}),
babelPlugin,
];

if (shouldMinify) {
Expand Down

0 comments on commit 2780b22

Please sign in to comment.