Skip to content

@babel/preset-env fails to polyfill Promise#finally #8297

@bradennapier

Description

@bradennapier

When using preset-env as designed it will not add the Promise#finally polyfill. Promise#finally did not ship until NodeJS v10+ so it should be doing it all the way up to that.

package.json snippet

    "@babel/cli": "^7.0.0-beta.52",
    "@babel/core": "^7.0.0-beta.52",
    "@babel/node": "^7.0.0-beta.52",
    "@babel/plugin-proposal-class-properties": "^7.0.0-beta.52",
    "@babel/polyfill": "^7.0.0-beta.52",
    "@babel/preset-env": "^7.0.0-beta.52",
    "@babel/preset-flow": "^7.0.0-beta.52",
    "@babel/register": "^7.0.0-beta.52",

.babelrc

{
  presets: [
    "@babel/preset-flow",
    [
      "@babel/preset-env",
      {
        debug: true,
        useBuiltIns: "usage",
        shippedProposals: true,
        targets: {
          node: "8.10"
        }
      }
    ]
  ],
  plugins: ["@babel/plugin-proposal-class-properties"]
}

Debug Output:

Using plugins:
  proposal-async-generator-functions { "node":"8.10" }
  syntax-object-rest-spread { "node":"8.10" }
  proposal-unicode-property-regex { "node":"8.10" }
  proposal-optional-catch-binding { "node":"8.10" }

Using polyfills with `usage` option:

[/Users/Shared/Development/projects/aws-lambda-runner/lib/plugin.js] Based on your code and targets, none were added.

[/Users/Shared/Development/projects/aws-lambda-runner/lib/runner.js] Based on your code and targets, none were added.

Transpiles To:

if (typeof runner === 'function') {
      return runFunctionInstance(runner, config, event, context, callback).then(({
        result: _result,
        data: _data
      } = {}) => {
        // code
      }).catch(err => {
        // code
      }).finally(async () => {
        // code
    }

When Run by Node 8.10 as specified:

2018-07-10T01:41:09.326Z	5181d267-83e2-11e8-8df6-5bb8f152a769	TypeError: runFunctionInstance(...).then(...).catch(...).finally is not a function
    at runAWSLambdaRunnerStartupEvaluation (/var/task/node_modules/aws-lambda-runner/dist/runner.js:162:17)```

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