serverless-webpack: Bug Report. Node.js 8.10. Building for Production. serverless-webpack 5.1.1.

Bug Report

Description

  • What went wrong?

    • Migration from 6.10 to 8.10
  • What was the config you used?

    • Changed targets in .babelrc from 6.10 to 8.10
    • Changed runtime in serverless.yml from 6.10 to runtime: nodejs8.10
  • What stacktrace or error message from your provider did you see?

    • It doesn’t give any meaningful error, I even removed uglify from the webpack config, but still receive without produced file:
ERROR in Unexpected token (1106:32)

Additional Data

  • Serverless-Webpack Version you’re using: 5.1.1
  • Webpack version you’re using: 4.4.1
  • Serverless Framework Version you’re using: 1.26.1
  • Operating System: MacOS High Sierra 10.13.3

.babelrc:

{
  "presets": [
    ["env", {
      "targets": {
        "node": "8.10"
      }
    }]
  ],
  "plugins": [
    "syntax-dynamic-import", // tried with and without
    "transform-es2015-template-literals", // tried with and without
    "transform-object-rest-spread", // tried with and without
    "syntax-object-rest-spread", // tried with and without
    ["transform-imports", {
      "my-library": {
        "transform": "../../path/to/transform.js",
        "preventFullImport": true
      }
    }],
    ["babel-plugin-inline-import", {
      "extensions": [".gql"]
    }]
  ]
}

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (4 by maintainers)

Most upvoted comments

You need to use the babel-preset-stage-2 preset together with the env preset when using 8.10 as target.

The problem is, that the pure env 8.10 preset does not include the spread rest operator and import. So use

"presets": [
    ["env", {
      "targets": {
        "node": "8.10"
      }
    }],
    "stage-2"
  ],

We did the transistion yesterday for our projects and that way it works.

@OlzhasAlexandrov I updated my comment to include the dash (wrote the answer just too quickly 😄 ). Thanks for the correction.