Skip to content

fix(cli): dynamic import @inquirer modules to resolve CJS/ESM conflict#359

Merged
ankit-thesys merged 2 commits intothesysdev:mainfrom
ankit-thesys:fix/cli-module-cjs
Mar 20, 2026
Merged

fix(cli): dynamic import @inquirer modules to resolve CJS/ESM conflict#359
ankit-thesys merged 2 commits intothesysdev:mainfrom
ankit-thesys:fix/cli-module-cjs

Conversation

@ankit-thesys
Copy link
Copy Markdown
Contributor

Summary

  • Convert static @inquirer/prompts and @inquirer/core imports to dynamic await import() in resolve-args.ts to fix CJS/ESM module resolution errors
  • Move @openuidev/cli from dependencies to devDependencies in the example app
  • Use useLayoutEffect instead of useEffect for theme detection in the example app to reduce flash-of-wrong-theme

Motivation

The @inquirer/prompts package is ESM-only, but the CLI's compiled output runs in a CJS-compatible context. Static imports at the top of the file fail at module resolution time. Dynamic imports defer loading until the function is actually called, avoiding the CJS/ESM conflict.

Test plan

  • pnpm --filter @openuidev/cli build succeeds
  • Running npx create-openui-app prompts work correctly
  • Example app examples/openui-chat builds and runs without errors

🤖 Generated with Claude Code

@ankit-thesys ankit-thesys merged commit 89fa579 into thesysdev:main Mar 20, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants