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

When context is used in the webpack config, handlers arent found #418

Closed
jdbevan opened this issue Jun 28, 2018 · 1 comment
Closed

When context is used in the webpack config, handlers arent found #418

jdbevan opened this issue Jun 28, 2018 · 1 comment
Milestone

Comments

@jdbevan
Copy link
Contributor

@jdbevan jdbevan commented Jun 28, 2018

This is a Bug Report

Description

For bug reports:

  • What went wrong?
    I had a context path defined in my webpack config. serverless-webpack therefore didn't find the relevant files for the handlers because it uses the serverless.config.servicePath

  • What did you expect should have happened?
    It should have found my files, or told me where it was looking for them

  • What was the config you used?

service: jons-service

provider:
  name: aws
  runtime: nodejs4.3
  memorySize: 128
  timeout: 60
  stage: dev
  region: us-west-2

plugins:
  - serverless-webpack

custom:
  webpack:
    packager: yarn
    includeModules:
      forceExclude:
        - aws-sdk

functions:
  my-function:
    handler: modules/foo-bar.doSomething

and

const webpack = require('webpack');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const slsw = require('serverless-webpack');

const entry = Object.keys(slsw.lib.entries).reduce((acc, path) => {
    return {
        ...acc,
        [path]: ['babel-polyfill'].concat(acc[path])
    }
}, slsw.lib.entries);

const config = {
    context: __dirname + "/app"
    target: "node",
    mode: 'production',
    entry,
    externals: ['aws-sdk'],
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                use: [{
                    loader: 'babel-loader',
                    options: {
                        presets: [["env", {
                            "targets": {
                                "node": "4.3"
                            }
                        }]]
                    }
                }]
            }
        ]
    },

    optimization: {
        minimizer: [
            new UglifyJsPlugin({
                parallel: true,
                uglifyOptions: {
                    mangle: false
                }
            })
        ]
    },

    plugins: [
        new webpack.NoEmitOnErrorsPlugin(),
        new webpack.DefinePlugin({
            'process.env.NODE_ENV': 'production'
        })
    ]
};

module.exports = config;
  • What stacktrace or error message from your provider did you see?
    No matching handler found for 'modules/foo-bar'. Check your service definition.

For feature proposals:

  • What is the use case that should be solved. The more detail you describe this in the easier it is to understand for us.
  • If there is additional config how would it look

Similar or dependent issue(s):
*

Additional Data

  • Serverless-Webpack Version you're using: 5.1.5
  • Webpack version you're using: 4.12.1
  • Serverless Framework Version you're using: 1.27.3
  • Operating System: macOS Sierra 10.12.6
  • Stack Trace (if available):
@HyperBrain HyperBrain added this to the 5.2.0 milestone Jun 28, 2018
@HyperBrain
Copy link
Member

@HyperBrain HyperBrain commented Jun 28, 2018

Hi @jdbevan , good catch 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants