feat: add dynamic chalk loader for ESM compatibility#371
Open
wearedood wants to merge 1 commit into
Open
Conversation
Add getChalk.ts helper that dynamically imports ESM-only chalk with fallback shim for compatibility. Addresses issue celo-org#358.
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 ESM import error caused by chalk being ESM-only in version 5.x. This PR adds a dynamic chalk loader with fallback shim to maintain compatibility while supporting the latest chalk version.
Changes Made
src/utils/getChalk.ts: Dynamic loader that usesimport()to load ESM-only chalk with graceful fallbacksrc/index.ts: Modified CLI entrypoint to use async IIFE pattern with the getChalk helperTechnical Details
import()to handle ESM-only chalk packagechalk.green.bold()Testing
npm run build- TypeScript compilation successfulnpm run lint- ESLint passesnpm test- All tests passnode dist/index.js --help- CLI works correctlynpm pack- Package creation successfulCloses
#358