https://github.com/architect/plugin-node-prune
Architect plugin that cleans `node_modules` cruft from your cloud functions during deployment
https://github.com/architect/plugin-node-prune
Last synced: 11 months ago
JSON representation
Architect plugin that cleans `node_modules` cruft from your cloud functions during deployment
- Host: GitHub
- URL: https://github.com/architect/plugin-node-prune
- Owner: architect
- License: apache-2.0
- Created: 2019-01-25T16:44:09.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2022-11-05T04:04:33.000Z (over 3 years ago)
- Last Synced: 2025-07-06T06:02:40.583Z (11 months ago)
- Language: Shell
- Homepage:
- Size: 1.69 MB
- Stars: 2
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- Changelog: changelog.md
- Contributing: .github/contributing.md
- License: LICENSE
- Code of conduct: .github/code_of_conduct.md
Awesome Lists containing this project
README
[
](https://www.npmjs.com/package/@architect/architect)
## [`@architect/plugin-node-prune`](https://www.npmjs.com/package/@architect/plugin-node-prune)
> Node.js-specific Architect plugin based on [`node-prune`](https://github.com/tuananh/node-prune) that cleans `node_modules` cruft from your Lambdas during deployment
## Warning
Pruning your `node_modules` tree(s) has some inherent risks. While we have found it to be stable and reliable, the packages your project uses may provide different results.
For example: while unlikely, a package that includes and makes use of a file with a commonly `.npmignore`d filename may be impacted by this pruner. For a list of files and folders that are pruned, please [review the pruner script source](https://github.com/architect/plugin-node-prune/blob/main/prune.sh).
## Installation
1. Run: `npm i @architect/plugin-node-prune`
2. Then add the following to your Architect project file (usually `.arc`):
```
@plugins
architect/plugin-node-prune
```
> Note, no `@` in the plugin name!
3. Deploy your project (`npx deploy`) and watch the filesizes drop 📉
## Results
In practice, we have seen average filesize and file count reductions of about 25-30% across the board. That's a meaningful number for cloud functions!
## Disabling the plugin
If for whatever reason you need to disable the plugin, simply comment it out in (or remove it from) your Architect project file:
```
@plugins
# architect/plugin-node-prune
```
## Limitations
- Architect supports shared code by selectively copying `src/shared` and `src/views` into all Functions' `node_modules` dirs by default.
- Because this plugin runs just prior to deployment, it must avoid Architect shared code dirs so as not to inadvertently destroy user files.
- As such, any `node_modules` folders within `src/shared` or `src/views` will not be pruned.
- This plugin relies on shelling out to a bash script, so ymmv on Windows.