dougmoscrop / serverless-plugin-include-dependencies

MIT License
184 stars 40 forks source link

Plug-in ignores package exclude(?) #9

Closed neverendingqs closed 7 years ago

neverendingqs commented 7 years ago

(Related to #6)

I have the following (slight modification from files created with sls create):

serverless.yml:

service: aws-nodejs

provider:
  name: aws
  runtime: nodejs4.3

package:
  exclude:
    - node_modules/aws-sdk/**

plugins:
  - serverless-plugin-include-dependencies

functions:
  hello:
    handler: handler.hello

handler.js:

'use strict';

const aws = require('aws-sdk')

module.exports.hello = (event, context, callback) => {
  const response = {
    statusCode: 200,
    body: JSON.stringify({
      message: 'Go Serverless v1.0! Your function executed successfully!',
      input: event,
    }),
  };

  callback(null, response);

  // Use this code if you don't use the http event with the LAMBDA-PROXY integration
  // callback(null, { message: 'Go Serverless v1.0! Your function executed successfully!', event });
};

Running sls deploy --noDeploy produces a aws-node.zip package that includes node_modules/aws-sdk.

Removing the serverless-plugin-include-dependencies plugin produces a package that does not include node_modules/aws-sdk.

Does this plugin ignore entries in package exclude?

dougmoscrop commented 7 years ago

This is correct. This plugin includes dependencies with no attempts at excluding them. It's been suggested but I'm not sure how I want to go about it.

This plugin is supposed to be a size-reducing middle ground without getting in to the intricacies that something like browserify has to deal with.

dougmoscrop commented 7 years ago

I have a basic working solution to this that handles excludes against includes, but I also have an idea for how to take it even further. I'll try to get it out soon.

dougmoscrop commented 7 years ago

2.0 should support this. Please give it a try. Note that for the best filtering, you should exclude node_modules/**/aws-sdk/** since aws-sdk could be installed underneath some dependencies.

neverendingqs commented 7 years ago

Worked perfectly. Thanks!