npm-packlist icon indicating copy to clipboard operation
npm-packlist copied to clipboard

feat!: major refactor

Open nlf opened this issue 3 years ago • 0 comments

BREAKING CHANGE: this module now follows a strict order of operations when applying ignore rules. if a package.json containing a 'files' array is present, then top level .npmignore and .gitignore files will both be ignored entirely

this refactor drops the previous approach where the package.json files array was used to direct the tree walker, rather than as an ignore list.

the files array is back to being an ignore list, and may be overridden by nested .npmignore and .gitignore files (i.e. not at the project root).

in addition, rather than using npm-bundled to gather a list of flat package names that are to be bundled in this module, we instead load an arborist tree at the project root and walk the actual tree structure to determine what packages (and from where) should be bundled. this allowed us to reduce the complexity of the code here quite a bit since we're doing several small tree walks that do not traverse node_modules at all, so we don't have to keep track of which directories should be ignored. we also now force the follow option passed to ignore-walk to false as we no longer have any need to traverse a symlinked directory at all.

bundled dependencies are now handled somewhat differently as well. if a bundled dependency is a symlink, we assume that it is either a workspace or an otherwise linked standalone project and treat it as such. if a bundled dependency is not a symlink, then we skip all ignore rules except for those found in the package.json of the bundled dep as well as any strict inclusions or exclusions we determine based on other fields in the package.json.

closes #50 closes #54 closes #66

nlf avatar Apr 06 '22 20:04 nlf