-
Notifications
You must be signed in to change notification settings - Fork 417
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
Unable to exclude package from being bundled #1218
Comments
Hi, I tried following options (and all of them does not work) excludeFiles
forceExcludecustom:
webpack:
includeModules:
forceExclude:
- puppeteer nodeExternals in webpack.config.jsexternals: [
nodeExternals({
modulesFromFile: {
exclude: ["puppeteer"]
}
})
] noInstall: truecustom:
webpack:
packagerOptions:
noInstall: true this actually causes error
|
The This is also why, in newer versions of webpack, they renamed Try moving your externals: [
nodeExternals({
modulesFromFile: {
excludeFromBundle: ["devDependencies"]
}
})
] |
@vicary Thanks. The problem is not that I get it bundled into .js file but rather that it is included into a resulting ZIP file... It is used by https://github.com/ghostery/adblocker/tree/master/packages/adblocker-puppeteer |
If I am getting it correctly, your puppeteer lives inside Our package installer, i.e. the You may try the followings,
|
@vicary it's not ideal to use package.patterns especially when dependencies have a lot of peerDependencies. No one want to review manually peerDependencies in a large number of their lambda functions. For example TypeORM from version 3 started to use ts-node as optional peerDependency which on its own has typescript peerDependency which is huge and now all of it in packaged zip so the size of lamba.zip file has been started to grow significantly and upload of lambda functions have been started to fail due to AWS lambda limits. So I would say it's critical issue which requires urgent fix. Devs from serverless-esbuild seems fixed it already floydspace/serverless-esbuild#113 |
Removing optional peer deps is already supported since 3 years now #542 |
But it doesn't work by some reason. In my example the TypeORM version 3 started to be packaged with ts-node and typescript in node_modules and command npm list typescript says it's due to ts-node which is optional peerDependency. |
@j0k3r I am not using puppeteer directly, but through chrome-aws-lambda package: https://github.com/huksley/puppeteerless/blob/main/package.json you think I should go to maintainers of chrome-aws-lambda and ask them to add peerDependenciesMeta ? |
@huksley I guess so, like it's done in typeorm. Even better, you can submit yourself a PR (it's hacktoberfest!) @andrew-ignatiev regarding the code, |
@j0k3r in unzipped lambda folder I see the next npm list outputs: npm list ts-node npm list typescript I have checked package-lock.json and ts-node is optional peerDependency here. I don't see any other non optional peerDependencies or primary dependencies. In package-loc.json in section dependencies:
|
@j0k3r @vicary I've created minimal reproducible repo. Could you please check?
|
Maybe we could have a flag which will treat all peer dependencies as optional if they do not appear in dependencies of the parent package? I allways thought this is a convention. |
@vicary Answering your post on Aug 12 (sorry, I just noticed it) git clone https://github.com/huksley/puppeteerless |
@j0k3r @vicary I've created extra branch with TypeORM v2
Could you confirm the optional peerDependency issue in |
Temporary workaround for short term in serverless.yml:
|
I have the same problem now with typescript bundled. Now I do
Dependecy tree excerpt:
|
I updated my project, but you need to remove hook proposed by @andrew-ignatiev in serverless.yml to show the bug
|
I think the better way is to trace all dependencies how NextJS does https://github.com/vercel/nft |
Why is this marked as "Awaiting reply"? All replies and reproducible repo has been given. |
as issue is still open and still relevant, i'll left ref to own one(there is repo with straightforward steps how to reproduce it) @huksley as workaround you can use packageOptions -> scripts in order to exclude redundant package from final node_modules // serverless.ts file
.....
webpack: {
packagerOptions: {
scripts: ['#define custom script here which will delete redundant files/folders'],
},
},
.... |
@collierrgbsitisfise thanks I already doing it and use esbuild to trace dependencies and it works pretty well |
This is a Bug Report
Description
What went wrong?
I am using the
puppeteer
package, and it creates inside a.local-chromium
folder during package installation.This package and
.local-chromium
folder are being packaged together into the zip file which end up being 352Mb.What did you expect should have happened?
Package
puppeteer
should not be present in the resulting zip node_modules/ folder.What was the config you used?
See config and full reproducible example in
https://github.com/huksley/puppeteerless/blob/main/serverless.yml
What stacktrace or error message from your provider did you see?
I am getting very slow upload speed and error that unpacked size exceeds 200Mb.
Additional Data
NodeJS v16.16.0 NPM v8.11.0
"serverless-webpack": "5.8.0"
"webpack": "^5.72.1", "webpack-node-externals": "^3.0.0"
"serverless": "^3.21.0"
Reproducing
The text was updated successfully, but these errors were encountered: