Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #238: make webpacker create es5 code instead of es6 code
Changes
Notes
Babel es5 transpiling
In the builder app, we use webpacker v4, which, by default, is configured to transpile js code using babel in production.
However I've experienced huge issues with that, because, no matter what I did, babel did not transpile everything, but left loads of arrow functions (
=>
) un-transpiled, which do not work in ie11. Inspired by rails/webpacker#1239 (comment), I've discovered that our configuration did not include all necessary js paths in the scope that babel did run on.Apparently, the paths that are considered by babel, are not taken from the
config/webpacker.yml
, but need to be added by hand:Then run
rake webpack
from the matestack-ui-core root directory.Polyfills
Scope: Asset pipeline vs. webpack(er)
Users of the webpack(er) workflow transpile the js code on their own and make their own decisions regarding babel transpiling and the inclusion of polyfills.
For users of the asset pipeline, we provide ready-to-use assets including minified, transpiled js code of matestack-ui-core using the builder app. For these files, we need to consider the inclusion of polyfills here.
Filesize
With polyfills:
Without poylfills:
The babel online converter http://babeljs.io does not include polyfills. This is why the online-converted js file size is significantly smaller than the local one when including polyfills locally.
Do we need polyfills?
I've tested matestack with ie11 (in virtualbox): Currently, matestack-ui-core runs well without polyfillls.
Thus, due to filesize considerations, I'm deactivating polyfills for now in the builder app..
How to include polyfills
If we do need polyfills later, they can be activated by adding them to
packs/matestack-ui-core.js
:Then, run webpack using
rake webpack
from the matestack-ui-core root directory.Development vs. production
By default, webpacker is configured to use babel es5 transpiling only in production. However, above filesize experiment (where the min version corresponds to production, the non-min version to development) shows that polyfills are also included in development.
Thus, when testing internet explorer, you need to require the production asset manually in your main application: