Skip to content

Conversation

@ktny
Copy link
Owner

@ktny ktny commented Jul 6, 2025

Summary

npmパッケージとして公開された@ktny/ccstatをnpx経由で実行する際のESMインポートエラーを修正

問題の詳細

  • dist/index.jsでの相対パス問題(../ui/./ui/
  • ESMインポートでの.js拡張子不足
  • ディレクトリインポートでのindex.js不足

修正内容

  • scripts/fix-esm-imports.jsを改良して包括的な修正機能を追加
  • ビルドプロセスで自動的にESMインポートパスを修正
  • 手動で残った問題箇所を修正

動作確認

node dist/index.js --help - 正常に動作
node dist/index.js --hours 1 - データ処理とタイムライン表示が正常

Test plan

  • PRマージ後、npmパッケージが更新される
  • npx @ktny/ccstat での実行が正常に動作する

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Improved the handling of JavaScript import paths to ensure more accurate and comprehensive fixes for relative and directory imports.
    • Enhanced support for known import patterns and special cases, reducing potential import errors.

- dist/index.jsの相対パス問題を修正 (../ui/ → ./ui/)
- ESMインポートパスで.js拡張子不足を修正
- ディレクトリインポートでindex.js不足を修正
- scripts/fix-esm-imports.jsを改良して包括的な修正機能を追加

これによりnpx @ktny/ccstatでの実行が正常に動作

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Jul 6, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The import-fixing logic in the fixImportsInFile function within scripts/fix-esm-imports.js was refactored. The new implementation applies multiple distinct passes to handle various import path scenarios, including adding .js extensions, handling directory imports, fixing known patterns, and cleaning up duplicated extensions.

Changes

File(s) Change Summary
scripts/fix-esm-imports.js Refactored fixImportsInFile to apply multiple targeted passes for import path corrections, addressing relative, directory, known pattern, and special-case imports, and cleaning up duplicated extensions. No changes to exported function signatures.

Sequence Diagram(s)

sequenceDiagram
    participant fixImportsInFile
    participant FileContent

    fixImportsInFile->>FileContent: Read file content
    fixImportsInFile->>FileContent: Add .js to ./ and ../ imports
    fixImportsInFile->>FileContent: Append /index.js to directory imports
    fixImportsInFile->>FileContent: Fix known import patterns (core, git, UI)
    fixImportsInFile->>FileContent: Special-case fix for dist/index.js
    fixImportsInFile->>FileContent: Remove duplicated .js.js
    fixImportsInFile->>FileContent: Write updated content
Loading

Possibly related PRs

Poem

In the warren of scripts, a fix hops through,
Import paths now clearer, with .js in view.
Directories and patterns, all neatly aligned,
No more doubled extensions for us to find.
With every hop, the code grows bright—
A bunny’s touch makes imports right! 🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-07-06T13_04_05_961Z-debug-0.log


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e4aa4f9 and f628c67.

📒 Files selected for processing (1)
  • scripts/fix-esm-imports.js (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ktny ktny merged commit 6560710 into main Jul 6, 2025
0 of 2 checks passed
@ktny ktny deleted the fix/npx-execution-error branch July 6, 2025 13:04
@github-actions
Copy link

github-actions bot commented Jul 6, 2025

🎉 This PR is included in version 2.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants