You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does this need to be npm installed inside each function of the project?
Do we need to add the custom object to s-function.json shown in the readme for each function in the project?
Does this work when deploying using sls dash deploy or does it require a particular command?
Are there any global dependencies that need to be installed?
hey joel - i can answer a little bit of this (below) as to how we got it working but i also have a question for @ac360 on dependencies -> why do I have major issues with certain npm modules not being included in the resulting minified file? For example, I've got a dependency on an npm module facebook-node-sdk... the optimizer plugin is successfully minifying and packaging up the code but I get errors on lambda as if the dependency was not added to the minified file - what am i doing wrong??
@joel1st as to your questions, to get this running what you'll need is the following:
1.) create a directory at your project root called plugins
2.) move into that directory, git clone this repo
3.) move into serverless-optimizer-plugin directory and npm install
4.) now in root s-project.json, include a plugins section at the end:
however, this kind of snowballs... especially if you have a good number of dependencies - for example, now my next issue appears to be something similar - cannot find module ./aes
any tips on how to deal with what appears to be troublesome modules that break browserify - or even any tips on how to discover this locally before deploy?
what happens above is that i'm telling browserify to exclude the specific dependencies for the module and then including the entire node_modules directory - note the path there on includePaths is relative from the back/ folder. this gives a good bit of space savings but not ideal, i'd definitely like to understand more about why browserify fails and how i can help along the modules which are messy - browserify shims perhaps?
Thanks, @srg-clearlaunch , that was a good tip. I cost me some time to get this working for me with 0.1.0. As I'm using mysql I had to do something like that:
Activity
srg-clearlaunch commentedon Jan 12, 2016
hey joel - i can answer a little bit of this (below) as to how we got it working but i also have a question for @ac360 on dependencies -> why do I have major issues with certain npm modules not being included in the resulting minified file? For example, I've got a dependency on an npm module facebook-node-sdk... the optimizer plugin is successfully minifying and packaging up the code but I get errors on lambda as if the dependency was not added to the minified file - what am i doing wrong??
@joel1st as to your questions, to get this running what you'll need is the following:
1.) create a directory at your project root called plugins
2.) move into that directory, git clone this repo
3.) move into serverless-optimizer-plugin directory and npm install
4.) now in root s-project.json, include a plugins section at the end:
5.)in your s-function.json you're trying to deploy you'll need to add the config that is listed in the readme of this repo, something like this:
srg-clearlaunch commentedon Jan 12, 2016
fwiw i think i found out the problem with my facebook-node-sdk module above... looks like there is something funky with the module itself - and i needed to follow these instructions: http://stackoverflow.com/questions/32707970/how-do-you-bundle-aws-sdk-js-into-a-jaws-optimized-package
however, this kind of snowballs... especially if you have a good number of dependencies - for example, now my next issue appears to be something similar - cannot find module ./aes
any tips on how to deal with what appears to be troublesome modules that break browserify - or even any tips on how to discover this locally before deploy?
srg-clearlaunch commentedon Jan 12, 2016
fwiw to anyone else who reads this, here's what i settled on -
what happens above is that i'm telling browserify to exclude the specific dependencies for the module and then including the entire node_modules directory - note the path there on includePaths is relative from the back/ folder. this gives a good bit of space savings but not ideal, i'd definitely like to understand more about why browserify fails and how i can help along the modules which are messy - browserify shims perhaps?
arabold commentedon Jan 20, 2016
Thanks, @srg-clearlaunch , that was a good tip. I cost me some time to get this working for me with 0.1.0. As I'm using
mysqlI had to do something like that:Note that a bug (?) in 0.1.0 requires
includePathsto be directly underneath thecustomproperty instead of inside ofoptimizewhere it belongs: #8skilledDeveloper commentedon Jul 29, 2016
See my comment
#49 (comment)