Extra file (package.json) not included into final zips
See original GitHub issueDescribe the bug Extra files (package.json to be exact) are not included into the final zips.
Versions (please complete the following information):
- OS: Mac
- Serverless Framework Version: 3.18.2
- Plugin Version: 1.30.0
Additional context
So basically I wanted to use esbuild with ESM (AWS supports this for a while already). I set the type
inside package.json to module
and everything else needed for this move, worked fine, but the problem I stumbled upon is that serverless-esbuild simply does not include the package.json
into the zip even if it’s added to the package.patterns
like so below.
custom:
esbuild:
bundle: true
minify: false
packager: 'yarn'
target: 'node16'
keepOutputDirectory: true
package:
individually: true
excludeDevDependencies: true
patterns:
- 'package.json'
It looks like the .esbuild
contains the the package.json
, but the zips themselves don’t.
Of course I could just name my files .mjs
instead, but that isn’t an ideal solution for me.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
javascript - How to automatically zip files with Node.js and npm
The files array is a whitelist of what to include. Here, it's just index.js and the lib directory. However, npm will also automatically...
Read more >Serverless package does not include all modules when a ...
Description. When deploying multiple versions of a service or just versions of the function within the service, but sometimes some modules are ...
Read more >Create an application source bundle - AWS Elastic Beanstalk
Create an application source bundle · Consist of a single ZIP file or WAR file (you can include multiple WAR files inside your...
Read more >How To Work With Zip Files in Node.js - DigitalOcean
After you run the command, npm will install adm-zip and update the package.json file. Next, create a directory called test and move into...
Read more >Common Configuration - electron-builder
in the package.json file of your project using the build key on the top level: ... If you want to use js file,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@doteric yes, you’re absolutely right, only external modules, here is the thing, other dependencies are bundled and you don’t need them in generated package.json. so your assumption is correct, but could be vice versa, some of the params from base package.json would be copied to generated one, because you probably do not need
scripts
for instance nad other dev specific meta.hi @doteric , to be honest, not sure what is the reason we exclude, maybe because anyway we deliver bundled code and
package.json
used to be just unnecessary development artifacts, but feel free to test it locally withpatch-package
for instance and let as know, if you’d like raise a PR, keep in mind that we do not use rootpackage.json
for packaging dependencies, we generate one here https://github.com/floydspace/serverless-esbuild/blob/master/src/pack-externals.ts#L293, maybe it makes sense store this file, not the root one, but we’d also have to copy some necessary module meta located in rootpackage.json
you mentioned, so your js files are treated correctly by nodejs.