medikoo / serverless-plugin-reducer

Serverless plugin: Reduce Node.js lambda package so it contains only lambda dependencies
ISC License
14 stars 5 forks source link

Include dependencies of manually included files #5

Closed jormaechea closed 5 years ago

jormaechea commented 5 years ago

I have some dynamically included modules that I include in package manually.

But this modules have others dependencies, some are mine and some are npm packages.

This last non-dinamically resolved dependencies are not being included in the function package.

Examples:

1. Local dependency

// handler.js
const moduleName = 'A';
const module = require(`./module${moduleName}`);
// moduleA.js
const module = require(`./aDependency`);
// serverless.yml
functions:
  functionA:
    include:
      - moduleA.js

This way, aDependency.js is still missing. This can be solved manually including the dependency's dependencies, although it's a pain in the a$$.

2. Npm package dependency

// handler.js
const moduleName = 'A';
const module = require(`./module${moduleName}`);
// moduleA.js
const module = require(`some-npm-module`);
// serverless.yml
functions:
  functionA:
    include:
      - moduleA.js

In this case, the npm package some-npm-module (and it's dependencies) are not packaged, and this cannot be manually solved.

medikoo commented 5 years ago

Indeed it's not how it should work, it also should not be difficult to solve, let me look into.

medikoo commented 5 years ago

Fixed with d7d827fc8d965851172747e367939a33a2dea9c7 and published with v3.2.2

jormaechea commented 5 years ago

Thanks @medikoo !