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

Clean up babel messages when testing #5419

Conversation

Lukazovic
Copy link
Contributor

What does this PR do?

Fixes console warnings when running yarn test. Nowadays it shows multiple messages like:

The "loose" option must be the same for @babel/plugin-proposal-class-properties, @babel/plugin-proposal-private-methods and @babel/plugin-proposal-private-property-in-object (when they are enabled): you can silence this warning by explicitly adding
	["@babel/plugin-proposal-private-methods", { "loose": false }]
to the "plugins" section of your Babel config.
Though the "loose" option was set to "true" in your @babel/preset-env config, it will not be used for @babel/plugin-proposal-private-methods since the "loose" mode option was set to "false" for @babel/plugin-proposal-class-properties.

It closes #5416

Where should the reviewer start?

.babelrc
package.json

What testing has been done on this PR?

yarn test

How should this be manually tested?

Running: yarn test

Any background context you want to provide?

What are the relevant issues?

#5416

Screenshots (if appropriate)

Screenshot from 2021-07-02 16-21-45

Do the grommet docs need to be updated?

No.

Should this PR be mentioned in the release notes?

No.

Is this change backwards compatible or is it a breaking change?

No.

Copy link
Collaborator

@halocline halocline left a comment

Choose a reason for hiding this comment

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

Hi @Lukazovic, Thank you for helping out here!

While this does eliminate the warning, I am wondering if you could share any insights as to the root cause of this issue and why this is the proper fix? I'd like to learn more.

From my investigation, this warning seems to have been introduced on Babel's side and has been a bug which has been reported and re-surfaced from time to time.

Additionally, the warning speaks to @babel/preset-env

Though the "loose" option was set to "true" in your @babel/preset-env config, it will not be used ...

Storybook .babelrc uses @babel/preset-env, but I don't see any configurations specifying loose as true.

I'd like to understand any potential side-effects that could be introduced. Any insights you could share would be much appreciated.

@Lukazovic
Copy link
Contributor Author

Lukazovic commented Jul 2, 2021

Hello @halocline.

Yeah, from my investigation, it looks like this bug is probably caused by @babel/preset-env. But unfortunately, I don't know much more than you do about it.

I can share some issues I found while I was trying to understanding this warning:

I'd like to understand any potential side-effects that could be introduced

I think we should be good because we have some other configs on storybook /storybook/.babelrc. But I agree we should test it and understand it better.

While this does eliminate the warning, I am wondering if you could share any insights as to the root cause of this issue and why this is the proper fix? I'd like to learn more.

I found a PR that fixed this warning on Nuxt.js, and that's how they solved it:

If you find something else, please, let me know. I'd like to learn more about it as well

@halocline
Copy link
Collaborator

Hello @halocline.

Yeah, from my investigation, it looks like this bug is probably caused by @babel/preset-env. But unfortunately, I don't know much more than you do about it.

I can share some issues I found while I was trying to understanding this warning:

I'd like to understand any potential side-effects that could be introduced

I think we should be good because we have some other configs on storybook /storybook/.babelrc. But I agree we should test it and understand it better.

While this does eliminate the warning, I am wondering if you could share any insights as to the root cause of this issue and why this is the proper fix? I'd like to learn more.

I found a PR that fixed this warning on Nuxt.js, and that's how they solved it:

If you find something else, please, let me know. I'd like to learn more about it as well

Thank you for the additional details. I appreciate it. I'd like to do a bit more investigation prior to proceeding. Will pick this back up next week. Thanks again for your help!

@halocline
Copy link
Collaborator

Hello @halocline.
Yeah, from my investigation, it looks like this bug is probably caused by @babel/preset-env. But unfortunately, I don't know much more than you do about it.
I can share some issues I found while I was trying to understanding this warning:

I'd like to understand any potential side-effects that could be introduced

I think we should be good because we have some other configs on storybook /storybook/.babelrc. But I agree we should test it and understand it better.

While this does eliminate the warning, I am wondering if you could share any insights as to the root cause of this issue and why this is the proper fix? I'd like to learn more.

I found a PR that fixed this warning on Nuxt.js, and that's how they solved it:

If you find something else, please, let me know. I'd like to learn more about it as well

Thank you for the additional details. I appreciate it. I'd like to do a bit more investigation prior to proceeding. Will pick this back up next week. Thanks again for your help!

I'd also been looking at where this logic is being applied to make sense of it here but had gotten interrupted and haven't gotten back to it.

@Lukazovic
Copy link
Contributor Author

Cool, if I find something else I'll add a comment to this PR.

@ericsoderberghp
Copy link
Member

Any reason we cannot remove loose: true, from tools/grommet-babel-preset-es2015.js?

@halocline
Copy link
Collaborator

Any reason we cannot remove loose: true, from tools/grommet-babel-preset-es2015.js?

So, it looks like we get significant savings in our bundle size when using loose: true. If we switch to loose: false, grommet.min.js is 32% larger.

loose: true ==> grommet.min.js (503 KiB)

loose: false ==> grommet.min.js (662 KiB)

Because of the increase in bundle size and the setting loose: true has been in place 3-4 years without issue, I recommend we:

  • leave loose: true in tools/grommet-babel-preset-es2015.js
  • modify
    "@babel/plugin-proposal-class-properties"
    to read ["@babel/plugin-proposal-class-properties", { "loose": true }]

This approach will align the usage of loose across plugins, eliminate babel's warning, and keep bundle size reduced.

@halocline
Copy link
Collaborator

Because of the increase in bundle size and the setting loose: true has been in place 3-4 years without issue, I recommend we:

  • leave loose: true in tools/grommet-babel-preset-es2015.js
  • modify
    "@babel/plugin-proposal-class-properties"

    to read ["@babel/plugin-proposal-class-properties", { "loose": true }]

This approach will align the usage of loose across plugins, eliminate babel's warning, and keep bundle size reduced.

@Lukazovic, would you like to modify this PR to reflect this ☝️ approach? Otherwise, I can open a separate PR. Let me know your preference.

@halocline halocline added the waiting Awaiting response to latest comments label Jul 13, 2021
@Lukazovic
Copy link
Contributor Author

@Lukazovic, would you like to modify this PR to reflect this approach? Otherwise, I can open a separate PR. Let me know your preference.

@halocline I'd like to modify this PR, I'll do it today

@halocline
Copy link
Collaborator

@Lukazovic, would you like to modify this PR to reflect this approach? Otherwise, I can open a separate PR. Let me know your preference.

@halocline I'd like to modify this PR, I'll do it today

Awesome. Thank you!

@Lukazovic Lukazovic force-pushed the chore/clean-up-babel-messages-when-testing branch from 2669a16 to ff928c0 Compare July 13, 2021 21:41
@Lukazovic Lukazovic requested a review from halocline July 13, 2021 21:42
Copy link
Collaborator

@halocline halocline left a comment

Choose a reason for hiding this comment

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

Thank you for collaborating on this with us @Lukazovic! We appreciate your help.

@halocline halocline removed the waiting Awaiting response to latest comments label Jul 13, 2021
@ericsoderberghp ericsoderberghp merged commit 8bb9bff into grommet:master Jul 13, 2021
@Lukazovic Lukazovic deleted the chore/clean-up-babel-messages-when-testing branch July 13, 2021 23:49
@Lukazovic
Copy link
Contributor Author

Thank you for collaborating on this with us @Lukazovic! We appreciate your help.

@halocline thank You for helping me out

@britt6612 britt6612 mentioned this pull request Nov 30, 2021
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

clean up babel messages when testing
3 participants