Skip to content

chore: migrate from TS path aliases to workspaces + project references#774

Draft
layershifter wants to merge 4 commits into
microsoft:mainfrom
layershifter:chore/workspace-migration
Draft

chore: migrate from TS path aliases to workspaces + project references#774
layershifter wants to merge 4 commits into
microsoft:mainfrom
layershifter:chore/workspace-migration

Conversation

@layershifter
Copy link
Copy Markdown
Member

Summary

  • Replace 36 TypeScript path aliases in tsconfig.base.json with Yarn workspaces + TypeScript project references
  • Switch moduleResolution to "bundler" with customConditions: ["@griffel/source"] for source-level resolution
  • Enable composite builds with cross-project references in tsconfig files
  • Register @nx/js/typescript plugin to infer type-check targets automatically
  • Standardize all tsconfig files (consistent extends, rootDir, remove redundant options)
  • Add workspace:* dependencies for internal @griffel/* packages
  • Fix Vitest SSR environment conditions, devtools webpack build, vite-plugin test aliases
  • Add tag-processor/tsconfig.build.json for CJS output (wyw-in-js runtime evaluation)

CI status: type-check (22), build (13), test (17 non-e2e), lint (17) all pass.
E2e tests need follow-up for npm pack compatibility with new output paths.

Test plan

  • nx run-many -t type-check — all 22 projects pass
  • nx run-many -t build — all 13 projects pass
  • nx run-many -t test (excluding e2e) — all 17 projects pass
  • nx run-many -t lint — all 17 projects pass
  • E2e tests — need package.json in dist/ for npm pack

🤖 Generated with Claude Code

@layershifter layershifter requested a review from a team as a code owner March 5, 2026 16:53
@layershifter layershifter force-pushed the chore/workspace-migration branch from 0e4468d to 953c290 Compare March 6, 2026 09:08
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 6, 2026

📊 Bundle size report

✅ No changes found

@layershifter layershifter force-pushed the chore/workspace-migration branch from 6c3e83b to 9bd737f Compare March 6, 2026 13:21
@layershifter layershifter reopened this Mar 6, 2026
@layershifter layershifter marked this pull request as draft March 6, 2026 15:48
@layershifter layershifter force-pushed the chore/workspace-migration branch from 9bd737f to e92975d Compare March 9, 2026 14:21
layershifter and others added 4 commits May 7, 2026 20:54
Per https://nx.dev/docs/technologies/typescript/guides/switch-to-workspaces-project-references.

- tsconfig.base.json: composite, moduleResolution: bundler, customConditions
  ["@griffel/source"], declarationMap, isolatedModules. Drop paths/baseUrl/rootDir.
- Root tsconfig.json with project references to every package.
- Per-package tsconfig.lib.json: extends base directly, outDir: ./dist,
  rootDir: ./src. Cross-package references added via `nx sync`.
- Per-package tsconfig.spec.json: extends base, outDir: ./out-tsc/spec,
  references its tsconfig.lib.json (avoids TS6307).
- @nx/js/typescript plugin in nx.json infers type-check target.
- Drop explicit type-check targets from project.json files.
- Add apps/* to root workspaces.
- All package.json: add @griffel/source export condition pointing to source TS;
  convert internal @griffel/* deps to workspace:*.

CJS packages (babel-preset, jest-serializer, postcss-syntax, webpack-loader,
webpack-extraction-plugin, style-types) keep CJS output via separate
tsconfig.build.json; their tsconfig.lib.json is typecheck-only with
emitDeclarationOnly + module: bundler (avoids TS1479 across package boundary).

Type-check passes for all 20 projects. Build still fails for the three CJS
packages that import @griffel/core (ESM) — needs follow-up: either convert
them to ESM, or split exports so the require condition has its own types
field pointing to a .d.cts file emitted alongside ./lib/index.cjs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Build outputs now land at packages/X/dist/ (workspace-relative) instead
of dist/packages/X/. This means npm publish from packages/X/ works
without the beachball patch — to be removed once verified.

- Replace @nx/js:tsc with run-commands invoking tsc + tools/copy-pkg-assets.mjs
  so tsc's rootDir flattens src/ properly (the executor was preserving src/
  in output paths).
- Extend tools/build-cjs.mjs to also emit .d.cts alongside .cjs, so CJS
  consumers under moduleResolution: node16 see CJS-context type
  declarations via the require export condition.
- Dual packages (core/react/shadow-dom): build target chains _build_tsc
  → build-cjs so consumers' ^build picks up the .cjs output.
- exports.require gets per-condition types (./dist/cjs/index.d.cts).
- Add files: ["dist/", README, LICENSE] to every published package.json.
- Add resolve.conditions: ["@griffel/source"] to every vitest.config so
  vitest picks up the source-resolution path during tests.

Status:
- type-check ✅ 20/20
- lint ✅ 15/15 (pre-existing warnings only)
- build ✅ 15/15
- test ✅ 15/17, 2 inline-snapshot mismatches in transform/webpack-plugin
  VM-error-trace tests (formatting diff, just need snapshot update)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Stack frame format gained "Module." prefix on require.Object.assign.ensure
under the new resolution path. Functional behavior unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…cking

- Restore versioned ranges (^X.Y.Z) for internal @griffel/* dependencies
  in publishable packages. Workspace:* breaks npm pack — yarn rewrites
  it at publish time but npm pack does not, leaving "workspace:*"
  literally in the .tgz package.json. Yarn workspaces still resolve
  ^X.Y.Z to the local package when the version matches, so dev mode
  is unaffected.
- e2e/* and tools/update-shorthands devDependencies stay workspace:*
  (not published).
- Update e2e/utils/src/packLocalPackage.ts to look at packages/X/ as
  the package root (npm pack from there picks up dist/ via the files
  field). Old code pointed at dist/packages/X which no longer exists
  with per-package dist/.
- Switch types fields back to ./dist/index.d.ts (and .d.mts where
  applicable). Per-condition types in exports.require still point at
  ./dist/cjs/index.d.cts. The @griffel/source condition (TS) and
  vitest's resolve.conditions still resolve to source TS in dev/test.

All targets pass for 19/20 projects (e2e/rspack fails the same way on
main — pre-existing, not migration-related).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@layershifter layershifter force-pushed the chore/workspace-migration branch from e92975d to 905f100 Compare May 7, 2026 19:16
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.

1 participant