Closed t2ym closed 5 years ago
npm run size
with bundled-import-meta
i18n.js → test/build/i18n.bundled-not-usable-as-it-is.js...
i18n.js:
i18n-behavior - 105.34 KB (40.54%)
i18n-controller.js - 82.14 KB (77.98%)
i18n-attr-repo.js - 15.87 KB (15.07%)
i18n-preference.js - 7.33 KB (6.95%)
lit-html - 43.51 KB (16.75%)
lib/parts.js - 14.84 KB (34.10%)
lib/template.js - 9.24 KB (21.23%)
lib/template-instance.js - 4.07 KB (9.35%)
lib/template-result.js - 3.42 KB (7.86%)
lit-html.js - 2.52 KB (5.79%)
lib/default-template-processor.js - 2.01 KB (4.61%)
lib/template-factory.js - 1.9 KB (4.37%)
lib/render.js - 1.78 KB (4.08%)
lib/dom.js - 1.56 KB (3.58%)
lib/directive.js - 1.37 KB (3.16%)
lib/part.js - 834 B (1.87%)
make-plural - 32.86 KB (12.65%)
es6/plurals.js - 32.86 KB (100.00%)
app - 25.29 KB (9.73%)
i18n.js - 25.29 KB (100.00%)
i18n-format - 22.29 KB (8.58%)
i18n-format.js - 22.29 KB (100.00%)
i18n-number - 10.98 KB (4.23%)
i18n-number.js - 10.98 KB (100.00%)
wc-putty - 10.11 KB (3.89%)
polyfill.js - 10.11 KB (100.00%)
deepcopy - 9.43 KB (3.63%)
dist/deepcopy.js - 9.43 KB (100.00%)
┌─────────────────────────────────────────────────────────────────┐
│ │
│ Destination: test/build/i18n.bundled-not-usable-as-it-is.js │
│ Bundle Size: 107.7 KB │
│ Minified Size: 82.53 KB │
│ Gzipped Size: 18.56 KB │
│ Brotli size: 18.98 KB │
│ │
└─────────────────────────────────────────────────────────────────┘
(!) rollup-plugin-sizes plugin: The ongenerate hook used by plugin rollup-plugin-sizes is deprecated. The generateBundle hook should be used instead.
created test/build/i18n.bundled-not-usable-as-it-is.js in 3.3s
> gulp size
[22:34:54] Using gulpfile ~/WebComponents/components/i18n-element/gulpfile.js
[22:34:54] Starting 'size'...
[22:34:54] gulp-debug: test/build/i18n.js
[22:34:54] gulp-debug: 1 item
[22:34:54] all files 115.25 kB
[22:34:54] gulp-debug: test/build/i18n.js.gz
[22:34:54] gulp-debug: 1 item
[22:34:54] all files 23.32 kB
[22:34:54] Finished 'size' after 35 ms
rollup.config.js
for bundled-import-meta
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: 'i18n.js',
output: {
file: 'test/build/i18n.bundled-not-usable-as-it-is.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': '.',
'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,
}),
]
}
rollup.config.js
for demo/preprocess/clock.js
build/esm-bundled/demo/preprocess/clock.js
polymer build # set up build/esm-bundled/...
rollup -c # deploy build/esm-bundled/demo/preprocess/clock.js
cd build/esm-bundled
python -m SimpleHTTPServer 8081 # http://localhost:8081/demo/preprocess/
// On DevTools Console
customElements.get('world-clock').importMeta
{ url: 'http://localhost:8081/demo/preprocess/clock.js' }
customElements.get('i18n-format').importMeta
{ url: 'http://localhost:8081/node_modules/i18n-format/i18n-format.js' }
rollup.config.js
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,
}),
]
}
i18n-core.js
part of log from npm run sizei18n-core.js → test/build/i18n-core.bundled-not-usable-as-it-is.js...
i18n-core.js:
i18n-behavior - 60.73 KB (29.08%)
i18n-controller-core.js - 37.53 KB (61.80%)
i18n-attr-repo.js - 15.87 KB (26.14%)
i18n-preference.js - 7.33 KB (12.06%)
lit-html - 43.51 KB (20.83%)
lib/parts.js - 14.84 KB (34.10%)
lib/template.js - 9.24 KB (21.23%)
lib/template-instance.js - 4.07 KB (9.35%)
lib/template-result.js - 3.42 KB (7.86%)
lit-html.js - 2.52 KB (5.79%)
lib/default-template-processor.js - 2.01 KB (4.61%)
lib/template-factory.js - 1.9 KB (4.37%)
lib/render.js - 1.78 KB (4.08%)
lib/dom.js - 1.56 KB (3.58%)
lib/directive.js - 1.37 KB (3.16%)
lib/part.js - 834 B (1.87%)
make-plural - 32.86 KB (15.73%)
es6/plurals.js - 32.86 KB (100.00%)
i18n-format - 22.29 KB (10.67%)
i18n-format.js - 22.29 KB (100.00%)
app - 18.95 KB (9.07%)
i18n-core.js - 18.95 KB (100.00%)
i18n-number - 10.98 KB (5.26%)
i18n-number.js - 10.98 KB (100.00%)
wc-putty - 10.11 KB (4.84%)
polyfill.js - 10.11 KB (100.00%)
deepcopy - 9.43 KB (4.52%)
dist/deepcopy.js - 9.43 KB (100.00%)
[4.0] Remove dependency on Polymer library
Links to BundlePhobia
i18n-element@4.0.0
fori18n.js
i18n-element@4.0.0-core
fori18n-core.js
Gzipped Bundled
i18n-core.js
- 15.26 kB includinglit-html
polymer-build
minify: true
polymer-build
minify: true
rollup
babel-preset-minify
rollup
babel-preset-minify
i18n-core.js
is only for preprocessed sourcesi18n-behavior/i18n-controller-core.js
, which omits the preprocessor codedemo/gulpfile.js
withconst useI18nCoreJs = true
can convert imports toi18n-core.js
"i18n-element"
->"i18n-element/i18n-core.js"
"i18n-element/i18n.js"
->"i18n-element/i18n-core.js"
"/node_modules/i18n-element/i18n.js"
->"/node_modules/i18n-element/i18n-core.js"
Gzipped Bundled
i18n.js
- 18.82 kB includinglit-html
polymer-build
minify: true
polymer-build
minify: true
rollup
babel-preset-minify
rollup
babel-preset-minify
rollup
rollup-plugin-babel-minify
106.43 kBrollup
rollup-plugin-terser
82.44 kBwebpack
babel-minify-webpack-plugin
webpack
babel-minify-webpack-plugin
webpack.config.js
is just a trial and may not be optimaldemo/preprocess/webpack.config.js
seems to work but not tested well./node_modules/node-libs-browser/node_modules/buffer/index.js
47.7 KiB(webpack)/buildin/global.js
475 bytes./node_modules/base64-js/index.js
3.41 KiB./node_modules/ieee754/index.js
2.03 KiB./node_modules/node-libs-browser/node_modules/isarray/index.js
131 bytes@open-wc/webpack-import-meta-loader
is appliedstatic get is()
getters are explicitly declared to survive UglifyJS mangling for class names@vaadin/*
elements, which depend on Polymer library, but the webpack configurations should be compatible even after they are removed from the approllup-plugin-babel
can be configured with a presetbabel-preset-minify
bundled-import-meta
babel plugin can be configured withrollup-plugin-babel
to convertimport.meta
meta properties to maintain their original values on bundlingrollup.config.js
withbundled-import-meta
is attached to this GitHub issuerollup-plugin-babel-minify
minified version has limitationslocales/
paths (not forbundle.*.json
) cannot be found sinceimport.meta
meta-properties for the elements are left as they are in the bundlepolymer-build
,import.meta
for each element is crafted to maintain the original intended value for the element so thatimportMeta()
method can return the same expected value as that for the unbundled original versioni18n.js
withrollup-plugin-babel-minify
whose options followingpolymer-build
itself is intact as it does not contain anyimport.meta
forlocales/
pathsrollup.config.js
with the options is attached to this GitHub issuerollup-plugin-terser
fori18n.js
demo/preprocess/clock.js
, unexpected fetching ofhtml-element.ja.json
is observed, which indicates critical mal-minification byrollup-plugin-terser
rollup-plugin-terser
usesterser
as a mangling engine, terser-mangled code should not have the issue with babel shown belowrollup
is internally used inpolymer build
with calibrated options for Polymer 3Polymer/tools/issues/261
[build] Name mangling mismangles names when emitting ES6, which can be tracked tobabel/minify/issues#943
For loops declaration sometimes shadows loop condition variablesBundled Modules and Packages
Dependencies
Notes
i18n-element 4.x
, the elements themselves must have@polymer/polymer
as their NPM dependencies sincei18n-element@4.x
andi18n-behavior@4.x
do NOT have@polymer/polymer
as their own NPM package dependencies.i18n-element@4.x
but have no dependencies on@polymer/polymer
, the missing explicit NPM package dependencies on@polymer/polymer
ini18n-element@4.x
andi18n-behavior@4.x
NPM packages should not become issues.Status
npm install i18n-element@next
ornpm install i18n-element@4.0.0-pre.17
i18n.js
is independent of Polymer libraryi18n-core.js
for preprocessed sourcesi18n-behavior@4.0.0-pre.19
i18n-behavior/i18n-controller-core.js
omits the preprocessor codei18n-format@4.0.0-pre.13
andi18n-number@4.0.0-pre.6
render withlit-html
Tasks
i18n-number
lit-html
instead of Polymer librarywc-putty
fori18n-element/polyfill.js
, which will be shared amongi18n-number
,i18n-format
, andi18n-element
wc-putty
i18n-format
lit-html
instead of Polymer libraryi18n-behavior
<i18n-attr-repo>
to a vanilla web component<i18n-preference>
to a vanilla web component<iron-ajax>
fromI18nBehavior
I18nBehavior
interface compatible with 3.xpolyfill.js
and usewc-putty/polyfill.js
mixin
,base-element
,legacy
syntax tests passthin
syntax tests failurei18n-format@4.0.0-pre.10
, which puts off assignment of DEFAULT_LANG untilconnectedCallback()
lit-html
i18n-behavior@4.0.0-pre.3
- still dependent on Polymer library3.0.0 with dependency on Polymer Library
i18n.js
≈ 67.9KB4.0.0 plan # 1 with no production dependency on Polymer Library
i18n.js
≈ 23.5KBRoughly Estimated Tasks on Plan # 1
i18n-number
renders withlit-html
, but has the same interfaces as 3.0.0i18n-format
renders withlit-html
, but has the same interfaces as 3.0.0i18n-attr-repo
is a vanilla web component, but has the same interfaces as 3.0.0i18n-preference
is a vanilla web component, but has the same interfaces as 3.0.0, usinglocalStorage
API directlyi18n-controller.js
is introduced for non-Polymer part ofi18n-behavior.js
, usingXHR
(orfetch
with the help ofwhatwg-fetch
on IE 11) directlyi18n-behavior.js
contains only Polymer dependent part, depending oni18n-controller.js
, but providing the same interfaces as 3.0.0i18n-element.js
andi18n-behavior.js
are still supported ifpolymer
is loadedpolymer
is adevDependency
ofi18n-element
andi18n-behavior
npm packagesi18n-element.js
depend onpolymer
andi18n-element
andi18n-behaviro
themselves do not have to depend onpolymer
as npm packageslive-localizer
is still a Polymer element, but is required only in development phases and not required in productionLitElement
has to be supported as wellDesign Issues on Plan # 1
i18n-number
,i18n-format
,i18n-attr-repo
,i18n-preference
: Property/attribute management should be easier withLitElement
LitElement
footprint overheads?i18n-number
,i18n-format
can be implemented as vanilla web components but rendering with ShadyDOM may be more compatible and easier withlit-html
intl
dependency can be dropped ifSafari 9
support is droppedlit-html
other thanLitElement
be officially supported?fetch
API be used instead ofXHR
?fetch
API can be polyfilled bywhatwg-fetch
on IE 11