You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Change how required built-ins are polyfilled #8727
The current npm packages that being built for Gutenberg polyfill usage of some browser features that are not available on older browsers. This polyfill is global and affects any client who uses the gutenberg npm packages. This is unexpected and can alter the runtime environment in surprising ways. Additonally, some client environments do not require these polyfills and would work without them. Bundling them increases the overall bundle size and slows down loading.
Instead, gutenberg's packages should take one of two approaches: use use babel's transform-runtime plugin to replace problematic built-in usage, or stop polyfilling altogether and declare that host environments must polyfill certain features for Gutenberg to work on downlevel browsers. The later is the direction being taken by react-dom and some other libraries that require full ES5 compliance.
@blowery, we have just published new packages to npm which have @babel/runtime usage replaced with @babel/runtime-corejs2. Can you double check if that changes anything?
Activity
gziolo commentedon Aug 9, 2018
This is the current state of art:
We use
@babel/plugin-transform-runtimewhen producing a distribution version of packages. See:https://github.com/WordPress/gutenberg/blob/master/packages/babel-preset-default/index.js#L23
We also add
@babel/runtime-corejs2as a dependency of each package which is transpiled, e.g.:https://github.com/WordPress/gutenberg/blob/master/packages/blocks/package.json#L23
blowery commentedon Aug 9, 2018
@gziolo The problematic line is https://github.com/WordPress/gutenberg/blob/master/packages/babel-preset-default/index.js#L11. That includes polyfills that affect the global scope when a given module uses language features that require a polyfill on older browers.
blowery commentedon Aug 9, 2018
Here's an example of what Gutenberg outputs today.
source:
transpiled:
My contention is that Gutenberg should not ship code that requires the core-js polyfill.
gziolo commentedon Aug 9, 2018
@blowery, we have just published new packages to npm which have
@babel/runtimeusage replaced with@babel/runtime-corejs2. Can you double check if that changes anything?/cc @aduth @youknowriad @ntwb
gziolo commentedon Aug 9, 2018
Okey, this is still the case. I see:
in https://unpkg.com/@wordpress/editor@2.0.0/build-module/components/navigable-toolbar/index.js
Code of this polyfill:
https://unpkg.com/core-js@2.5.7/modules/es6.array.find.js
gziolo commentedon Aug 20, 2018
Opened #9171 hoping that it will solve the issue. However I still see imports like:
gziolo commentedon Sep 5, 2018
This should be resolved with the #9171 and is now available on npm.
Check related versions of updated packages in df6f8da.