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

No external modules needed - caused due to ES6 module imports with webpack 5.4.0 #656

Closed
dpkshrma opened this issue Nov 5, 2020 · 1 comment

Comments

@dpkshrma
Copy link

dpkshrma commented Nov 5, 2020

Bug Report

Description

  • What went wrong?

Node modules are not auto-packing as expected. Please check the following repository which helps reproduce this issue - https://github.com/dpkshrma/sls-webpack-peer-dep-issue

According to the documentation, the below configuration should allow to selectively pack only the imported modules:

// webpack.config.js
var nodeExternals = require('webpack-node-externals')

module.exports = {
  // we use webpack-node-externals to excludes all node deps.
  // You can manually set the externals too.
  externals: [nodeExternals()],
}
# serverless.yml
custom:
  webpack:
    includeModules: true # enable auto-packing of external modules

But, with the peer dependency webpack": "^5.4.0, no npm modules are packaged in the artifacts:

image

With peer dependency webpack": "^4.5.1, it works as expected:

image

  • What did you expect should have happened?
    Node modules should have been auto-packed with webpack version 5.4.0

  • What was the config you used?

service: sls-webpack-peer-dep-issue

provider:
  name: aws
  versionFunctions: false
  runtime: nodejs12.x
  region: ap-south-1
  apiGateway:
    shouldStartNameWithService: true

plugins:
  - serverless-webpack

custom:
  webpack:
    webpackConfig: webpack.config.js
    includeModules: true
    packager: "yarn"

functions:
  app:
    handler: index.default
    events:
      - http: ANY /{any+}
  • What stacktrace or error message from your provider did you see?
$ sls package
Serverless: Bundling with Webpack...
asset index.js 838 bytes [emitted] [minimized] (name: index)
runtime modules 931 bytes 4 modules
orphan modules 126 bytes [orphan] 3 modules
./index.js + 3 modules 387 bytes [not cacheable] [built] [code generated]
webpack compiled successfully in 1108 ms
Serverless: No external modules needed
(node:15690) [DEP_WEBPACK_CHUNK_MODULES_ITERABLE] DeprecationWarning: Chunk.modulesIterable: Use new ChunkGraph API
(Use `node --trace-deprecation ...` to show where the warning was created)
Serverless: Packaging service...
✨  Done in 9.06s.

Similar or dependent issue(s):

Additional Data

  • Serverless-Webpack Version you're using: 5.3.5
  • Webpack version you're using: 5.4.0
  • Serverless Framework Version you're using: 2.10.0
  • Operating System: MacOS
  • Stack Trace (if available):
@j0k3r
Copy link
Member

j0k3r commented Nov 5, 2020

Duplicates #651

@j0k3r j0k3r closed this as completed Nov 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants