No shared global state
No module-level mutable singletons — state injects at app entry so domains can run standalone.
nx-isolation-deps-no-global-state
Why it matters
| Stake | If ignored |
|---|---|
| Hidden coupling |
|
| Can't run alone |
|
How to fix
No singletons holding cross-domain state. No global store every app writes to. If two domains need the same data, one owns it and the other receives it via the public contract.
Examples
ts
// libs/shared/state/src/lib/global-store.ts
export const globalStore = {
currentUser: null,
currentSite: null,
activeWorkflow: null,
isDevMode: false,
};ts
// libs/workspace/feature-workflow-builder/src/lib/workflow-runner.ts
type RunWorkflowOptions = { workflow: Workflow; devMode: boolean };
export function runWorkflow({ workflow, devMode }: RunWorkflowOptions) {
if (devMode) { /* ... */ }
return workflow.run();
}
// apps/workspace/src/main.tsx — composing layer
const user = await usersApi.getCurrent();
const site = await sitesApi.get(siteId);
runWorkflow({ workflow: site.workflow, devMode: user.preferences.devMode });