fix: bundle CLI dependencies to resolve global module resolution issues#125
Open
diegomarino wants to merge 1 commit intomainfrom
Open
fix: bundle CLI dependencies to resolve global module resolution issues#125diegomarino wants to merge 1 commit intomainfrom
diegomarino wants to merge 1 commit intomainfrom
Conversation
Global npm installations (especially with Homebrew) have module resolution issues with ESM packages. By using bundleDependencies, we ensure that commander, chalk, and @inquirer/prompts are always available in the package's node_modules, regardless of installation method. This is the standard npm solution for CLI packages and is used by TypeScript, ESLint, and other major CLI tools. Changes: - Added bundleDependencies for commander, chalk, @inquirer/prompts - No code changes required - Increases tarball size by ~500KB (acceptable tradeoff) - Works correctly in all installation scenarios Tested: - npm pack creates tarball with bundled deps - CLIs execute correctly from /tmp (different working directory) - Module resolution works in global installs
There was a problem hiding this comment.
Pull Request Overview
This PR fixes module resolution issues in global npm installations by bundling CLI dependencies directly in the package tarball. The solution addresses errors where globally installed packages couldn't find their dependencies due to ESM module resolution quirks.
- Adds
bundleDependenciesconfiguration to package.json - Bundles CLI-specific dependencies (commander, chalk, @inquirer/prompts) directly in the npm package
- Uses standard npm approach for CLI packages to ensure reliable dependency resolution
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes module resolution issues in global npm installations by bundling CLI dependencies directly in the package.
Problem
Users installing
legal-markdown-jsglobally (especially with Homebrew-installed Node) were experiencing:This happened because ESM module resolution in global npm installs doesn't always correctly resolve dependencies in the package's
node_modules.Solution
Used
bundleDependenciesto bundle CLI-specific dependencies (commander,chalk,@inquirer/prompts) directly in the npm tarball. This is the standard npm solution for CLI packages.Why this works:
node_modulesChanges
Impact
Testing
npm pack- dependencies bundled correctlynpm link/tmp(different working directory)References