feat(build): OHIF_ENV build profiles, out-of-tree pluginConfig.json, and a customization index - #6197
feat(build): OHIF_ENV build profiles, out-of-tree pluginConfig.json, and a customization index#6197wayfarer3130 wants to merge 2 commits into
OHIF_ENV build profiles, out-of-tree pluginConfig.json, and a customization index#6197Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
feat(build):
OHIF_ENVbuild profiles, out-of-treepluginConfig.json, and a customization indexStacked on top of #6168 — base branch is
ohifNextExtensions, notohifReact. These twocommits were originally part of that PR and have been split out to keep the extensibility
contract PR reviewable on its own. Merge #6168 first.
Why
#6168 makes extensions and modes loadable, but the build was still hard-wired to files inside
this repo: the plugin set came from
platform/app/pluginConfig.json, and every build variant wasanother
cross-env A=1 B=2 rsbuild buildline inplatform/app/package.json. A downstreamdeployment had to edit files it does not own — i.e. fork — just to compile in its own plugins or
serve from its own route. That fork then pays a merge cost on every OHIF release.
This PR removes that requirement. Nothing about the default build changes.
What
1. Build profiles —
OHIF_ENV=./ohif.config.jsonOne committed JSON file supplies the defaults for the build's environment variables
(
PLUGIN_CONFIG,APP_CONFIG,PUBLIC_URL,HTML_TEMPLATE,ENTRY_TARGET, and the dev-serverproxy vars):
still overridden for a single CI job (
OHIF_ENV=./profiles/hospital.json PUBLIC_URL=/staging/ …).publicUrlpatternsfail the build naming the offending key. Constraints are read out of the schema
(
.rspack/schemaConstraints.js) rather than retyped, which is the drift class the existingparity test was written to catch.
.rspack/loadBuildProfile.jsis CJS and memoized:rsbuild.config.ts,writePluginImportsFile.js(whichplatform/app/tailwind.config.jsalso loads), andscripts/ohif-plugin.mjsall go through it, so whichever runs first applies the profile and therest are no-ops. All three therefore agree on which config the build is using.
2.
pluginConfig.jsonyou own, outside this repoPLUGIN_CONFIG(or a profile'spluginConfig) now redirects the build, Tailwind's content globs,and every
pnpm run pluginsubcommand at the same config file — soplugin addcan no longer edita file the build ignores.
A new optional
"root"key inpluginConfig.schema.jsonlets an out-of-tree config keep shortrelative paths:
./-relativedirectoryvalues and its ownextensions//modes/foldersresolve against its tree, while OHIF's in-tree plugins keep resolving inside the checkout
(nearest root first, so a workspace's
extensions/<name>shadows a same-named one in the harness).Omitting
rootpreserves the historical meaning exactly — no existing config changes behavior.APP_CONFIGnow also accepts an absolute path, which is how a./-prefixed profileappConfiglets a deployment keep its app config in its own repo.
3. The
create-ohifworkspace checkout is now read-onlyohif.config.jsonis both the committed manifest and the build profile.harness ensurederives agitignored
pluginConfig.generated.jsonin the workspace and passes it asPLUGIN_CONFIG;the app config is no longer copied into
.ohif/. Nothing is written inside the checkout, so it canbe deleted and recreated at any time — and upgrading the pin picks up the new version's default
plugin set for free, because the generated file is rebuilt on top of whatever the fresh checkout
ships.
4. Schemas are published, not repo-internal
ohif.schema.jsonmoved toplatform/app/, and both it andpluginConfig.schema.jsonare added to@ohif/app'sfiles. A downstream repo can point$schemaat./node_modules/@ohif/app/ohif.schema.jsonand get completion and validation in its editor.5.
CUSTOMIZING.mdAn index of every supported customization mechanism, ordered by cost, against the build procedure
each implies — plus a "files you should not edit, and what to do instead" table and a section aimed
at coding agents. The rule it exists to enforce: you should never have to modify a file inside this
repo to ship a customized viewer. Linked from
AGENTS.md, with reference docs inplatform/docs/docs/configuration/build-profiles.md.Testing
platform/app/src/__tests__/buildProfile.test.js— profile resolution, env-var precedence,path resolution (
truevs'dot'), validation failures, and which config/root the build ends upwith.
platform/create-ohif/tests/scaffold.test.mjsupdated for the generated-config harness flow.pluginConfigSchemaParity.test.jsstill guards the hand-rolled validator against theschema.
Compatibility
Additive. With no
OHIF_ENVand noPLUGIN_CONFIG, the build readsplatform/app/pluginConfig.jsonand resolvesdirectoryvalues against the repo root exactly asbefore;
"root"is optional and unset in the shipped config.