module-pattern

Guides export and encapsulation decisions for non-React JavaScript modules.

1|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/TierOne-Studio/spa-velocity --skill module-pattern-tierone-studio
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: module-pattern
Source: https://github.com/TierOne-Studio/spa-velocity/tree/main/.ruler/skills/module-pattern
Command: npx skills add https://github.com/TierOne-Studio/spa-velocity --skill module-pattern-tierone-studio

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? When designing utility modules, formatting libraries, schema definitions, or service-layer wrappers in a JavaScript SPA, it is easy to over-export internals, pollute the global scope, or hurt tree-shaking. This Skill provides clear rules for deciding what to export, what to keep file-private, and how module shape affects bundling and testability. ## Core Features & Use Cases - Export Strategy Guidance: Explains when to use named exports, default exports, and namespace imports, with concrete code examples. - Encapsulation Rules: Shows how module-scoped declarations keep values private and prevent naming collisions across files. - Dynamic Import Patterns: Covers on-demand module loading with import() to reduce initial bundle size, including template-literal paths. - Use Case: You are writing a new date-formatting utility library for your SPA and need to decide which helpers to export, which to keep private, and whether to lazy-load locale data. ## Quick Start Ask the assistant to apply the module pattern skill when designing a new JavaScript utility module so it can advise on exports, privacy, and dynamic imports.

Frequently Asked Questions about module-pattern

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

FAQPage Schema
How do I decide between named exports and default exports in JavaScript?

Use named exports when a module exposes multiple values, and a default export for the single primary value of a module. A module can have many named exports but only one default export, and they are imported with different syntax.

How do I keep values private in a JavaScript module?

Simply do not export them. Declarations inside an ES2015 module are scoped to that file by default, so any variable without the export keyword is inaccessible to importing files, preventing naming collisions and global scope pollution.

When should I use dynamic import() instead of static imports?

Use dynamic import() when a module is only needed under certain conditions, so it loads on demand rather than at page load. This reduces initial bundle size, and import() also accepts expressions like template literals for computed paths.

Does the module pattern apply to React components?

This Skill explicitly excludes React component files, hooks, and framework-managed entry points. It targets plain JavaScript or TypeScript modules such as utilities, formatting libraries, schema definitions, and service-layer wrappers.

When should I avoid the classic IIFE module pattern?

Avoid the IIFE-based module pattern when native ES2015 modules with static import/export are available, since static imports give better tooling and tree-shaking. It is also unnecessary in codebases that already use a bundler for encapsulation.