Repository navigation
feat: drop react 17 support & publish esm only - #8314
tomdavies73 wants to merge 7 commits into
Conversation
There was a problem hiding this comment.
🟡 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
package-lock.json: Excluded by your content exclusion settingsskills/carbon-react/references/docs/installation.md: Excluded by your content exclusion settings
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/
esmoutputs. - 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
a23a78e to
a7de795
Compare
There was a problem hiding this comment.
🟡 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
package-lock.json: Excluded by your content exclusion settingsskills/carbon-react/references/docs/installation.md: Excluded by your content exclusion settings
Review effort: Balanced
There was a problem hiding this comment.
🔵 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
package-lock.json: Excluded by your content exclusion settingsskills/carbon-react/references/docs/installation.md: Excluded by your content exclusion settings
Review effort: Balanced
There was a problem hiding this comment.
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.
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.
d7958b6 to
577d6ee
Compare



Proposed behaviour
Drops support for react v
17now only react v18is supported.Also now drops support for
commonJSpublishing and supportsesmonly, the/esm/path will also be removed with/lib/taking priority as it is widely used import path by consumers.Internal
commonJSusage 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-tbscommits, if we feel they're unneeded and additional complexity we can drop.Current behaviour
Currently, we support react v
17andcommonJSpublish. Both are either out of support or not the industry standard, we need to remove to maintain package health.Checklist
d.tsfile added or updated if requiredQA
Additional context
Testing instructions