Skip to content

Adopt explicit type imports and re-enable onlyRemoveTypeImports - #443

Merged
timotheeguerin merged 5 commits into
alloy-framework:mainfrom
timotheeguerin:type-imports-only-remove
Jul 21, 2026
Merged

Adopt explicit type imports and re-enable onlyRemoveTypeImports#443
timotheeguerin merged 5 commits into
alloy-framework:mainfrom
timotheeguerin:type-imports-only-remove

Conversation

@timotheeguerin

@timotheeguerin timotheeguerin commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Fixes #442

What

Migrate the codebase to explicit type-only imports/exports (import type / export type) so we can drop the Babel 8 stopgap and rely on the default onlyRemoveTypeImports: true.

Approach: verbatimModuleSyntax

Rather than a lint rule, enforcement is done via TypeScript's verbatimModuleSyntax (added to tsconfig.base.json). It's compiler-enforced by the tsc typecheck the build already runs, and — unlike oxlint's consistent-type-imports — it also covers samples/**, **/scripts/**, and other oxlint-ignored dirs. It errors (TS1484/TS1485) precisely on the pure type symbols that would break at runtime under onlyRemoveTypeImports: true.

Changes

  • tsconfig.base.json: enable verbatimModuleSyntax.
  • Marked all type-only imports/exports across the codebase with import type / export type (bulk-applied via oxlint's consistent-type-imports / consistent-type-exports fixer as a one-time mechanical tool; the rules are not kept in .oxlintrc.json). This includes previously oxlint-ignored dirs: samples/**, **/scripts/**, and packages/babel-plugin-alloy (NodePath).
  • Dropped the onlyRemoveTypeImports: false override in packages/cli/src/babel.ts and packages/rollup-plugin/src/index.ts (Babel 8 default is true).
  • Fixed packages/core/testing/index.ts: the export * from "./extend-expect.js" re-export was rewritten to export type *, which dropped the expect.extend(...) side effect that registers the toRenderTo matchers. Added an explicit side-effect import "./extend-expect.js" alongside the type-only re-export.

Verification

  • pnpm build
  • pnpm test — 210 files / 1717 tests pass ✅ (incl. packages/core/test/browser-build.test.ts)
  • pnpm lint
  • pnpm format:check
  • npx chronus verify

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @alloy-js/babel-plugin
  • @alloy-js/cli
  • @alloy-js/core
  • @alloy-js/csharp
  • @alloy-js/go
  • @alloy-js/java
  • @alloy-js/json
  • @alloy-js/markdown
  • @alloy-js/msbuild
  • @alloy-js/python
  • @alloy-js/rollup-plugin
  • @alloy-js/typescript
  • @alloy-js/typespec
Show changes

@alloy-js/babel-plugin - internal ✏️

Adopt explicit import type / export type across the codebase (enforced via TypeScript's verbatimModuleSyntax) and re-enable Babel 8's default onlyRemoveTypeImports: true by dropping the stopgap override in the CLI and rollup-plugin builds.

@alloy-js/cli - internal ✏️

Adopt explicit import type / export type across the codebase (enforced via TypeScript's verbatimModuleSyntax) and re-enable Babel 8's default onlyRemoveTypeImports: true by dropping the stopgap override in the CLI and rollup-plugin builds.

@alloy-js/core - internal ✏️

Adopt explicit import type / export type across the codebase (enforced via TypeScript's verbatimModuleSyntax) and re-enable Babel 8's default onlyRemoveTypeImports: true by dropping the stopgap override in the CLI and rollup-plugin builds.

@alloy-js/csharp - internal ✏️

Adopt explicit import type / export type across the codebase (enforced via TypeScript's verbatimModuleSyntax) and re-enable Babel 8's default onlyRemoveTypeImports: true by dropping the stopgap override in the CLI and rollup-plugin builds.

@alloy-js/go - internal ✏️

Adopt explicit import type / export type across the codebase (enforced via TypeScript's verbatimModuleSyntax) and re-enable Babel 8's default onlyRemoveTypeImports: true by dropping the stopgap override in the CLI and rollup-plugin builds.

@alloy-js/java - internal ✏️

Adopt explicit import type / export type across the codebase (enforced via TypeScript's verbatimModuleSyntax) and re-enable Babel 8's default onlyRemoveTypeImports: true by dropping the stopgap override in the CLI and rollup-plugin builds.

@alloy-js/json - internal ✏️

Adopt explicit import type / export type across the codebase (enforced via TypeScript's verbatimModuleSyntax) and re-enable Babel 8's default onlyRemoveTypeImports: true by dropping the stopgap override in the CLI and rollup-plugin builds.

@alloy-js/markdown - internal ✏️

Adopt explicit import type / export type across the codebase (enforced via TypeScript's verbatimModuleSyntax) and re-enable Babel 8's default onlyRemoveTypeImports: true by dropping the stopgap override in the CLI and rollup-plugin builds.

@alloy-js/msbuild - internal ✏️

Adopt explicit import type / export type across the codebase (enforced via TypeScript's verbatimModuleSyntax) and re-enable Babel 8's default onlyRemoveTypeImports: true by dropping the stopgap override in the CLI and rollup-plugin builds.

@alloy-js/python - internal ✏️

Adopt explicit import type / export type across the codebase (enforced via TypeScript's verbatimModuleSyntax) and re-enable Babel 8's default onlyRemoveTypeImports: true by dropping the stopgap override in the CLI and rollup-plugin builds.

@alloy-js/rollup-plugin - internal ✏️

Adopt explicit import type / export type across the codebase (enforced via TypeScript's verbatimModuleSyntax) and re-enable Babel 8's default onlyRemoveTypeImports: true by dropping the stopgap override in the CLI and rollup-plugin builds.

@alloy-js/typescript - internal ✏️

Adopt explicit import type / export type across the codebase (enforced via TypeScript's verbatimModuleSyntax) and re-enable Babel 8's default onlyRemoveTypeImports: true by dropping the stopgap override in the CLI and rollup-plugin builds.

@alloy-js/typespec - internal ✏️

Adopt explicit import type / export type across the codebase (enforced via TypeScript's verbatimModuleSyntax) and re-enable Babel 8's default onlyRemoveTypeImports: true by dropping the stopgap override in the CLI and rollup-plugin builds.

@timotheeguerin
timotheeguerin marked this pull request as ready for review July 21, 2026 17:12
@timotheeguerin
timotheeguerin merged commit d7f7586 into alloy-framework:main Jul 21, 2026
5 checks passed
@timotheeguerin
timotheeguerin deleted the type-imports-only-remove branch July 21, 2026 18:18
timotheeguerin added a commit that referenced this pull request Jul 29, 2026
## What

Cleans up and modernizes the Babel-based build tooling, removing
duplicated configuration and giving the Rollup/Vite plugin a real API.

### `@alloy-js/babel-preset`
- Converted from plain JS to TypeScript with real type declarations, so
consumers import the preset without `@ts-expect-error`.
- package.json hygiene: description/author/homepage/bugs/exports/types,
`build`/`clean` scripts, `node >=22`.

### `@alloy-js/rollup-plugin`
- Real typed `AlloyPluginOptions` (`addSourceInfo`, `sourceMaps`) that
are actually forwarded (previously ignored).
- Adds a Vite `config` hook that auto-configures `esbuild.jsx:
"preserve"` and the `source` resolve/ssr conditions, so **consumers no
longer set these by hand**.
- Typed `PluginOption` return (was `any`).

### Consumers
- `@alloy-js/cli` and the plugin compose the typed preset chain inline
(`@babel/preset-typescript` + Alloy preset).
- Removed the now-redundant `esbuild`/`resolve.conditions`/`ssr`
boilerplate from 16 `vitest.config.ts` files.

## Validation
- `pnpm build` ✔
- `pnpm test` — 243 files / 2103 tests ✔
- `pnpm run lint` (0 warnings), `format:check`,
`sync-publish-config:check`, `chronus verify` ✔

## Notes
The stale assumption that `onlyRemoveTypeImports: false` was required is
no longer true — #443 re-enabled the Babel 8 default via explicit type
imports, so the preset chain uses `typescriptPreset` plainly.
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.

Adopt explicit import type and re-enable onlyRemoveTypeImports (Babel 8)

1 participant