question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Packaging bug when using nodejs based custom runtime

See original GitHub issue

This is a Bug

Description

I am trying to have a custom runtime for one of my lambda function. However when I specify runtime: provided webpack is not packaging my function as expected. Instead is packaging the whole project including all the other functions. If my runtime is not provided (just standard nodejs) then the packaging is correct. Without webpack plugin it works fine as well.

I have a repro case here: https://github.com/MatteoGioioso/serverless-webpack-bug

Additional Data

  • Serverless-Webpack Version you’re using: 5.3.4
  • Webpack version you’re using: 4.29.6
  • Serverless Framework Version you’re using:
Framework Core: 1.77.1
Plugin: 3.6.18
SDK: 2.3.1
Components: 2.33.2

Webpack configuration


const path = require('path');
const nodeExternals = require('webpack-node-externals');
const slsw = require('serverless-webpack');

module.exports = {
  entry: slsw.lib.entries,
  target: 'node',
  devtool: 'source-map',

  externals: [nodeExternals()],
  module: {
    rules: [
      {
        test: /\.js$/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env'],
          },
        },
        include: __dirname,
        exclude: /node_modules/,
      },
    ],
  },
  output: {
    libraryTarget: 'commonjs2',
    path: path.join(__dirname, '.webpack'),
    filename: '[name].js',
    sourceMapFilename: '[file].map',
  },
};

Serverless.yaml simplified

service: sls-webpack-bug

provider:
  name: aws
  runtime: nodejs12.x

custom:
  webpack:
    webpackConfig: ./webpack.config.js

package:
  individually: true

plugins:
  - serverless-webpack

functions:
  exampleFunction:
    memorySize: 1024
    timeout: 30
    handler: services/myService/handler.default
    runtime: provided

  exampleFunction2:
    memorySize: 1024
    timeout: 30
    handler: services/anotherService/myHandler.default

If I have time I will make a repro case, but I think that should be it for the time being.

PS: The custom runtime is nodejs in this case

Thanks

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
MatteoGioiosocommented, Dec 11, 2020

@j0k3r ok, I can update the docs as well in the same PR if you guys need

0reactions
MatteoGioiosocommented, Dec 14, 2020

@j0k3r ok, I have made a PR for this!

Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS Lambda Custom Nodejs Container Shows Runtime Error
I have built a AWS Lambda function with custom container image. I am trying to convert an excel file to pdf with Libreoffice...
Read more >
What Node.js Custom Runtime Brings and How We ...
Thundra NodeJS Custom Runtime lets you monitor your AWS Lambda Functions with no code change. Learn how we developed Thundra NodeJS Custom Runtime....
Read more >
vercel/pkg: Package your Node.js project into an executable
This command line interface enables you to package your Node. js project into an executable that can be run even on devices without...
Read more >
Custom AWS Lambda runtimes
To use a custom runtime, set your function's runtime to provided.al2 . The runtime can be included in your function's deployment package, or...
Read more >
How to Throw Exceptions in Node.js - Rollbar
Runtime errors occur whenever something unexpected occurs in your application, and they often lead to catastrophic issues that can crash your ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found