Skip to content

Upgrade to Babel 8 - #441

Merged
timotheeguerin merged 4 commits into
alloy-framework:mainfrom
timotheeguerin:upgrade-babel-8
Jul 21, 2026
Merged

Upgrade to Babel 8#441
timotheeguerin merged 4 commits into
alloy-framework:mainfrom
timotheeguerin:upgrade-babel-8

Conversation

@timotheeguerin

Copy link
Copy Markdown
Collaborator

Upgrades Babel and related dependencies to v8 (along with other catalog bumps that were already part of this branch).

Babel 8 breaking changes fixed

  • @babel/generator removed CodeGenerator and the lib/printer.js entrypoint. @alloy-js/babel-plugin used both to subclass the printer and force _indent = 0 so JSX children weren't re-indented on output. Babel 8's default generator already prints JSX children verbatim without re-indenting, so the entire JSXPreservingPrinter / JSXPreservingGenerator / generatorOverride machinery is now obsolete and has been removed. Verified against the full fixture snapshot suite.
  • Babel packages now ship their own TypeScript types. The legacy @types/babel__* packages conflicted with @babel/types@8 (causing the NodePath<JSXElement | JSXFragment> type errors). Dropped them and import NodePath from @babel/core (which re-exports the v8 type) instead of @babel/traverse.
  • cli: removed a now-stale @ts-expect-error on the @babel/preset-typescript import (babel 8 ships its types).

Verification

  • @alloy-js/babel-plugin: tsc build clean; all 19 tests pass (including custom-printer / indentation whitespace fixtures).
  • @alloy-js/cli: builds and tests pass; end-to-end preset transform on real Alloy JSX produces correct output.
  • Lockfile in sync (pnpm install --frozen-lockfile clean).

Upgrade Babel and related dependencies to v8, plus other catalog bumps.

Babel 8 breaking changes fixed:
- @babel/generator no longer exports CodeGenerator nor a lib/printer.js
  entrypoint. Babel 8's default generator already prints JSX children
  verbatim without re-indenting, so the JSX-preserving printer/generator
  override in @alloy-js/babel-plugin is obsolete and was removed.
- Babel packages now ship their own types; drop the legacy @types/babel__*
  packages (they conflicted with @babel/types@8) and import NodePath from
  @babel/core instead of @babel/traverse.
- cli: remove a now-stale @ts-expect-error on the @babel/preset-typescript
  import.
@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/babel-plugin-jsx-dom-expressions
  • @alloy-js/cli
  • @alloy-js/create
  • @alloy-js/rollup-plugin
Show changes

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

Upgrade Babel and related tooling to v8. @alloy-js/babel-plugin drops the obsolete generator/printer override (Babel 8's default generator already preserves JSX whitespace) and no longer depends on the legacy @types/babel__* packages. The Babel build now passes onlyRemoveTypeImports: false to keep eliding unmarked type-only imports.

@alloy-js/babel-plugin-jsx-dom-expressions - internal ✏️

Upgrade Babel and related tooling to v8. @alloy-js/babel-plugin drops the obsolete generator/printer override (Babel 8's default generator already preserves JSX whitespace) and no longer depends on the legacy @types/babel__* packages. The Babel build now passes onlyRemoveTypeImports: false to keep eliding unmarked type-only imports.

@alloy-js/cli - internal ✏️

Upgrade Babel and related tooling to v8. @alloy-js/babel-plugin drops the obsolete generator/printer override (Babel 8's default generator already preserves JSX whitespace) and no longer depends on the legacy @types/babel__* packages. The Babel build now passes onlyRemoveTypeImports: false to keep eliding unmarked type-only imports.

@alloy-js/create - internal ✏️

Upgrade Babel and related tooling to v8. @alloy-js/babel-plugin drops the obsolete generator/printer override (Babel 8's default generator already preserves JSX whitespace) and no longer depends on the legacy @types/babel__* packages. The Babel build now passes onlyRemoveTypeImports: false to keep eliding unmarked type-only imports.

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

Upgrade Babel and related tooling to v8. @alloy-js/babel-plugin drops the obsolete generator/printer override (Babel 8's default generator already preserves JSX whitespace) and no longer depends on the legacy @types/babel__* packages. The Babel build now passes onlyRemoveTypeImports: false to keep eliding unmarked type-only imports.

- Remove stale @ts-expect-error directives on @babel/preset-typescript and
  @babel/core imports (both ship types under Babel 8): rollup-plugin,
  cli, and core e2e tests.
- Babel 8 PresetItem no longer accepts a single-element [preset] tuple;
  pass explicit options ([alloyPreset, {}]) in core e2e tests.
- Add a pnpm override wiring @babel/core@8 as the @rollup/plugin-babel
  peer (its declared range is ^7 but it works with v8), fixing a runtime
  'Cannot find package @babel/core' failure in the rollup plugin.
- js-yaml v5 is ESM-only with named exports; use { load } instead of a
  default import in the create gen-deps script.
Babel 8's @babel/preset-typescript flips the onlyRemoveTypeImports default
to true, so type-only imports that aren't written as 'import type' are no
longer elided. The emitted dist then contained value imports of
type-only symbols (e.g. AlloyHostInterface, Refkey), which broke strict
browser bundling (browser-build.test.ts) with MISSING_EXPORT errors.

Set onlyRemoveTypeImports: false in the alloy CLI build and the rollup
plugin to restore Babel 7's usage-based type-import elision.
@timotheeguerin
timotheeguerin marked this pull request as ready for review July 21, 2026 15:41
@timotheeguerin
timotheeguerin merged commit 9e88b0a into alloy-framework:main Jul 21, 2026
5 checks passed
@timotheeguerin
timotheeguerin deleted the upgrade-babel-8 branch July 21, 2026 15:46
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