Skip to content

refactor(env): move runtime env setup to packages#11039

Merged
asturur merged 3 commits into
masterfrom
codex/refactor-env-ownership
Jul 7, 2026
Merged

refactor(env): move runtime env setup to packages#11039
asturur merged 3 commits into
masterfrom
codex/refactor-env-ownership

Conversation

@asturur

@asturur asturur commented Jul 7, 2026

Copy link
Copy Markdown
Member

Refactors Fabric environment setup so the core package owns only the environment holder, types, and setter/getter APIs, while the browser and node packages own their runtime-specific environment implementations.

The PR is small on purpose.
This PR is not moving core files yet and so imports from @fabric/node to src are still relative.

Key changes:

  • Add setEnvFactory to the core env holder and remove browser/node runtime imports from src/env.
  • Move browser env setup into packages/browser/src/env.ts and install it lazily from browser/root browser entrypoints.
  • Move node env setup and NodeGLProbe into packages/node/src, keeping @fabricjs/node and fabric/node responsible for jsdom/canvas.
  • Stage @fabricjs/core from a neutral core bundle so the published core package does not include runtime env implementations.
  • Update generated root dist artifacts and the package changelog.

Validation:

  • npm run lint passes, with existing warnings.
  • npm run prettier:check is blocked locally by unrelated untracked e2e/ report files; the PR files pass oxfmt --check.
  • tsc -p ./tsconfig.build.json --noEmit
  • tsc -p ./tsconfig-extensions.json --noEmit
  • tsc -p ./tsconfig.packages.json --noEmit
  • node ./scripts/package-smoke.mjs
  • rg "jsdom|from 'canvas'|src/env/node|NodeGLProbe" packages/core src/env
  • Browser package import smoke without global window/document

@codesandbox

codesandbox Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Build Stats

file / KB (diff) bundled minified
fabric 774.150 (+0.022) 293.676 (+0.275)

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

=============================== Coverage summary ===============================
Statements   : 79.92% ( 8047/10068 )
Branches     : 76.87% ( 4331/5634 )
Functions    : 85.53% ( 1526/1784 )
Lines        : 79.91% ( 7867/9844 )
================================================================================

@sonarqubecloud

sonarqubecloud Bot commented Jul 7, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
50.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@Smrtnyk

Smrtnyk commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

we should also at one point move jsdom dep to the node subpackage, i guess that comes later?

@asturur

asturur commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

we should also at one point move jsdom dep to the node subpackage, i guess that comes later?

I m following a plan step by step to avoid doing mess, but yes, the idea at the end is total separation for node and browser. As soon as i can do that 'fabric/node' is jut a re-export of @fabricjs/node, then i can move them.

fabric package will still be requiring those, but it will be a legacy pacakge. if you install @fabricjs/browser in theory you won't have any node dep in your logs.

@asturur

asturur commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

Ok since you approved i move to next step right away.

@asturur
asturur merged commit e4d5718 into master Jul 7, 2026
16 checks passed
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.

2 participants