Upgrade to Babel 8 - #441
Conversation
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.
|
All changed packages have been documented.
Show changes
|
- 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.
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/generatorremovedCodeGeneratorand thelib/printer.jsentrypoint.@alloy-js/babel-pluginused both to subclass the printer and force_indent = 0so JSX children weren't re-indented on output. Babel 8's default generator already prints JSX children verbatim without re-indenting, so the entireJSXPreservingPrinter/JSXPreservingGenerator/generatorOverridemachinery is now obsolete and has been removed. Verified against the full fixture snapshot suite.@types/babel__*packages conflicted with@babel/types@8(causing theNodePath<JSXElement | JSXFragment>type errors). Dropped them and importNodePathfrom@babel/core(which re-exports the v8 type) instead of@babel/traverse.@ts-expect-erroron the@babel/preset-typescriptimport (babel 8 ships its types).Verification
@alloy-js/babel-plugin:tscbuild clean; all 19 tests pass (includingcustom-printer/indentationwhitespace fixtures).@alloy-js/cli: builds and tests pass; end-to-end preset transform on real Alloy JSX produces correct output.pnpm install --frozen-lockfileclean).