-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#2329 Moved from polymer-based tree shaking to rollup-based.
This allows greater capabilities for importing libraries (like antlr4). polymer-cli is quite old and limited in that regard. Rollup also has a potential to import raw string from css files, which would hopefully also simplify libraries maintenance. Many regenerated files are more close to npm-versions. That is not bad, because stripping of unnecessary braces or some other simplification of code is still done using terser during vulcanisation. Also, rollup seems to be more strict during tree shaking (tree shakes more). However, exactly the same count of files returned (besides antlr4). Some files lost some (actually used) functions, but they were returned in subsequent tree regeneration commits. * Antlr library file are now tree-shaken through lib/antlr-lib.js file, which generates polymer/lib/antlr-lib.js (install-polymer.sh). The generated file is used for TG components. * Added some missing imports to tree shaker: dom-bind, dom-module, dom-repeat. They were not a problem because of transitive usage, but better to be included. * Added missing ';'.
- Loading branch information
Showing
6 changed files
with
60 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
rm -f package-lock.json | ||
npm install | ||
rm -f node_modules/stacky | ||
polymer build | ||
cp -r lib node_modules/ | ||
rollup --config | ||
rm -r -f polymer | ||
mv node_modules polymer | ||
rm -r -f polymer/@google-web-components | ||
rm -r -f polymer/@polymer | ||
rm -r -f polymer/@webcomponents | ||
rm -r -f polymer/web-animations-js | ||
mv build/tg-custom-build/node_modules/@google-web-components polymer/ | ||
mv build/tg-custom-build/node_modules/@polymer polymer/ | ||
mv build/tg-custom-build/node_modules/@webcomponents polymer/ | ||
mv build/tg-custom-build/node_modules/web-animations-js polymer/ | ||
rm -r -f polymer/lib | ||
rm -r -f polymer/antlr4 | ||
mv build/node_modules/@google-web-components polymer/ | ||
mv build/node_modules/@polymer polymer/ | ||
mv build/node_modules/@webcomponents polymer/ | ||
mv build/node_modules/web-animations-js polymer/ | ||
mv build/node_modules/lib polymer/ | ||
mv build/node_modules/antlr4 polymer/ | ||
rm -r -f build | ||
find polymer -type f -name "package.json" -delete |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
import antlr4 from '/resources/polymer/antlr4/dist/antlr4.web.mjs'; | ||
import antlr4 from 'antlr4'; | ||
export default antlr4; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { nodeResolve } from '@rollup/plugin-node-resolve'; | ||
|
||
export default { | ||
input: [ | ||
// Polymer, its elements and Google elements. | ||
'build-polymer.js', | ||
|
||
// Our other libraries. | ||
'node_modules/lib/antlr-lib.js', | ||
|
||
// Polymer import files, that we are using through function imports, are listed here. | ||
// They can not be added to 'build-polymer.js' because we would need to somehow use those functions there for them to be not tree-shaken. | ||
'node_modules/@polymer/polymer/lib/legacy/class.js', // 'mixinBehaviors' is required (and not used transitively) | ||
'node_modules/@polymer/polymer/lib/mixins/gesture-event-listeners.js', // (used transitively) | ||
'node_modules/@polymer/polymer/lib/utils/flush.js', // (used transitively) | ||
'node_modules/@polymer/polymer/lib/utils/render-status.js', // 'beforeNextRender' is required (and not used transitively) | ||
'node_modules/@polymer/polymer/lib/utils/async.js', // (used transitively) | ||
'node_modules/@polymer/polymer/lib/utils/flattened-nodes-observer.js', // (used transitively) | ||
'node_modules/@polymer/polymer/lib/utils/html-tag.js', // (used transitively) | ||
'node_modules/@polymer/polymer/lib/legacy/polymer-fn.js', // (used transitively) | ||
'node_modules/@polymer/polymer/polymer-element.js', // (used transitively) | ||
|
||
// These two files just perform imports with side effects and that's why they are tree-shaken if placed in 'build-polymer.js'. | ||
'node_modules/@polymer/paper-styles/paper-styles.js', | ||
'node_modules/@polymer/paper-styles/paper-styles-classes.js', | ||
|
||
// Separate testing dependency -- we also tree shake it because placed under '@polymer/' umbrella. | ||
'node_modules/@polymer/test-fixture/test-fixture.js', | ||
|
||
// Separate production files, that are used through <script src='/resources/polymer/ ... /*.js'></script>. | ||
'node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js', | ||
'node_modules/web-animations-js/web-animations-next-lite.min.js' | ||
], | ||
output: { | ||
dir: 'build', | ||
format: 'es', | ||
preserveModules: true | ||
}, | ||
plugins: [ | ||
nodeResolve({ | ||
extensions: ['.js', '.mjs'], | ||
browser: true // required for resolving browser-related file in libs like antlr4 (see 'exports' section in 'package.json' in https://www.npmjs.com/package/antlr4?activeTab=code) | ||
}) | ||
] | ||
}; |