Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Framework: Move @babel/polyfill import to webpack config #26094

Merged
merged 1 commit into from
Jul 17, 2018

Conversation

ockham
Copy link
Contributor

@ockham ockham commented Jul 16, 2018

For #24788 (which otherwise breaks). Usage in webpack.config.js is documented in official Babel docs.

Testing Instructions

Verify that functionality that isn't present in a browser but provided by the polyfill still works.

In particular, follow testing instructions found in #25419 to make sure we're not introducing a regression here. @jblz I don't have Android Studio installed on my computer, can I ask you to give this a test?

@ockham ockham added Framework [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Jul 16, 2018
@ockham ockham self-assigned this Jul 16, 2018
@ockham ockham requested review from jblz and a team July 16, 2018 21:49
@matticbot
Copy link
Contributor

@jblz
Copy link
Member

jblz commented Jul 17, 2018

@ockham I tried to give it a run on the same setup I used for the other issue and unfortunately, it looks like the init is broken on the UC Mini browser in prod again :(

I/chromium( 2416): [INFO:CONSOLE(113)] "Uncaught SyntaxError: Use of const in strict mode.", source: https://calypso.live/calypso/141.235cace701bed7e16978.min.js (113)
I/chromium( 2416): [INFO:CONSOLE(12)] "Uncaught TypeError: Object [object global] has no method 'AppBoot'", source: https://calypso.live/start?branch=move/babel-polyfill-to-webpack-config (12)

Will try and see if I can get more info.

@jblz
Copy link
Member

jblz commented Jul 17, 2018

My gut says this is related to #26120. I'm trying a rebase to see if it fixes it.

Copy link
Member

@jblz jblz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My gut says this is related to #26120. I'm trying a rebase to see if it fixes it.

Suspicion confirmed. After rebasing this on master, I'm able to boot Calypso on Android 4.4 / UC Mini and I noticed no regressions.

@ockham
Copy link
Contributor Author

ockham commented Jul 17, 2018

Awesome, thanks so much @jblz!

@ockham ockham merged commit ed6beaa into master Jul 17, 2018
@ockham ockham deleted the move/babel-polyfill-to-webpack-config branch July 17, 2018 20:54
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jul 17, 2018
@jsnajdr
Copy link
Member

jsnajdr commented Jul 18, 2018

@ockham This PR increased the bundle size and reverted the improvements achieved in #25961.

It's because babel-preset-env used to transform the @babel/polyfill import into a list that excludes the polyfills that are not needed on the target browser list. In the new location of @babel/polyfill, the plugin doesn't get the opportunity to do that transform and all polyfills are bundled again.

Is there a way to fix this?

@ockham
Copy link
Contributor Author

ockham commented Jul 18, 2018

Ouch. Sorry 'bout that, I should've checked ICFY.

I guess we can revert for now. My rationale for filing this PR was #24788, which wouldn't work without this change -- which probably means that babel-present-env is apparently a bit over-eager when it comes to excluding polyfills there. We'll need to find out what exactly is breaking there and fix it 🙁

@jsnajdr
Copy link
Member

jsnajdr commented Jul 18, 2018

Here's an idea for a simple fix: create a file client/boot/babel-polyfill.js with just one line:

import '@babel/polyfill';

and then use it in the entrypoint array:

entry: {
  build: [ './client/boot/babel-polyfill', './client/boot/app' ]
}

That simple indirection will make the babel-polyfill.js transpiled by the Babel loader and the preset can do its job.

I didn't test it, so it might not work. Also, it might break Lerna again if the overeager babel-preset-env was really the issue. But let's first try to move forward (create a fix) rather than backward (revert).

@ockham
Copy link
Contributor Author

ockham commented Jul 18, 2018

Thanks for the suggestion! Unfortunately, that gives the same error as before 🙁

@ockham
Copy link
Contributor Author

ockham commented Jul 18, 2018

(In combination with #24788 that is -- meaning we might as well revert.)

@ockham
Copy link
Contributor Author

ockham commented Jul 19, 2018

@jsnajdr found a fix here.

ockham added a commit that referenced this pull request Jul 20, 2018
)" (#26192)

This reverts commit ed6beaa.

[Rationale](#26094 (comment)):

> This PR [increased](http://iscalypsofastyet.com/push/ed6beaa5e0b54f6ddbe11360c8ad8a572b83a32f/e3642614723d88c353e5d768969d8f877d7472c4) the bundle size and [reverted](http://iscalypsofastyet.com/push/acef9fa493cc06a9fefece7ff00759997af8ca8a/03502467b044464e191c9746c510c6a10a7930e0) the improvements achieved in #25961.
>
> It's because `babel-preset-env` used to transform the `@babel/polyfill` import into a list that excludes the polyfills that are not needed on the target browser list. In the new location of `@babel/polyfill`, the plugin doesn't get the opportunity to do that transform and all polyfills are bundled again.

I filed #26094 in the first place to get #24788 to work. Fortunately, @jsnajdr found [another way](#24788 (comment)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants