npm pack brings unnecessary files of locally-bundled dependencies

265 views Asked by At

I have a project and it depends on a local lib package. Let me show you pakage.json

{
  "name": "myproject",
  ...
  "dependencies": {
    "local-lib": "file:../local-lib"
  }
  ...
  "bundledDependencies": [
    "local-lib"
  ]
}

And the referenced local lib package creates 'dist' directory when build. And only 'dist' directory is necessary to be installed to other package. So its package.json is like...

{
  "name": "local-lib",
  ...
  "files": [
    "dist"
  ]
}

Now, 'npm pack' in local-lib package makes local-lib-xxx.tgz file that has 'dist' directory in it. It does not include the other directories such as 'src'. This is what I want.

'npm pack' in myproject package creates myproject-xxx.tgz file bundling 'local-lib' package in it. But bundled 'node_modules/local-lib' in myproject-xxx.tgz includes unnecessary files like 'src/**'.

This is not what I want. Deployment package of 'myproject' does not need the 'src' of local-lib package. It need only 'dist' of local-lib package.

How could I get bundled packages with only necessary things for deployment?

0

There are 0 answers