Js static import

From Intense-Visions/harness-engineering · View interactive version

Js static import is an AI agent skill from the GitHub repository Intense-Visions/harness-engineering. > Use static import declarations to load ES modules at parse time for tree-shaking and static analysis

How to use this skill

Skill file

JS Static Import

Use static import declarations to load ES modules at parse time for tree-shaking and static analysis

When to Use

Instructions

  1. Use import { name } from './module.js' at the top of the file for all compile-time dependencies.
  2. Prefer named exports over default exports — they enable tree-shaking and IDE auto-imports.
  3. Group imports: external packages first, then internal modules, then relative paths.
  4. Never use require() in ESM files — static import enables bundler dead-code elimination.
// Named exports — tree-shakeable
import { useState, useEffect } from 'react';
import { formatDate, parseDate } from '../utils/date.js';

// Default export — avoid when possible
import MyComponent from './MyComponent.js';
  1. Use import * as ns from './module.js' sparingly — it imports everything and can defeat tree-shaking.

Details

Static import declarations are resolved at parse time, before any code executes. This enables bundlers to analyze the dependency graph and eliminate unused exports (tree-shaking). Static imports are hoisted — they run before the module body regardless of where they appear in the file.

Trade-offs:

When NOT to use:

Source

https://patterns.dev/javascript/static-import

Process

  1. Read the instructions and examples in this document.
  2. Apply the patterns to your implementation, adapting to your specific context.
  3. Verify your implementation against the details and edge cases listed above.

Harness Integration

Success Criteria

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.