Skip to content

Issue with working serverless-webpack#266

@yoel-inboxhealth

Description

@yoel-inboxhealth

As the documentation says, I added this configuration inside my custom property in the serverless.yaml

localstack: stages: # list of stages for which the plugin should be enabled - local - developmenthost: http://localhost # optional - LocalStack host to connect toedgePort: 4566# optional - LocalStack edge port to connect toautostart: true # optional - Start LocalStack in Docker on Serverless deploynetworks: #optional - attaches the list of networks to the localstack docker container after startup - host - overlaylambda: # Enable this flag to improve performancemountCode: true # specify either "true", or a relative path to the root Lambda mount path

The webpack config is this for the serverless:

webpack: webpackConfig: ./webpack.config.jsincludeModules: trueexcludeFiles: tests/**/*.{js,ts}keepOutputDirectory: true

This is the webpack configuration:

constpath=require('path');constslsw=require('serverless-webpack');constnodeExternals=require('webpack-node-externals');module.exports={entry: slsw.lib.entries,target: 'node',mode: slsw.lib.webpack.isLocal ? 'development' : 'production',optimization: {minimize: false,},plugins: [],performance: {// Turn off size warnings for entry pointshints: false,},externals: [nodeExternals()],module: {rules: [{test: /\.ts$/,use: 'ts-loader?configFile=tsconfig.build.json',exclude: [/node_modules/,/tests/],},],},resolve: {extensions: ['.ts','.js'],},output: {libraryTarget: 'commonjs2',path: path.join(__dirname,'.webpack'),filename: '[name].js',},cache: {type: 'filesystem',},};

And I'm getting this error:

Execution environment startup failed:{"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module 'a-handler'\nRequire stack:\n- /var/runtime/index.mjs","trace":["Runtime.ImportModuleError: Error: Cannot find module 'a-handler'","Require stack:","- /var/runtime/index.mjs"," at _loadUserApp (file:///var/runtime/index.mjs:1087:17)"," at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1119:21)"," at async start (file:///var/runtime/index.mjs:1282:23)"," at async file:///var/runtime/index.mjs:1288:1"]} 

And it looks like is because the handler path is incorrect, it says this

'_HANDLER': '.webpack/service/src/a-dir/a-handler.handle'

But when webpack package the code is located in .webpack/a-dir/a-handler.handle, what would be the solution for that, I'm kind of lost, should I update the output path?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions