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

@babel/plugin-proposal-decorators not working with @babel/plugin-transform-runtime #9454

Open
Lodin opened this Issue Feb 4, 2019 · 4 comments

Comments

Projects
None yet
3 participants
@Lodin
Copy link

Lodin commented Feb 4, 2019

Bug Report

Current Behavior
Decorator helpers are not imported if @babel/plugin-transform-runtime is enabled, instead, they are still defined in file as if no transform-runtime plugin is used.

Input Code

@cls
class A {
  @prop
  test() {}
}

Expected behavior/code
All helper functions in the file are replaced with imports from @babel/runtime.

Babel Configuration (.babelrc, package.json, cli command)

{
  plugins: [
    [require("@babel/plugin-proposal-decorators"), {decoratorsBeforeExport: true}],
    require("@babel/plugin-proposal-class-properties"),
    [require("@babel/plugin-transform-runtime"), {
      "corejs": false,
      "helpers": true,
      "regenerator": false,
      "useESModules": true
    }],
  ],
  presets: [],
}

Environment

  • Babel version(s): 7.2.2
  • Node/npm version: node 11.8.0/npm 6.5.0
  • OS: Windows 10
  • Monorepo: [e.g. yes/no/Lerna]: no
  • How you are using Babel: [e.g. cli, register, loader]: cli

Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.

I can find @babel/runtime/helpers/esm/decorate.js file in node_modules, so only import replacing doesn't work for some reason.

@babel-bot

This comment has been minimized.

Copy link
Collaborator

babel-bot commented Feb 4, 2019

Hey @Lodin! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community
that typically always has someone willing to help. You can sign-up here
for an invite.

@nicolo-ribaudo

This comment has been minimized.

Copy link
Member

nicolo-ribaudo commented Feb 4, 2019

You need to specify which runtime version you are using:

{
  plugins: [
    [require("@babel/plugin-proposal-decorators"), {decoratorsBeforeExport: true}],
    require("@babel/plugin-proposal-class-properties"),
    [require("@babel/plugin-transform-runtime"), {
      "corejs": false,
      "helpers": true,
      "regenerator": false,
      "useESModules": true,
      "version": "7.2.2"
    }],
  ],
  presets: [],
}

By default, Babel must output code compatible with runtime v7.0.0

@Lodin

This comment has been minimized.

Copy link
Author

Lodin commented Feb 6, 2019

@nicolo-ribaudo, great, thanks! Could it be mentioned in the documentation somewhere? I couldn't find it at the @babel/runtime page

@nicolo-ribaudo

This comment has been minimized.

Copy link
Member

nicolo-ribaudo commented Feb 6, 2019

Do you want to document it? 😄 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment