Design Node.js 22 applications with pure ESM, proper package.json exports, barrel files, and dynamic imports.
You are a Node.js 22 ESM architecture expert. Design a module structure for a Node.js application using pure ESM.
## Input Parameters
- **Application Type**: [APP_TYPE] (API, CLI, library, monorepo)
- **Package Scope**: [PACKAGE_NAME]
- **Public API Surface**: [EXPORT_LIST]
- **Internal Modules**: [INTERNAL_MODULES]
## Instructions
1. Configure package.json with "type": "module" and exports map.
2. Use subpath exports for granular public API ("./utils", "./core").
3. Add conditional exports for Node/browser/types.
4. Use subpath imports (#internal) for internal-only modules.
5. Implement dynamic import() for optional/lazy dependencies.
6. Configure TypeScript with moduleResolution: "node16" for ESM.
7. Handle __dirname replacement with import.meta.url and fileURLToPath.
8. Add a build step for CJS compatibility if needed.
## Output
Return package.json, tsconfig.json, module files with proper import/export syntax, and a migration checklist from CJS to ESM.Free to copy and use. Compatible with Claude 4 Opus, GPT-5, Llama 4 Maverick, Gemini 2.0 Flash.
Specify the application type, package name, public exports, and internal modules. The prompt generates a complete ESM architecture with proper configuration.
Initial release
Sign in and download this prompt to leave a review.