Skip to content

Load chokidar with dynamic import - #460

Merged
atm-snag2 merged 1 commit into
mainfrom
load-chokidar-with-dynamic-import
Oct 23, 2026
Merged

atm-snag2 merged 1 commit into
mainfrom
load-chokidar-with-dynamic-import

Conversation

@atm-snag2

Copy link
Copy Markdown
Contributor

What

Load chokidar with a dynamic import in startLocalChangeWatcher, so that qiita-cli keeps working when chokidar becomes ESM-only in v5.

How

  • This follows the existing pattern for ESM-only packages (chalk, boxen, open). Migrating the whole package to ESM is out of scope.
  • chokidar stays at 4.0.3 in this PR. The ESM build of 4.0.3 also has export default { watch, FSWatcher }, so the same code works with both 4.0.3 and 5.0.0.
  • The bump itself is left to Bump chokidar from 4.0.3 to 5.0.0 #448. After this PR is merged, Dependabot can rebase Bump chokidar from 4.0.3 to 5.0.0 #448 without a human commit on its branch.

Why

#448 (chokidar 4.0.3 → 5.0.0) fails lint, build, and test. chokidar 5.0.0 ships ESM only, and qiita-cli compiles to CommonJS (module: "Node16"), so the static import chokidar from "chokidar" becomes a require call that cannot load the package.

  • lint:typecheck / build:server: src/server/app.ts(1,22): error TS1479
  • test: src/commands/preview.test.ts and src/commands/index.test.ts fail to load src/server/app.ts

Until this is fixed, every chokidar bump is blocked here.

Refs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@atm-snag2 atm-snag2 self-assigned this Oct 22, 2026
@atm-snag2

Copy link
Copy Markdown
Contributor Author

Verification

Environment: Node.js v24.22.1, pnpm 10.34.7 (macOS)

chokidar 4.0.3 (this PR as is)

Check Result
pnpm run lint:typecheck pass
pnpm run lint:eslint pass
prettier --check src pass
pnpm test (run twice) 26 suites, 248 tests passed both times
pnpm run build pass

chokidar 5.0.0 (installed temporarily with pnpm add chokidar@5.0.0, not committed)

Check Before this PR With this PR
pnpm run lint:typecheck src/server/app.ts(1,22): error TS1479 pass
pnpm run lint:eslint not run pass
pnpm test 2 suites failed (preview.test.ts, index.test.ts) 26 suites, 248 tests passed
pnpm run build not run pass

The "Before this PR" column was run on Node.js v24.22.0. The other runs used v24.22.1.

File watcher

  • With both 4.0.3 and 5.0.0, I loaded startLocalChangeWatcher from the built dist/server/app.js, connected a WebSocket client, and wrote a file in the watched directory. The client received local changed.
  • With 4.0.3, I ran qiita preview against a local Qiita API and opened an article in a browser. I appended a unique string to the article file. The string appeared in the article body without a page reload.
  • I did not run qiita preview in a browser with 5.0.0. That can be checked on Bump chokidar from 4.0.3 to 5.0.0 #448 after it is rebased.

@atm-snag2
atm-snag2 marked this pull request as ready for review October 22, 2026 08:24
@atm-snag2
atm-snag2 requested review from a team and inukai-masanori and removed request for a team October 22, 2026 10:44

@inukai-masanori inukai-masanori left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@atm-snag2
atm-snag2 merged commit 4b1bea4 into main Oct 23, 2026
11 checks passed
@atm-snag2
atm-snag2 deleted the load-chokidar-with-dynamic-import branch October 23, 2026 05:05
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.

2 participants