Skip to content

Refactor: Replace barrel exports with explicit imports#53

Merged
YusukeHirao merged 3 commits intomainfrom
claude/fix-index-ts-rules-07w4y
Mar 9, 2026
Merged

Refactor: Replace barrel exports with explicit imports#53
YusukeHirao merged 3 commits intomainfrom
claude/fix-index-ts-rules-07w4y

Conversation

@YusukeHirao
Copy link
Copy Markdown
Member

@YusukeHirao YusukeHirao commented Mar 7, 2026

Summary

This PR eliminates barrel export files (index.ts) across the codebase and replaces them with explicit imports from individual modules. This improves tree-shaking, reduces circular dependency risks, and makes dependencies more explicit and traceable.

closes: #15

Key Changes

Core Refactoring

  • Removed barrel exports: Deleted index.ts files from:

    • packages/@nitpicker/crawler/src/utils/ (types, array, error, object subdirectories)
    • packages/@nitpicker/crawler/src/archive/filesystem/
    • packages/@nitpicker/crawler/src/archive/
    • packages/@nitpicker/crawler/src/crawler/
    • packages/@nitpicker/core/src/hooks/
  • Updated all imports: Changed from barrel imports to explicit module imports across 30+ files:

    • import { foo } from './utils/index.js'import { foo } from './utils/types/types.js'
    • import { bar, baz } from './filesystem/index.js'import { bar } from './filesystem/bar.js'; import { baz } from './filesystem/baz.js'

Package Entry Points

  • Renamed main entry files to be more descriptive:
    • index.tscrawler.ts, cli.ts, core.ts, types.ts, axe-plugin.ts, lighthouse-plugin.ts, etc.
    • Updated package.json exports to reference new entry point names
    • Updated bin/nitpicker.js to import from new path

Documentation & Tests

  • Updated ARCHITECTURE.md to reflect new file structure
  • Updated test imports and mocks to use explicit module paths
  • Updated test server imports from index.js to server.js

Implementation Details

  • All functionality remains unchanged; this is purely a structural refactoring
  • Explicit imports make it clearer which modules depend on which, improving code maintainability
  • Better support for tree-shaking in bundlers since unused exports are no longer re-exported through barrel files
  • Reduced potential for circular dependency issues by removing intermediate aggregation layers

https://claude.ai/code/session_01Bkk5HRFJFjAviGpaT94yDn

claude added 3 commits March 6, 2026 09:20
全21個の index.ts ファイルを削除・リネームし、CLAUDE.md の
「index.ts 禁止」ルールに準拠させる。

- crawler 内部バレルファイル (utils/*, archive/*, crawler/) を削除し、
  インポートパスを実ファイルへの直接参照に変更
- 全パッケージの src/index.ts をリネーム (core.ts, crawler.ts, cli.ts 等)
- 各 package.json の exports フィールドを新ファイル名に更新
- CLI の bin/nitpicker.js のインポートパスを更新
- テストファイルのインポートパスとモック対象を更新

Closes #15

https://claude.ai/code/session_01Bkk5HRFJFjAviGpaT94yDn
- Fix utils/types/ description: ParseURLOptions → Link, CrawlerError (ParseURLOptions is not in this file)
- Add missing files to archive listing: safe-path, types
- Add missing root-level files to crawler structure: crawler.ts, debug.ts, resolve-output-path.ts, types.ts
- Fix test-server entry point: index.ts → server.ts
- Add JSDoc descriptions to test-server createApp() and startServer()

https://claude.ai/code/session_01Bkk5HRFJFjAviGpaT94yDn
@YusukeHirao YusukeHirao merged commit cb8820e into main Mar 9, 2026
3 checks passed
@YusukeHirao YusukeHirao deleted the claude/fix-index-ts-rules-07w4y branch March 9, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

index.ts 禁止ルール違反の解消

2 participants