Ncc: Excluding node_modules as externals

Created on 28 May 2019  路  4Comments  路  Source: vercel/ncc

Hello!

How can I exclude node_modules from building? I need to build only project sources only.

question

Most helpful comment

Yes, but I needed to exclude all external modules, and easiest way for me was to readdir node_modules and put it to ncc's externals parameter via JS script.

All 4 comments

I'm not sure I understand your use case.

The purpose of ncc is to bundle the parts of node_modules that your code uses and exclude the parts it does not use.

You can exclude node_modules by avoiding the use of require('third-party-pkg') in your source code file that is passed to ncc.

So, my purpose was to package only project sources to one bundle, except third-party modules. I found solution in doing it via ncc API.

There is a --external flag you can use.

Something like ncc build index.js -e third-party-pkg

https://github.com/zeit/ncc/issues/274#issuecomment-463436176

Yes, but I needed to exclude all external modules, and easiest way for me was to readdir node_modules and put it to ncc's externals parameter via JS script.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

paulogdm picture paulogdm  路  5Comments

guybedford picture guybedford  路  4Comments

guybedford picture guybedford  路  5Comments

j picture j  路  3Comments

maku picture maku  路  3Comments