Skip to content

Decorator helpers use find, which breaks ie11 #12591

@bschlenk

Description

@bschlenk

Bug Report

  • I would like to work on a fix!

Current behavior

When using decorators through @babel/plugin-proposal-decorators and @babel/plugin-transform-runtime, code is included that uses find, which is unsupported in ie11.

Input Code

@decorator
class MyClass {}

function decorator() {}

Expected behavior

I was under the impression that babel would output code that works with what I have in my .browserslistrc file, which includes ie11. I have @babel/preset-env set up with useBuiltIns: "usage" and core-js@3, but I am building through webpack and ignore node_modules. Should I allow babel to transform itself?

Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)

  • Filename: babel.config.js
module.exports = {
  plugins: [
    ['@babel/plugin-proposal-decorators', { decoratorsBeforeExport: true }],
    '@babel/plugin-proposal-class-properties',
    [
      '@babel/plugin-transform-runtime',
      {
        useESModules: true,
        version: require('@babel/runtime/package.json').version,
      },
    ],
  ],
  presets: [
    ['@babel/preset-env', { useBuiltIns: 'usage', corejs: 3 }],
    '@babel/preset-typescript',
  ],
};

Environment

  System:
    OS: macOS Mojave 10.14.6
  Binaries:
    Node: 12.20.0 - ~/.nvm/versions/node/v12.20.0/bin/node
    Yarn: 1.21.1 - ~/.yarn/bin/yarn
    npm: 6.14.10 - ~/.nvm/versions/node/v12.20.0/bin/npm
  npmPackages:
    @babel/core: ^7.12.10 => 7.12.10 
    @babel/plugin-proposal-class-properties: ^7.12.1 => 7.12.1 
    @babel/plugin-syntax-dynamic-import: ^7.2.0 => 7.8.3 
    @babel/preset-env: ^7.12.11 => 7.12.11 
    @babel/preset-typescript: ^7.12.7 => 7.12.7 
    babel-jest: ^26.6.3 => 26.6.3 
    babel-loader: ^8.2.2 => 8.2.2 
    jest: ^26.6.3 => 26.6.3 
    webpack: ^4.43.0 => 4.43.0 

Possible Solution

Use a helper function that loops instead of calling .find.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    outdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions