typescript-modules-packaging

Aligns TypeScript module resolution, declaration emit, and package exports for published consumers.

1|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/cjthompson/claude-code-config --skill typescript-modules-packaging-cjthompson
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-modules-packaging
Source: https://github.com/cjthompson/claude-code-config/tree/main/plugins/typescript-development/skills/typescript-modules-packaging
Command: npx skills add https://github.com/cjthompson/claude-code-config --skill typescript-modules-packaging-cjthompson

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? TypeScript packages often fail for consumers because the runtime loader, the compiler's resolver, and the package's public exports are configured as three mismatched contracts. This Skill diagnoses and aligns those contracts so published artifacts actually resolve for every supported consumer. ## Core Features & Use Cases - Resolution Matching: Pairs module and moduleResolution settings (NodeNext, bundler, CommonJS) with the actual deployment target instead of mixing incompatible emit and resolver strategies. - Explicit Export Surface: Defines exports targets with ./ paths, orders types before runtime conditions, and keeps forbidden deep imports unavailable. - Artifact Verification: Packs the real archive, installs it into isolated consumer fixtures, and compiles and executes public imports across every supported resolver and runtime. - Use Case: You are publishing a dual-audience npm library and consumers report broken subpath imports. Use this Skill to fix the exports map, emit a complete declaration graph, and verify the packed tarball in external ESM and CommonJS fixtures. ## Quick Start Review my package.json and tsconfig setup and make the published package resolve correctly for both ESM and CommonJS consumers.

Frequently Asked Questions about typescript-modules-packaging

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I configure TypeScript package exports for ESM and CommonJS?

Define exports targets with ./ paths and place the types condition before runtime conditions for each public entry. Publish one ESM build by default, and add CJS only as a distinct output with conditional exports tested independently.

What moduleResolution should I use for Node ESM in TypeScript?

Use a Node mode such as NodeNext that matches the supported runtime, with module set to the same Node mode. The legacy node resolution setting does not model Node ESM and causes mismatched loader behavior.

Why do my published TypeScript subpath imports fail for consumers?

Failures usually come from exports targets missing the ./ prefix, declarations emitted without their full referenced graph, or testing source-tree imports instead of the packed artifact. Pack the archive and install it into isolated consumer fixtures to reproduce the real failure.

Should I publish dual ESM and CJS builds of my TypeScript package?

Only when require() consumers are a stated requirement. Start with one ESM artifact, and never point import and require conditions at a single ambiguous file; add CJS as a separate output with its own verification.

How do I test a TypeScript package before publishing to npm?

Build and inspect the emitted JavaScript, declarations, and package metadata, then create the actual archive with the package-manager pack command. Install that archive into isolated consumer fixtures and compile and execute public imports under every supported resolver and runtime.