Skip to content

Support Node 14 / ES2020  #693

@henhal

Description

@henhal

This is a Feature Request

Description

AWS is deprecating Node 10 in April, so we've converted all our lambdas, and we then went straight to Node 14. Node 14 enables using some new features, so while at it I updated my tsconfig.json to transpile to ES2020 instead of ES2019:

"compilerOptions": {
  "target": "ES2020",
  ...
}

When doing so, serverless-bundle failed to deploy my lambdas, supposedly because serverless-webpack does not support ES2020:

ERROR in <snip>/node_modules/<snip>/dist/<snip>.js 184:33
   Module parse failed: Unexpected token (184:33)
   You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
   >             body = body ?? result;

Now, obviously I can run Node 14 with TS transpiled down to ES2019; since I use TS I get the nice new features anyway so to speak and it's not really critical what level the transpiled code has as long as it still works on Node 14 (which ES2019 obviously will). But I would guess that with AWS deprecating Node 12 and encouraging people to use ES2020 features available in Node 14, you might be tempted to by default use tsconfig.json files with ES2020 level, and this will fail with serverless-webpack.

In my case, it was both my module containing the lambda and an external library which failed, so I have to go change the tsconfig.json also in the external library. Had I not owned that library as well, I might have been in greater trouble. So, assuming developers might start publishing libraries where the dist uses ES2020 features, this will be a severe problem for serverless-webpack?

Additional Data

  • Serverless-Webpack Version you're using: 5.3.5
  • Webpack version you're using: 4.44.2
  • Serverless Framework Version you're using: 2.18.0
  • Operating System: Ubuntu 18.04
  • Stack Trace (if available): N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions