Skip to content

Commit

Permalink
[skip ci] Issue #63 Update rollup.config.js for npm run size to suppo…
Browse files Browse the repository at this point in the history
…rt import.meta in bundled modules
  • Loading branch information
t2ym committed Mar 10, 2019
1 parent 317b0c8 commit 0d4d855
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 27 deletions.
36 changes: 36 additions & 0 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -55,6 +55,7 @@
"@polymer/paper-styles": "^3.0.0",
"@polymer/polymer": "^3.1.0",
"@polymer/test-fixture": "^4.0.0",
"babel-plugin-bundled-import-meta": "^0.3.0",
"babel-plugin-transform-es2015-classes": "^6.14.0",
"babel-preset-es2015": "^6.16.0",
"coveralls": "^2.11.8",
Expand Down Expand Up @@ -88,6 +89,7 @@
"merge-stream": "^1.0.0",
"npm-run-all": "^4.1.5",
"rollup": "^1.6.0",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-babel-minify": "^8.0.0",
"rollup-plugin-filesize": "^6.0.1",
"rollup-plugin-node-resolve": "^4.0.1",
Expand Down
58 changes: 31 additions & 27 deletions rollup.config.js
@@ -1,7 +1,8 @@
import resolve from 'rollup-plugin-node-resolve';
import sizes from 'rollup-plugin-sizes';
import filesize from 'rollup-plugin-filesize';
import minify from 'rollup-plugin-babel-minify';
import babel from 'rollup-plugin-babel';
import minifyPreset from 'babel-preset-minify';

export default {
input: 'i18n.js',
Expand All @@ -13,38 +14,41 @@ export default {
resolve({
modulesOnly: true,
}),
minify({
// Options from polymer-build/src/js-transform.ts
// Disable the minify-constant-folding plugin because it has a bug relating
// to invalid substitution of constant values into export specifiers:
// https://github.com/babel/minify/issues/820
evaluate: false,

// TODO(aomarks) Find out why we disabled this plugin.
simplifyComparisons: false,

// Prevent removal of things that babel thinks are unreachable, but sometimes
// gets wrong: https://github.com/Polymer/tools/issues/724
deadcode: false,

// Disable the simplify plugin because it can eat some statements preceeding
// loops. https://github.com/babel/minify/issues/824
simplify: false,

// This is breaking ES6 output. https://github.com/Polymer/tools/issues/261
mangle: false,

babel({
sourceMaps: false,
comments: false,
plugins: [
'@babel/plugin-syntax-object-rest-spread',
'@babel/plugin-syntax-async-generators',
//'@babel/plugin-syntax-dynamic-import', // enabled by default
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-syntax-import-meta',
// rollup rewrites import.meta.url, but makes them point to the file location after bundling
// we want the location before bundling
'bundled-import-meta',
],
presets: [
minifyPreset({}, {
// Options from polymer-build/src/js-transform.ts
// Disable the minify-constant-folding plugin because it has a bug relating
// to invalid substitution of constant values into export specifiers:
// https://github.com/babel/minify/issues/820
evaluate: false,

comments: false, // indicates if comments should be preserved in source;
banner: undefined, // the comment which should be prepended to the transformed bundle;
bannerNewLine: false, // indicates if the banner comment should be followed by a new line;
sourceMap: false, // indicates if sourcemap should be generated;
// TODO(aomarks) Find out why we disabled this plugin.
simplifyComparisons: false,

// Prevent removal of things that babel thinks are unreachable, but sometimes
// gets wrong: https://github.com/Polymer/tools/issues/724
deadcode: false,

// Disable the simplify plugin because it can eat some statements preceeding
// loops. https://github.com/babel/minify/issues/824
simplify: false,

// This is breaking ES6 output. https://github.com/Polymer/tools/issues/261
mangle: false,
}),
],
}),
sizes({
details: true,
Expand Down

0 comments on commit 0d4d855

Please sign in to comment.