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

aws-sdk: warning on deployment #393

Closed
shavo007 opened this Issue May 14, 2018 · 8 comments

Comments

Projects
None yet
2 participants
@shavo007
Copy link

shavo007 commented May 14, 2018

This is a Bug Report

Description

Updated webpack serverless and now get warning when deploying

Serverless: WARNING: Runtime dependency 'aws-sdk' found in devDependencies. You should use forceExclude to explicitly exclude it.

Config:

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

module.exports = {
  entry: slsw.lib.entries,
  target: 'node',
  // Generate sourcemaps for proper error messages
  devtool: 'source-map',
  // Since 'aws-sdk' is not compatible with webpack,
  // we exclude all node dependencies
  externals: [nodeExternals()],
  mode: slsw.lib.webpack.isLocal
    ? 'development'
    : 'production',
  optimization: {
    // We no not want to minimize our code.
    minimize: false
  },
  performance: {
    // Turn off size warnings for entry points
    hints: false
  },
  plugins: [new Dotenv()],
  // Run babel on all .js files and skip those in node_modules
  module: {
    rules: [
      {
        test: /\.js$/,
        loader: 'babel-loader',
        include: __dirname,
        exclude: /node_modules/
      }
    ]
  }
};

Similar or dependent issue(s):

Additional Data

  • Serverless-Webpack Version you're using: 5.1.5
  • Webpack version you're using: 4.8.3
  • Serverless Framework Version you're using: 1.27.2
  • Operating System: linux
  • ***Stack Trace (if available)***:
@HyperBrain

This comment has been minimized.

Copy link
Member

HyperBrain commented May 14, 2018

Hi @shavo007 , thanks for the report 👍 .

This warning is expected, because I improved the dependency detection to be able to find common issues where dependencies are set in devDependencies instead of dependencies (I treated this missing behavior as a bug, because it could lead to defunctional deployments). These issues are very hard to track down, because previously they only led to crashes when deployed.
However, for the aws-sdk this is expected, because it normally is in devDependencies although it is referenced at runtime. That's why it leads to a warning and not an error as other dependencies would do. Functional, there is no difference on deployment as with the previous serverless-webpack versions, only that a warning is printed.

To get rid of the warning and have a correct project setup you should set the aws-sdk as forcefully excluded. This explicitly states that it is not deployed intentionally (as the serverless.yml is declarative, this is then more correct than silently excluding it). So, just add:

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

in your serverless.yml and the warning will be gone and it expresses, what is happening and what is intended.

@HyperBrain

This comment has been minimized.

Copy link
Member

HyperBrain commented May 14, 2018

I'll change the issue subject, so that others who recognize the warning can lookup and find it more easily.

@HyperBrain HyperBrain changed the title warning on deployment aws-sdk: warning on deployment May 14, 2018

@shavo007

This comment has been minimized.

Copy link
Author

shavo007 commented May 14, 2018

hi @HyperBrain thanks for the response.

Issue is that it is correctly defined as a dev dependency (aws lambda includes aws-sdk in container).

see https://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html

That is why i do not have it as a dependency.

When i see a warning in my CI server i assume there is a problem.

What you think?

@HyperBrain

This comment has been minimized.

Copy link
Member

HyperBrain commented May 14, 2018

@shavo007 As I wrote, there is no problem and you defined it correctly in devDependencies 😃 . The warning is only a hint that aws-sdk should be set as forceExclude to let the system know that you intended to have it that way (which is fully normal for it).

The only thing you should do is, to define the forceExclude: ... aws-sdk to explicitly state that you are aware of this to have the configuration reflect exactly what is set up in your service.

@HyperBrain

This comment has been minimized.

Copy link
Member

HyperBrain commented May 15, 2018

I added some docs in #395 to explain the behavior (thanks to @arabold for the idea).
However, could someone please check the wording and placement of the paragraphs, if it is ok how I did it?

@shavo007

This comment has been minimized.

Copy link
Author

shavo007 commented May 16, 2018

tbh @HyperBrain im just not a big fan of this change!

i shoudnt have to declaratively exclude aws-sdk to resolve the warning. When in fact I am doing the right thing and defining it as a dev dependency.

Why have this warning in the first place? Why not have a whitelist and exclude aws-sdk?

Thoughts?

@HyperBrain

This comment has been minimized.

Copy link
Member

HyperBrain commented May 16, 2018

@shavo007 What we could do is, to restrict the warning to only show up with --verbose and change it to an informational message then, like INFO: devDependency aws-sdk has been excluded automatically. This could be a bit clearer and as you said, actually it is no issue and the standard behavior. How does that sound?

@shavo007

This comment has been minimized.

Copy link
Author

shavo007 commented May 16, 2018

@HyperBrain info sounds good. but thats just my opinion!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment