Skip to content

Don't remove excluded modules from the node modules directory #18

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/RuntimeBabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ module.exports = function(S) {
return this.copyFunction(func, pathDist, stage, region)
.then(() => this._addEnvVarsInline(func, pathDist, stage, region))
.then(() => this._browserify(func, pathDist))
.then(() => this._cleanup(pathDist))
.then(() => this._cleanup(func, pathDist))
.then(() => pathDist);
});
}
Expand Down Expand Up @@ -259,8 +259,11 @@ module.exports = function(S) {
* - removes all non-bundled .js and .json files from the pathDist
*/

_cleanup(pathDist) {
let ignore = '**/_serverless_handler.js';
_cleanup(func, pathDist) {
let exclude = _.get(func, 'custom.runtime').exclude || [],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it breaks if custom/runtime is not defined in s-function.json

ignore = ['**/_serverless_handler.js']
.concat(exclude.map(ex => `${pathDist}/**/node_modules/${ex}/**/*`));
Copy link

@machard machard Jun 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the regex is not perfect.

my exclude is
[ "regenerator-runtime/path.js", "regenerator-runtime/runtime.js" ]
(i tried to make pac-resolver work, because of the readFileSync. Only excluding regenerator-runtime does not work as path.js and runtime.js will be bundled because they are explicitely required)

my structure is
project root
---server
------node_modules (just for the api)
------api

and i had to add
.concat(exclude.map(ex => ${pathDist}/node_modules/${ex}));


S.utils.sDebug('cleaning up');
return BbPromise
.fromCallback(cb => require('glob')(`${pathDist}/**/*+(.js|.json)`, {ignore}, cb))
Expand Down