Guides ESM/CommonJS interop, module resolution errors, and import structuring for tree-shaking. Covers package.json config, tsconfig alignment, and dual-format publishing.
The JavaScript module story is two systems (ESM and CommonJS) that mostly interoperate and occasionally do not, and most "cannot use import outside a module" and "require is not defined" errors come from a mismatch nobody configured on purpose. Get the model straight and the errors resolve.
import/export). It is the standard, statically
analyzable (which enables tree-shaking), and what the ecosystem is
converging on. Signal it with "type": "module" in package.json (or
.mjs files). Reserve CommonJS (require/module.exports) for
legacy code and tools that still need it.module.exports becomes the default import), but CommonJS cannot
require an ESM module synchronously (it needs dynamic import()).
This one-way friction is behind most dual-system pain; know which
direction you are crossing (see tsconfig-mastery for making the
compiler agree).type,
tsconfig module/moduleResolution, and the bundler must agree. A
.ts file compiled as CJS but run in an ESM package, or imports
without extensions under NodeNext, produce the classic resolution
errors. Set them once, consistently, for your runtime."sideEffects": false (or list the files that do) so bundlers can drop
unused code (see bundle-size). Deep-import from large libraries
(import x from "lib/x") or use ones with proper ESM exports; a
barrel file that re-exports everything can defeat tree-shaking and slow
cold starts.import() for code-splitting and lazy loading.
await import("./heavy") loads a module on demand, splitting it into
its own chunk: the mechanism behind route-level and feature-level lazy
loading (see lazy-loading, bundle-size). It also bridges CJS
to ESM where needed.exports map
(conditional import/require entries) so both kinds of consumer
work, and pin the types entry (see npm-publishing). Getting the
exports map wrong is the top reason a published package "cannot be
imported".index.ts re-exporting a directory) trade import
convenience for bundler and cold-start cost; use them at true public
API boundaries, not for every internal folder (see
python-project-structure's analogous __init__ rule).What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Not loaded · from ai-skills-commands
Claude Code won't load this skill
It ships in ai-skills-commands at skills/, but Claude Code only loads skills/<name>/SKILL.md and folders listed under skills in plugin.json. Installing the plugin doesn't add it.
npx claudepluginhub amey-thakur/ai-skills --plugin ai-skills-commands1,000 skills in this plugin
/ab-test-designDesign product experiments with real hypotheses, honest sample-size math, guardrails, and peeking discipline. Use when validating a change by experiment or reviewing a test before believing its result./accessibility-reviewAudit a UI for real accessibility, keyboard-first, with concrete failures and fixes rather than checkbox compliance. Use when reviewing or building any user interface./accessibility-specialist-roleOperate as an accessibility specialist who audits against WCAG, trains teams to stop shipping the same defects, and owns the compliance sign-off. Use when a product needs to be usable with a keyboard, a screen reader, or magnification and someone must certify it before launch.Other plugins' skills for the same job