chore: migrate from TS path aliases to workspaces + project references#774
Draft
layershifter wants to merge 4 commits into
Draft
chore: migrate from TS path aliases to workspaces + project references#774layershifter wants to merge 4 commits into
layershifter wants to merge 4 commits into
Conversation
0e4468d to
953c290
Compare
Contributor
📊 Bundle size report✅ No changes found |
6c3e83b to
9bd737f
Compare
4 tasks
9bd737f to
e92975d
Compare
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>
e92975d to
905f100
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tsconfig.base.jsonwith Yarn workspaces + TypeScript project referencesmoduleResolutionto"bundler"withcustomConditions: ["@griffel/source"]for source-level resolutioncompositebuilds with cross-projectreferencesin tsconfig files@nx/js/typescriptplugin to infertype-checktargets automaticallyextends,rootDir, remove redundant options)workspace:*dependencies for internal@griffel/*packagestag-processor/tsconfig.build.jsonfor 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 packcompatibility with new output paths.Test plan
nx run-many -t type-check— all 22 projects passnx run-many -t build— all 13 projects passnx run-many -t test(excluding e2e) — all 17 projects passnx run-many -t lint— all 17 projects passpackage.jsonindist/fornpm pack🤖 Generated with Claude Code