vercel / vercel/ncc

Lazy imports fail to be compiled

Open
#495 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
9.8k
Forks
326
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue by compiling a CLI that uses update-notifier and its import-lazy pattern, then inspect ncc's handling of dynamic requires. Done means the compiled output recognizes and includes the lazily imported is-ci dependency and the resulting CLI runs correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.