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

Remove the "class-properties" and "private-methods" plugins #501

Closed
Windvis opened this issue Aug 31, 2023 · 2 comments
Closed

Remove the "class-properties" and "private-methods" plugins #501

Windvis opened this issue Aug 31, 2023 · 2 comments

Comments

@Windvis
Copy link

Windvis commented Aug 31, 2023

ember-cli-babel hardcodes these plugins so they are always transpiled even if the app's targets support the features natively. @babel/preset-env v7.14 also includes these plugins by default so these features would still be transpiled if needed.

I think we can safely remove the plugins without it being a breaking change.

@Windvis
Copy link
Author

Windvis commented Aug 31, 2023

Partly solved by #449 since that removes the "class-properties" plugin.

@Windvis
Copy link
Author

Windvis commented Aug 31, 2023

Looking into it, it seems it won't be this simple (which is probably why it wasn't done before 😅):

Some things I encountered:

  • ember-cli-typescript < v3 adds the "class-properties" plugin if it hasn't been added yet. ember-load-initializers in the blueprint brings in this version. What I'm not sure about is if this only affects that addon's code, or the whole bundle.

  • ember-auto-import does a similar thing but I assume it only affects the packages that are imported?

  • after patching ember-cli-babel to remove the transforms, an exception is thrown at runtime by the (legacy) decorator plugin. The docs explicitly mention that those plugins shouldn't be needed anymore if you use preset-env though 🤔. https://babeljs.io/docs/babel-plugin-proposal-decorators#legacy

    If you are already using @babel/preset-env, you can safely remove @babel/plugin-transform-class-properties and @babel/plugin-private-methods:

    Error message:

    Decorating class property failed. Please ensure that transform-class-properties is enabled and runs after the decorators transform.

This is the same issue as mentioned here: #447

I've opened a discussion in the babel repo to see if this behavior is intended: babel/babel#15912

@Windvis Windvis closed this as completed Jan 2, 2024
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

No branches or pull requests

1 participant