Skip to content

build: remove babel, configure swc to be main test transpiler#7743

Open
tomdavies73 wants to merge 2 commits intomasterfrom
FE-7424
Open

build: remove babel, configure swc to be main test transpiler#7743
tomdavies73 wants to merge 2 commits intomasterfrom
FE-7424

Conversation

@tomdavies73
Copy link
Contributor

@tomdavies73 tomdavies73 commented Jan 29, 2026

Proposed behaviour

Removes all babel related dependencies and instead uses swc/jest as the main test transpiler. In order to transition to swc/jest some additional changes have also been made.

babel/jest's less aggressive tree-shaking meant it would often leave unused exports in place during transpilation. swc/jest takes a stricter approach - it analyses exports more carefully and expects us to be more explicit about what we're exporting and using.

All exports which are unused (not imported anywhere else internally) were highlighted and have had to be removed.

There were multiple instances of consts which were only used locally in one file being exported, or instances of some costs being exported and never being used locally or elsewhere.

In some files we have also "doubled up" our exports, exporting twice as a named export and a default export. Where possible the named export has been removed, and only the default export remains.

Some additional steps have been made to meet coverage requirements with some exports which are needed but not directly tested, as instanbul ignore is now ineffectual against uncovered const statements

The removal of unused exports has been marked as a breaking change as technically some consumers may have imported these directly from legacy projects etc. However, the actual likelihood that this will break consumers' applications is slim to none.

config.ts and index.ts files are now exempt from the coverage report, as config.ts consts are typically used in stories and therefore are treated as unused. index.ts files exports are consumer facing entry points, so they have also been exempt as some exports are never imported and used elsewhere.

Current behaviour

Currently, there are multiple babel dependencies which are unused and babel/jest is used for test transpilation.

Checklist

  • Commits follow our style guide
  • Related issues linked in commit messages if required
  • Screenshots are included in the PR if useful
  • All themes are supported if required
  • Unit tests added or updated if required
  • Playwright automation tests added or updated if required
  • Storybook added or updated if required
  • Translations added or updated (including creating or amending translation keys table in storybook) if required
  • Typescript d.ts file added or updated if required
  • Related docs have been updated if required

QA

  • Tested in provided StackBlitz sandbox/Storybook
  • Add new Playwright test coverage if required
  • Carbon implementation matches Design System/designs
  • UI Tests GitHub check reviewed if required

Additional context

Testing instructions

This removes all unused exports within the codebase which were not being directly
imported or tested elsewhere. It also removes superfluous exports where a const
is exported as both a named or default export

If any exports cannot be removed because they are used in other files which are
not directly tested, new tests have been added

BREAKING CHANGE: If any consumers are importing any of these exports which have been
removed this will break their application. In theory no consumers should be importing
implementation details into their project, however we have marked this change as breaking
as there is a very remote possibility that some projects could break due to this change
@edleeks87 edleeks87 marked this pull request as ready for review January 30, 2026 08:52
@edleeks87 edleeks87 requested review from a team as code owners January 30, 2026 08:52
@edleeks87 edleeks87 marked this pull request as draft January 30, 2026 08:52
@tomdavies73 tomdavies73 added the Work in progress This is a WIP PR so may not be ready for review label Jan 30, 2026
import compareBuild from "semver/functions/compare-build";

import { TOOL_ID } from "./constants";
import { TOOL_ID } from "./constants/constants";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: you can just make constants.ts an index.ts

return (
<div ref={trapRef}>
{isOpen && (
<div
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment: not part of your changes but we should add the following to the top of the file imo so we don't get the linter warnings anymore

/* eslint-disable jsx-a11y/no-noninteractive-tabindex */
/* eslint-disable jsx-a11y/no-static-element-interactions */

"<rootDir>/lib",
"<rootDir>/esm",
".*index\\.ts$",
".*[.-]config\\.ts$",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment: we're still including files that aren't needed in the coverage report

Image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth generating a report from a test run in master and comparing it to one from this PR

}

export const ActionPopoverItem = ({
const ActionPopoverItem = ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment: I think this change has broken the prop table for the sub-components

Image

@tomdavies73 tomdavies73 marked this pull request as ready for review February 2, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

No UX QA Required Pending QA Pending Review Work in progress This is a WIP PR so may not be ready for review

Development

Successfully merging this pull request may close these issues.

2 participants