claudiajs / claudia

Deploy Node.js projects to AWS Lambda and API Gateway easily
https://claudiajs.com
MIT License
3.8k stars 274 forks source link

Using npm files property, temporary directory on MAC ignored #217

Closed bbehling closed 4 years ago

bbehling commented 4 years ago

Note, I've also tried to add the var directory as ["/var"], ["/var/"] and ["var/**"], but that directory is still not included in build.

*UPDATE:

If I include all the directories in my project, files["/"], then package will build correctly. Seems it was missing the lambda.js file (there may be more required files missing, but did not test)

Expected behavior would be that if I include the files property, Claudia will include the files needed to build the package.

gojko commented 4 years ago

@bbehling claudia uses npm pack, so whatever syntax is valid for npm pack will be valid for claudia. check the npm site about that. if there is a bug about packaging, it's best to submit directly to NPM in this case

bbehling commented 4 years ago

But shouldn't Claudia include the files it needs to successfully create a package? According to your docs, Claudia will include other files it needs.

So if claudia needs the lambda.js file to build successfully, this should be included in the build like other required files are.

If not, then the documentation should be updated.

From the docs - Although the AWS Node.js deployment guide requires including the node_modules folder for deployment, don’t add it to the files section. Claudia will do that automatically for you. Even better, while preparing a package, Claudia will copy all the relevant files to a temporary directory and prepare a clean install, validating the package before uploading to Lambda, to make sure that you’re deploying the right version of the dependent libraries.

Claudia did not copy the lambda.js file. This seems like unexpected behavior.

gojko commented 4 years ago

@bbehling the docs paragraph relates to node_modules specifically, I'll update it. files in NPM is a way to restrict the package contents, for example to exclude tests, build scripts etc. it's not a way to bundle stuff outside your project directory. if your project depends on stuff outside the NPM package, reference it as a NPM dependency and claudia will copy it over.