Ncc: Lazy imports fail to be compiled

Created on 17 Dec 2019  路  5Comments  路  Source: vercel/ncc

I was compiling a CLI with update-notifier.

However, they're lazy importing - which results in packages being missed when compiling.

Their code looks like this:

const importLazy = require('import-lazy')(require);

const isCi = importLazy('is-ci');

The compiled code expects is-ci to be a dependency.

Here's a related issue someone raised with them: https://github.com/yeoman/update-notifier/issues/123.

PS: This is a great package.

All 5 comments

I just ran into this same issue (hi @mrmckeb :wave:). I worked around this by making update-notifier a dependency and then excluding it from compilation by ncc. This works but isn't ideal since the CLI now has some dependencies that need to be installed along with it.

Thanks @iansu - I ended up doing the same thing! It works, and will do as a temporary fix ;)

Hi, I created a fork for that matter because seems like this will never be supported

https://github.com/datacrafts-io/update-notifier-webpack
https://www.npmjs.com/package/update-notifier-webpack

Also, my fork should be always up-to-date thanks to https://github.com/wei/pull bot that will track original package for any updates.

Seems that update-notifier-webpack still doesn't work with ncc since the check.js file attempts to require update-notifier-webpack (require('.')) which ends up requiring the CLI code in the dist dir, rather than the updater package.

Oh, I see now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

omar2205 picture omar2205  路  5Comments

drewolson picture drewolson  路  3Comments

maku picture maku  路  3Comments

hrueger picture hrueger  路  4Comments

guybedford picture guybedford  路  4Comments