Skip to content

Commit

Permalink
[skip ci] Issue #63 Add script npm run demo-rollup-esm-bundled
Browse files Browse the repository at this point in the history
  • Loading branch information
t2ym committed Mar 13, 2019
1 parent 86d2ea1 commit 2923b97
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 3 deletions.
66 changes: 66 additions & 0 deletions demo/clock/esm-bundled.rollup.config.js
@@ -0,0 +1,66 @@
import resolve from 'rollup-plugin-node-resolve';
import sizes from 'rollup-plugin-sizes';
import filesize from 'rollup-plugin-filesize';
import babel from 'rollup-plugin-babel';
import minifyPreset from 'babel-preset-minify';

export default {
input: 'demo/preprocess/clock.js',
output: {
file: 'build/esm-bundled/demo/preprocess/clock.js',
format: 'esm',
},
plugins: [
resolve({
modulesOnly: true,
}),
babel({
sourceMaps: false,
comments: false,
plugins: [
'@babel/plugin-syntax-object-rest-spread',
'@babel/plugin-syntax-async-generators',
'@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', {
'mappings': {
'node_modules': '../../node_modules'
},
'bundleDir': 'demo/preprocess',
'importStyle': 'esm',
} ],
],
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,

// 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,
}),
filesize({
showBrotliSize: true,
}),
]
}
66 changes: 66 additions & 0 deletions demo/preprocess/esm-bundled.rollup.config.js
@@ -0,0 +1,66 @@
import resolve from 'rollup-plugin-node-resolve';
import sizes from 'rollup-plugin-sizes';
import filesize from 'rollup-plugin-filesize';
import babel from 'rollup-plugin-babel';
import minifyPreset from 'babel-preset-minify';

export default {
input: 'demo/preprocess/clock.js',
output: {
file: 'build/esm-bundled/demo/preprocess/clock.js',
format: 'esm',
},
plugins: [
resolve({
modulesOnly: true,
}),
babel({
sourceMaps: false,
comments: false,
plugins: [
'@babel/plugin-syntax-object-rest-spread',
'@babel/plugin-syntax-async-generators',
'@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', {
'mappings': {
'node_modules': '../../node_modules'
},
'bundleDir': 'demo/preprocess',
'importStyle': 'esm',
} ],
],
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,

// 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,
}),
filesize({
showBrotliSize: true,
}),
]
}
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -33,6 +33,7 @@
},
"scripts": {
"demo": "cd demo && gulp",
"demo-rollup-esm-bundled": "rollup -c demo/preprocess/esm-bundled.rollup.config.js",
"size-polymer-build": "cd test && polymer build --root ..",
"size-rollup": "rollup -c",
"size-gulp": "gulp size",
Expand Down
4 changes: 2 additions & 2 deletions polymer.json
Expand Up @@ -17,7 +17,7 @@
{
"name": "esm-unbundled",
"browserCapabilities": [
"es2015",
"es2017",
"modules"
],
"js": {
Expand All @@ -35,7 +35,7 @@
{
"name": "esm-bundled",
"browserCapabilities": [
"es2015",
"es2017",
"modules"
],
"js": {
Expand Down
2 changes: 1 addition & 1 deletion test/polymer.json
Expand Up @@ -9,7 +9,7 @@
{
"name": "esm-bundled",
"browserCapabilities": [
"es2015",
"es2017",
"modules"
],
"js": {
Expand Down

0 comments on commit 2923b97

Please sign in to comment.