Skip to content

Latest commit

 

History

History
62 lines (43 loc) · 2.48 KB

README.md

File metadata and controls

62 lines (43 loc) · 2.48 KB

Copy node production deps

npm Build status codecov

Find and copy production deps of package living in yarn workspace to dist folder.

NOTE: This is very experimental package., nevertheless it's used in one internal project to build minimal node_modules for services running in docker.

Usage

# copy deps of current folder to ./dist
$ npx copy-production-deps

# copy deps specific package to specific folder
$ npx copy-production-deps packages/foo-backend dist/foo-backend

# Only dist selected packages that are not bundled with esbuild
$ esbuild server.js --outfile dist/server.js --external:mongoose --external:hiredis
$ npx copy-production-deps . dist --only-packages mongoose,hiredis

Doc

Full synopsis:

copy-production-deps [packageDir] [distDir]

copy production deps from Npm/Yarn workspace to dist folder

Positionals:
  packageDir  source package folder (must contain package.json)   [default: "."]
  distDir     distribution directory (packages will be copied to
              ${distDir}/node_modules)                       [default: "./dist"]

Options:
  --version       Show version number                                  [boolean]
  --dryRun, -n    Dry run - only show what would be copied.
                                                      [boolean] [default: false]
  --verbose, -v   Run with verbose logging            [boolean] [default: false]
  --exclude-from  Read ecluded file patterns from file one pattern a line.
                                                           [array] [default: []]
  --exclude       Exclude file pattern (minimatch glob)    [array] [default: []]
  --only-packages Include only those packages         [array] [default: []
  --help          Show help                                            [boolean]

Why

Born from frustration that both yarn and npm have several bugs related to --production install and i almost wrote everywhere before i found copy-node-modules which apparently didn't support yarn workspaces.

Contribute

PRs accepted.

License

MIT © Zbigniew Zagórski