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

IE11 Promise polyfill not loaded from @babel/present-env v7.7.0 #10830

Closed
AlmeroSteyn opened this issue Dec 6, 2019 · 5 comments
Closed

IE11 Promise polyfill not loaded from @babel/present-env v7.7.0 #10830

AlmeroSteyn opened this issue Dec 6, 2019 · 5 comments
Labels
i: bug i: needs triage outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@AlmeroSteyn
Copy link

Bug Report

I have an issue with @babel/preset-env not injecting the Promise polyfill after upgrading from v7.6.3 to v7.7.x.

Current Behavior
In a Preact application, when upgrading @babel/preset-env from v7.6.3 to v7.7.x, IE11 crashes with console error "Promise" is undefined. In the same repo, by simply reverting back to v7.6.3, the issue goes away and the code works flawlessly again.

I have tried a large number of things, including confirming that the browserslist is resolved correctly but am unable to fix this issue.

Input Code
I am currently unable to reproduce this in a smaller repo that I can share without breaking non-disclosure of company code as I don't know what has changed and therefore where to even start looking for it yet.

I am hoping that this is a known issue or that my configuration is enough to suggest a fix.

Expected behavior/code
The polyfills should work in IE11.

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

Configuration is done in webpack.config as rules.

Initially the rule was loaded as:

            plugins: [
              '@babel/plugin-syntax-dynamic-import',
              '@babel/plugin-proposal-object-rest-spread',
              [
                '@babel/plugin-transform-runtime',
                {
                  absoluteRuntime: false,
                  helpers: true,
                  corejs: 3,
                  regenerator: true,
                  useESModules: true,
                },
              ],
              [
                '@babel/plugin-transform-react-jsx',
                {
                  pragma: 'h',
                  pragmaFrag: 'Fragment',
                },
              ],
            ],
          },
        },

BROWSERS is defined as const BROWSERS = 'last 1 version, > 1%, not dead'

After consulting the documentation I change the deprecated query to use:

        {
          test: /\.js$/,
          exclude: /(node_modules|bower_components)/,
          use: {
            loader: 'babel-loader',
            options: {
              presets: [
                [
                  '@babel/preset-env',
                  {
                    useBuiltIns: "entry",
                    corejs: '3'
                  }
                ],
              ],
              plugins: [
                '@babel/plugin-syntax-dynamic-import',
                '@babel/plugin-proposal-object-rest-spread',
                [
                  '@babel/plugin-transform-runtime',
                  {
                    absoluteRuntime: false,
                    helpers: true,
                    corejs: 3,
                    regenerator: true,
                    useESModules: true,
                  },
                ],
                [
                  '@babel/plugin-transform-react-jsx',
                  {
                    pragma: 'h',
                    pragmaFrag: 'Fragment',
                  },
                ],
              ],
            },
          },
        },

In package.json I have the following setting now:

  "browserslist": "last 1 version, > 1%, not dead"

Environment

- Babel version(s): 7.4.4
- Node/npm version: Node 10.16.0/npm 6.11.3/yarn used at 1.19.1
- OS: Windows 10
- Monorepo: no
- How you are using Babel: loader
@babel-bot
Copy link
Collaborator

Hey @AlmeroSteyn! 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
Copy link
Member

I am currently unable to reproduce this in a smaller repo that I can share without breaking non-disclosure of company code as I don't know what has changed and therefore where to even start looking for it yet.

Could you at least share the path of the source file which contains the promise which isn't being transpiled?

@AlmeroSteyn
Copy link
Author

@nicolo-ribaudo Oh yeah of course!

Fails on /node_modules/preact/dist/preact.module.js and /node_modules/regenerator-runtime/runtime.js.

Both files that I cannot imagine should need transpilation?

@anthony-redFox
Copy link

I guess - it is the same as #10678 (comment)

@nicolo-ribaudo
Copy link
Member

This should be fixe by facebook/regenerator#383, because now we use the polyfilled promise with regenerator.

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jun 22, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: bug i: needs triage outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

4 participants