Skip to content

feat: drop react 17 support & publish esm only - #8314

Draft
tomdavies73 wants to merge 7 commits into
masterfrom
nuke_react_17_and_cjs
Draft

tomdavies73 wants to merge 7 commits into
masterfrom
nuke_react_17_and_cjs

Conversation

@tomdavies73

@tomdavies73 tomdavies73 commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Proposed behaviour

Drops support for react v17 now only react v18 is supported.

Also now drops support for commonJS publishing and supports esm only, the /esm/ path will also be removed with /lib/ taking priority as it is widely used import path by consumers.

Internal commonJS usage has also been removed from our scripts, configs, test setups etc. However some has to remain due to legacy tech debt.

After initial co-pilot reviews I've also added explicit /lib/ export mappings, rewrote Lodash and Atlaskit imports to resolvable paths, and fixed emitted declaration imports for Node16/NodeNext TypeScript resolution. I've put these in seperate -tbs commits, if we feel they're unneeded and additional complexity we can drop.

Current behaviour

Currently, we support react v17 and commonJS publish. Both are either out of support or not the industry standard, we need to remove to maintain package health.

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

@tomdavies73 tomdavies73 self-assigned this Nov 26, 2026
@tomdavies73 tomdavies73 added the Work in progress This is a WIP PR so may not be ready for review label Nov 26, 2026
Copilot AI balanced review requested due to automatic review settings November 26, 2026 10:45
@tomdavies73 tomdavies73 changed the title feat: drop react 17 support & publish esm only feat: drop react 17 support & publish esm only **WIP** Nov 26, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Extensionless Lodash imports and declaration re-exports in the emitted ESM package break default Webpack 5 bundling and Node16/NodeNext consumer type-checks with skipLibCheck disabled.

2 open issues
2 files not reviewed
What changed in this PR

This PR moves Carbon React to React 18-only support and a single ESM distribution, retaining the existing carbon-react/lib/... import paths.

Changes:

  • Removes React 17 support and the separate CommonJS/esm outputs.
  • Updates build scripts, package metadata, and asset copying for ESM-only publishing.
  • Migrates test configuration files and updates documentation, CI, and contributor guidance.
File Description
tsconfig.json Updates renamed test configuration references.
svgTransform.mjs Adds comments explaining retained CommonJS SVG output for Jest.
src/​package.json Declares source files as ESM.
scripts/​generate_package_json_files/​index.mjs Generates ESM metadata for published directories.
scripts/​generate_package_json_files/​index.js Removes the previous dual-output metadata generator.
scripts/​copy_svg/​index.mjs Copies SVG assets only to lib.
scripts/​copy_svg/​index.js Removes the previous dual-output SVG copier.
rollup.config.mjs Emits only ESM in lib and removes duplicate asset copying.
playwright/​support/​accessibility-reporter.mts Uses ESM-compatible reporter path resolution.
playwright/​package.json Declares Playwright files as ESM.
playwright/​global-teardown.js Adds an explicit extension to the helper import.
playwright-ct.config.mts Migrates configuration paths and reporter references to ESM.
package.json Requires React 18 and updates packaging and build/test scripts.
jest.config.mjs Converts Jest configuration to JavaScript ESM and removes legacy mappings.
docs/​installation.mdx Documents ESM publishing and the bundler requirement.
contributing/​testing-guide.md Explains snapshot compatibility and updates the Playwright filename.
babel.config.json Adds static Babel configuration with test-specific module handling.
babel.config.cjs Removes the previous CommonJS Babel configuration.
.vscode/​launch.json Updates the Jest debug configuration path.
.npmignore Updates the ignored Jest configuration filename.
.github/​workflows/​playwright.yml Updates configuration and reporter paths for report merging.
.github/​instructions/​implementation-shared.instructions.md Removes the obsolete esm/ output reference.
.github/​copilot-instructions.md Updates compatibility guidance to React 18.
.github/​CODEOWNERS Preserves ownership for the renamed Playwright configuration.
__mocks__/​styleMock.js Removes the CommonJS stylesheet mock.
__mocks__/​fs.js Removes the CommonJS filesystem mock.

Review effort: Balanced

Comment thread rollup.config.mjs Resolved
@tomdavies73
tomdavies73 force-pushed the nuke_react_17_and_cjs branch 4 times, most recently from a23a78e to a7de795 Compare November 26, 2026 15:36
@tomdavies73
tomdavies73 requested a balanced review from Copilot November 26, 2026 15:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The export fallback breaks the documented global-style import, and missing styled-components loaders cause Date test discovery to fail in UI and coverage runs.

3 open issues
2 resolved since last review
2 files not reviewed

Review effort: Balanced

Comment thread package.json Resolved
Comment thread package.json Resolved
Comment thread docs/installation.mdx Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The ESM-only release changes installed-package compatibility, requiring packed-artifact validation with supported consumer bundlers, Jest, and type checking that source tests and synthetic declaration fixtures do not establish.

No open issues 🎉

3 resolved since last review
2 files not reviewed

Review effort: Balanced

@tomdavies73 tomdavies73 added Pending Review Pending QA No UX QA Required and removed Work in progress This is a WIP PR so may not be ready for review labels Nov 27, 2026
@tomdavies73 tomdavies73 changed the title feat: drop react 17 support & publish esm only **WIP** feat: drop react 17 support & publish esm only Nov 27, 2026
@tomdavies73
tomdavies73 requested a review from edleeks87 December 1, 2026 12:42
@DipperTheDan
DipperTheDan self-requested a review December 1, 2026 13:11
DipperTheDan
DipperTheDan previously approved these changes Dec 1, 2026
Comment thread package.json Resolved
Comment thread rollup.config.mjs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment: context for other reviewers. I've asked @tomdavies73 to spike adding an adaptor and updating the rollup config. The idea is it will ensure styled-components styled works as a function in the esm-only builds.

tomdavies73 and others added 5 commits December 4, 2026 13:15
BREAKING CHANGE: Carbon now requires React 18. Upgrade both react and react-dom to version 18 if
currently on version 17
Render inert with the value expected by React 18 or 19 without augmenting
React declarations. Cover client rendering, server rendering, hydration,
runtime versions, and keyboard focus behavior.

BREAKING CHANGE: Option and SimpleSelect inert props now accept booleans only.
String, number, and other legacy values are no longer supported.
BREAKING CHANGE: Carbon no longer ships CommonJS or the esm/ directory. Use esm imports from
carbon-react/lib with an ESM-capable bundler. Replace any CommonJS specific syntax with an ESM
equivalent if available
Map existing lib directory imports to explicit entry files and emit Lodash
subpaths with .js extensions for Webpack 5. Rewrite relative declaration
imports after type emission so Node16 and NodeNext resolution can find them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants