Skip to content

fix: vite.config.ts の __dirname を import.meta.dirname に - #192

Merged
isamu merged 1 commit into
mainfrom
fix/vite-config-dirname
Oct 21, 2026
Merged

isamu merged 1 commit into
mainfrom
fix/vite-config-dirname

Conversation

@isamu

@isamu isamu commented Oct 21, 2026

Copy link
Copy Markdown
Member

Summary

Replaces __dirname with import.meta.dirname in the three places vite.config.ts uses it, the entry points of the library build.

The package is "type": "module", so __dirname is not defined in the config. It worked only because Vite's default (bundling) config loader fills it in. Loaded as native ESM (--configLoader runner), vitest and vite build stopped at startup with ReferenceError: __dirname is not defined. This is what had kept Codex's environment from running vitest.

Items to Confirm

  • The build output is the same. A yarn build before and after the change, and the hashes of every file under dist/ compared: all identical.
  • The runner loader now works. npx vitest run --configLoader runner passes, and npx vite build --configLoader runner succeeds. Both failed at startup before.
  • yarn test (the default loader), yarn lint and yarn typecheck pass, and npx vite (the demo's dev server) answers 200.
  • import.meta.dirname needs Node 20.11 or later; engines is already >=22.
  • Not type-checked: vite.config.ts is not in tsconfig.json's include, and @types/node is not installed. So this file's types are not checked, as with __dirname before.

User Prompt

  • Is __dirname worth fixing? If so, go ahead.

🤖 Generated with Claude Code

work in GUIChatPluginSpreadsheet

The package is "type": "module", so __dirname is not defined in the config; it worked only because
Vite's bundled config loader supplies it. With --configLoader runner (native ESM) vitest and vite
build stopped at startup with ReferenceError.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@isamu

isamu commented Oct 21, 2026

Copy link
Copy Markdown
Member Author

CODEX VERDICT: LGTM

Axis Result
correctness and edge cases none
security (injection / path traversal / code evaluation) none
tests: does a test go red if the new behaviour breaks none — npx vitest run --configLoader runner: 2 files / 32 tests passed; yarn test:engine: 2,216 tests passed
API / schema / wire / on-disk compatibility none
consistency with the rest of the codebase none
i18n lockstep (src/lang has 8 locales) none
TIER S (one config file; build output byte for byte) none — the change only replaces the config’s directory lookup; the three resolved entry paths remain the same
build: __dirname/config CommonJS consumers and CI Node versions none — no other runtime __dirname dependency was found; CI runs Node 22, 24, and 26, all supporting import.meta.dirname
verify none — npx vite build --configLoader runner and yarn typecheck passed; lint had only existing warnings

Reviewed SHA: 400c8e003b4e2e44c9163e970a2372609df1b4ad.

Mutation sweep: not run; no mutation is proposed.

FINDINGS COMPLETE: I read every hunk of the diff and this is every finding I have.

@isamu
isamu merged commit 93bbca2 into main Oct 21, 2026
17 checks passed
@isamu
isamu deleted the fix/vite-config-dirname branch October 21, 2026 08:17
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.

1 participant