Skip to content

feat: support dotswitch.config.ts/js/mjs/cjs config files#7

Merged
natterstefan merged 3 commits intomainfrom
feat/202603-config-files
Mar 10, 2026
Merged

feat: support dotswitch.config.ts/js/mjs/cjs config files#7
natterstefan merged 3 commits intomainfrom
feat/202603-config-files

Conversation

@natterstefan
Copy link
Owner

@natterstefan natterstefan commented Mar 10, 2026

Summary

  • Add JS/TS config file support (dotswitch.config.ts, .js, .mjs, .cjs) using jiti for runtime transpilation
  • Export defineConfig() helper for IDE intellisense and type safety
  • Remove legacy .dotswitchrc.json support (breaking, but package is effectively unused at the moment)
  • Replace toEqual with toStrictEqual across all tests

Config file resolution order

  1. dotswitch.config.ts
  2. dotswitch.config.js
  3. dotswitch.config.mjs
  4. dotswitch.config.cjs

Usage

// dotswitch.config.ts
import { defineConfig } from "dotswitch";

export default defineConfig({
  target: ".env.local",
  exclude: [".env.test"],
  hooks: { "main": "production" },
});

Test plan

  • Typecheck passes
  • All 135 tests pass
  • Build succeeds
  • Tested .ts, .js, .mjs, .cjs config loading
  • Tested priority order, partial configs, invalid syntax fallback

🤖 Generated with Claude Code

Use stricter equality checks to catch type coercion issues
and ensure objects match both value and prototype.
Add JS/TS config file support using jiti for runtime transpilation,
replacing the JSON-only approach. Config files are searched in order:
dotswitch.config.ts > .js > .mjs > .cjs > .dotswitchrc.json.

- Add defineConfig() helper for IDE intellisense and type safety
- Add jiti as a runtime dependency for sync TS/ESM/CJS loading
- Deprecate .dotswitchrc.json with a warning (still functional)
- Update README with new config format examples
Use dotswitch.config.ts, .js, .mjs, or .cjs instead.
@natterstefan natterstefan added the enhancement New feature or request label Mar 10, 2026
@natterstefan natterstefan self-assigned this Mar 10, 2026
@natterstefan natterstefan merged commit 8f3b2f4 into main Mar 10, 2026
4 checks passed
@natterstefan natterstefan deleted the feat/202603-config-files branch March 10, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant