Skip to content

fix(packaging)!: make the component library consumable outside the monorepo - #496

Merged
aldbr merged 1 commit into
DIRACGrid:mainfrom
aldbr:split/2-packaging
Jul 14, 2026
Merged

fix(packaging)!: make the component library consumable outside the monorepo#496
aldbr merged 1 commit into
DIRACGrid:mainfrom
aldbr:split/2-packaging

Conversation

@aldbr

@aldbr aldbr commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Part of #494 (stack 2/5). Stacked on #495 — until it merges, review the last commit only (fix(packaging)!).

Makes @dirac-grid/diracx-web-components consumable outside this monorepo:

  • peerDependencies: react, react-dom, @mui/material, @mui/icons-material, @emotion/*, @axa-fr/react-oidc, swr move from hard dependencies to peers (still in devDependencies for local dev/tests). Prevents duplicate React/emotion instances ("Invalid hook call", broken styles) and a duplicated oidc module with silently broken auth state.
  • exports map: adds the missing "." root entry (bare package import currently throws ERR_PACKAGE_PATH_NOT_EXPORTED), orders types first in every condition block, deletes the stale per-directory package.json stubs pointing at nonexistent .cjs files.
  • sideEffects set to a scoped array (["**/*.css", "**/SearchBar/DatePicker.*"]) so bundlers can tree-shake while preserving the side-effectful dayjs/locale/en-gb import in DatePicker (makes the lazy @mui/x-charts split actually effective downstream).
  • verify-dist build guard: validates every exports path against the actual tsup output on each build.
  • removes Next.js runtime coupling: the two next/image imports (Next.js was never a declared dependency) become plain <img>; the process.env read is guarded for non-Next bundlers.
  • introduces the framework-agnostic services/fetcher HTTP client module (consumed by later PRs in the stack).
  • misc bundled here: engines field, .nvmrc, test:coverage script, devDeps used by later stack PRs.

BREAKING CHANGE: consumers must install the peer dependencies themselves; the library no longer ships React/MUI/emotion/oidc as its own dependencies.

🤖 Generated with Claude Code

…norepo

Restructure @dirac-grid/diracx-web-components packaging so the library
works when installed from npm outside this monorepo:

- move host-provided packages (react, react-dom, MUI core, emotion,
  @axa-fr/react-oidc, swr) from dependencies to peerDependencies and
  mirror them in devDependencies for local dev/test
- add a proper exports map with a root "." entry (types-first) plus a
  new ./services entry; add sideEffects: false and engines.node >= 22
- drop the legacy src/{components,contexts,hooks,types}/package.json
  stub files (superseded by the exports map)
- add scripts/verify-dist.mjs to the build to fail fast when tsup
  output stops matching package.json#exports
- add a framework-agnostic services/fetcher HTTP client module
  (exported via ./services; root re-export lands with the consumer
  migration) and guard process.env access in useDiracxUrl so non-Next
  bundlers don't throw
- remove next/image usage from LoginForm and DashboardDrawer (plain
  <img>) so the library no longer requires Next.js; LoginForm gains a
  skeleton loading state and an error Alert
- pin Node >= 22 at the root (engines + .nvmrc); react-virtuoso stays
  a direct dependency until the DataTable rewrite lands

BREAKING CHANGE: react, react-dom, @mui/material, @mui/icons-material,
@emotion/react, @emotion/styled, @axa-fr/react-oidc and swr are now
peerDependencies and must be installed by the consuming application.
Deep imports that relied on the removed per-directory package.json
stubs must use the documented subpath exports instead.
@aldbr
aldbr force-pushed the split/2-packaging branch from d3222a7 to ac45d1c Compare July 14, 2026 13:59
@aldbr
aldbr requested a review from ryuwd July 14, 2026 15:42

@ryuwd ryuwd left a comment

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.

LGTM

@aldbr
aldbr merged commit 6cd3e80 into DIRACGrid:main Jul 14, 2026
64 of 71 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 14, 2026
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.

Quality pass: library packaging, Job Monitor performance, state correctness, test coverage

2 participants