Deployed Files
By default, Nudeps will copy everything in each package except for the following:
- Files and directories starting with a dot
package-lock.jsonandpnpm-lock.jsonfiles at the top level of any package
Why not just restrict to copying *.js files by default?
Because this allows dependencies to fetch other files dynamically, e.g. stylesheets, images, data files, etc.
This is particularly important for UI libraries, component libraries, etc.
Since files are only fetched when used, this does not impact actual bandwidth usage.
And if you’re trusting a package to run JS in your domain anyway, the additional risk from copying its entire package directory is tiny.
That said, there are cases where you know you won’t need certain files.
You can add globs (per Node’s native glob syntax) via the ignore option.
Its value can be either an array or a singular value.
Each entry is a raw string (a glob to ignore) or an object with an ignore or copy property.
Globs are relative to the package root.
The semantics are similar to a .gitignore file: the last matching entry wins, so a copy glob can only undo ignore globs that precede it.
Your entries come after the built-in defaults, so a copy glob reverses a default and an ignore glob adds to it:
- To ship a package’s lockfile anyway:
ignore: { copy: "package-lock.json" }. - To skip readmes, which are copied by default:
ignore: "{readme,README}.*". - To only copy
*.jsfiles and nothing else:ignore: [{ ignore: "**/*" }, { copy: "**/*.js" }](but see above why this is not recommended).
Files that the import map explicitly maps are never ignored.
To restrict globs to specific packages, put them in an override rule — a rule’s ignore appends to the global list for the packages it matches:
export default {
overrides: {
"leaflet": { ignore: "docs/**" },
},
};