esm-module-patterns

Guide ESM import/export patterns and tsconfig.json configuration for TypeScript projects.

2|1|Updated Nov 13, 2025
One-click install
npx skills add https://github.com/MolcajeteAI/plugin --skill esm-module-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: esm-module-patterns
Source: https://github.com/MolcajeteAI/plugin/tree/main/deprecated/tech-stacks/js/common/skills/esm-module-patterns
Command: npx skills add https://github.com/MolcajeteAI/plugin --skill esm-module-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides clear guidance and best practices for using modern ECMAScript Module (ESM) syntax in TypeScript projects, ensuring clean, maintainable, and tree-shakeable code.

Core Features & Use Cases

  • ESM Syntax: Demonstrates preferred patterns for named and default imports/exports.
  • TypeScript Integration: Shows tsconfig.json configurations for ESM.
  • Node.js Specifics: Covers node: prefix usage and CommonJS interop.
  • Use Case: When setting up a new Node.js TypeScript project or refactoring existing code to use native ES Modules, this skill ensures you follow the latest standards and avoid common pitfalls.

Quick Start

Use the esm-module-patterns skill to generate a sample tsconfig.json for an ESM project.

Frequently Asked Questions about esm-module-patterns

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

FAQPage Schema
How do I configure a TypeScript project to use native ES Modules?

To configure native ES Modules in a TypeScript project, you need to update your package.json and tsconfig.json settings. This skill provides exact configurations and patterns for setting up ESM syntax, ensuring proper file extensions and tree-shakeable code.

What is the correct way to use import and export syntax in ESM?

Correct ESM syntax involves using named and default imports and exports. This skill demonstrates preferred patterns for structuring import/export statements, including re-exports, to ensure clean and maintainable ECMAScript Module code.

How do I import Node.js built-in modules using ESM?

Importing Node.js built-in modules in ESM requires using the node: prefix for clarity and native compatibility. This skill covers Node.js specifics including built-in module usage and handling CommonJS interop.

Does ESM support importing from CommonJS modules in Node.js?

ESM supports CommonJS interop in Node.js through specific import patterns. This skill addresses how to handle CommonJS dependencies within a native ES Module setup, enforcing ESM-only principles to avoid common integration mistakes.

What are common anti-patterns when refactoring to ECMAScript Modules?

Common ESM anti-patterns include incorrect file extensions, improper package.json configuration, and mismanaged default exports. This skill identifies these frequent mistakes and provides the correct modern ECMAScript Module patterns to avoid them.