From ec002ce845ceee3739a751e68e5a680dd89a9df2 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Thu, 21 May 2026 11:47:37 +0200 Subject: [PATCH 01/26] chore: migrate from TS path aliases to workspaces + project references Squash-rebase of the earlier 4-commit migration onto current main. The migration replaces TS path aliases with yarn workspaces + project references and a custom `@griffel/source` exports condition, switches tsconfig.base.json to `moduleResolution: bundler` with composite builds, registers `@nx/js/typescript` for inferred type-check targets, moves each package's build output to `packages/X/dist`, and dual-emits ESM + CJS via `tools/build-cjs.mjs` for the three runtime-dual packages. Versions and dep ranges follow current main (post-`10b7b8f3`); the publishable packages' internal deps stay as `^X.Y.Z` so `npm pack` survives without yarn's workspace-protocol rewriting. Co-Authored-By: Claude Opus 4.7 (1M context) --- .gitignore | 4 +- apps/website/project.json | 20 +++--- apps/website/tsconfig.json | 12 +++- e2e/eslint/package.json | 7 ++- e2e/eslint/project.json | 21 ++++--- e2e/eslint/tsconfig.json | 8 --- e2e/eslint/tsconfig.lib.json | 22 +++++-- e2e/rspack/project.json | 24 +++---- e2e/rspack/tsconfig.json | 10 --- e2e/rspack/tsconfig.lib.json | 27 +++++++- e2e/typescript/package.json | 6 +- e2e/typescript/project.json | 21 ++++--- e2e/typescript/tsconfig.json | 8 --- e2e/typescript/tsconfig.lib.json | 18 +++++- e2e/utils/package.json | 7 ++- e2e/utils/project.json | 11 +--- e2e/utils/src/packLocalPackage.ts | 9 +-- e2e/utils/tsconfig.json | 8 --- e2e/utils/tsconfig.lib.json | 10 ++- nx.json | 15 ++++- package.json | 1 + packages/babel-preset/package.json | 18 +++++- packages/babel-preset/project.json | 31 ++------- packages/babel-preset/tsconfig.build.json | 20 ++++++ packages/babel-preset/tsconfig.json | 4 -- packages/babel-preset/tsconfig.lib.json | 20 ++++-- packages/babel-preset/tsconfig.spec.json | 28 +++++---- packages/babel-preset/vitest.config.mts | 2 + packages/core/package.json | 24 ++++--- packages/core/project.json | 38 +++-------- packages/core/tsconfig.json | 5 -- packages/core/tsconfig.lib.json | 29 +++------ packages/core/tsconfig.spec.json | 19 +++--- packages/core/vitest.config.ts | 2 + packages/devtools/project.json | 12 ---- packages/devtools/tsconfig.json | 3 - packages/devtools/tsconfig.lib.json | 23 ++++--- packages/devtools/tsconfig.spec.json | 18 +++--- packages/devtools/tsconfig.storybook.json | 3 +- packages/eslint-plugin/package.json | 18 +++++- packages/eslint-plugin/project.json | 33 +++------- packages/eslint-plugin/tsconfig.json | 5 -- packages/eslint-plugin/tsconfig.lib.json | 10 +-- packages/eslint-plugin/tsconfig.spec.json | 23 ++++--- packages/eslint-plugin/vitest.config.mts | 2 + packages/jest-serializer/package.json | 18 +++++- packages/jest-serializer/project.json | 31 ++------- packages/jest-serializer/tsconfig.build.json | 20 ++++++ packages/jest-serializer/tsconfig.json | 4 -- packages/jest-serializer/tsconfig.lib.json | 20 ++++-- packages/jest-serializer/tsconfig.spec.json | 26 ++++---- packages/jest-serializer/vitest.config.mts | 2 + packages/postcss-syntax/package.json | 17 ++++- packages/postcss-syntax/project.json | 33 +++------- packages/postcss-syntax/tsconfig.json | 3 - packages/postcss-syntax/tsconfig.lib.json | 18 ++++-- packages/postcss-syntax/tsconfig.spec.json | 22 ++++--- packages/postcss-syntax/vitest.config.mts | 2 + packages/react/package.json | 24 ++++--- packages/react/project.json | 38 +++-------- packages/react/tsconfig.json | 7 --- packages/react/tsconfig.lib.json | 30 ++++----- packages/react/tsconfig.spec.json | 24 +++---- packages/react/tsconfig.storybook.json | 3 +- packages/react/vitest.config.ts | 2 + packages/shadow-dom/package.json | 24 ++++--- packages/shadow-dom/project.json | 39 +++--------- packages/shadow-dom/tsconfig.json | 8 --- packages/shadow-dom/tsconfig.lib.json | 32 +++++----- packages/shadow-dom/tsconfig.spec.json | 23 ++++--- packages/shadow-dom/tsconfig.storybook.json | 3 +- packages/shadow-dom/vitest.config.ts | 2 + packages/style-types/package.json | 17 ++++- packages/style-types/project.json | 35 +++-------- packages/style-types/tsconfig.json | 8 +-- packages/style-types/tsconfig.lib.json | 22 +++---- packages/style-types/tsconfig.spec.json | 22 +++++++ packages/transform-shaker/package.json | 17 +++-- packages/transform-shaker/project.json | 31 ++------- packages/transform-shaker/tsconfig.json | 6 -- packages/transform-shaker/tsconfig.lib.json | 31 ++------- packages/transform-shaker/tsconfig.spec.json | 32 +++++----- packages/transform-shaker/vitest.config.mts | 2 + packages/transform/package.json | 17 +++-- packages/transform/project.json | 31 ++------- .../transform/src/evaluation/module.test.mts | 2 +- packages/transform/tsconfig.json | 6 -- packages/transform/tsconfig.lib.json | 41 +++++------- packages/transform/tsconfig.spec.json | 30 +++++---- packages/transform/vitest.config.mts | 2 + .../webpack-extraction-plugin/package.json | 18 +++++- .../webpack-extraction-plugin/project.json | 36 ++--------- .../tsconfig.build.json | 20 ++++++ .../webpack-extraction-plugin/tsconfig.json | 5 -- .../tsconfig.lib.json | 20 ++++-- .../tsconfig.spec.json | 26 ++++---- .../vitest.config.mts | 2 + packages/webpack-loader/package.json | 18 +++++- packages/webpack-loader/project.json | 31 ++------- packages/webpack-loader/tsconfig.json | 4 -- packages/webpack-loader/tsconfig.lib.json | 21 +++++-- packages/webpack-loader/tsconfig.spec.json | 24 +++---- packages/webpack-loader/vitest.config.mts | 2 + packages/webpack-plugin/package.json | 22 ++++--- packages/webpack-plugin/project.json | 36 ++--------- .../webpack-plugin/src/GriffelPlugin.test.mts | 2 +- packages/webpack-plugin/tsconfig.json | 5 -- packages/webpack-plugin/tsconfig.lib.json | 45 ++++++------- packages/webpack-plugin/tsconfig.spec.json | 36 ++++++----- packages/webpack-plugin/vitest.config.mts | 2 + tools/build-cjs.mjs | 30 +++++++-- tools/copy-pkg-assets.mjs | 33 ++++++++++ tools/deprecate-broken-release.mjs | 58 +++++++++++++++++ tools/update-shorthands/package.json | 6 +- tools/update-shorthands/project.json | 12 ---- tools/update-shorthands/tsconfig.json | 9 --- tools/update-shorthands/tsconfig.lib.json | 19 ++++-- tools/update-shorthands/tsconfig.spec.json | 29 ++++----- tsconfig.base.json | 30 ++------- tsconfig.json | 63 +++++++++++++++++++ yarn.lock | 26 ++++++-- 121 files changed, 1156 insertions(+), 1020 deletions(-) create mode 100644 packages/babel-preset/tsconfig.build.json create mode 100644 packages/jest-serializer/tsconfig.build.json create mode 100644 packages/style-types/tsconfig.spec.json create mode 100644 packages/webpack-extraction-plugin/tsconfig.build.json create mode 100644 tools/copy-pkg-assets.mjs create mode 100644 tools/deprecate-broken-release.mjs create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore index 7442e52f9..40ec071f4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,9 @@ # See http://help.github.com/ignore-files/ for more about ignoring files. # compiled output -/dist +dist /tmp -/out-tsc +out-tsc /packages/*/dist/bundle-size # TypeScript build info diff --git a/apps/website/project.json b/apps/website/project.json index 900cb48da..83b1ff447 100644 --- a/apps/website/project.json +++ b/apps/website/project.json @@ -8,7 +8,11 @@ "executor": "nx:run-commands", "options": { "cwd": "apps/website", - "commands": [{ "command": "docusaurus build --out-dir ../../dist/apps/website" }] + "commands": [ + { + "command": "docusaurus build --out-dir ../../dist/apps/website" + } + ] }, "outputs": ["{workspaceRoot}/dist/apps/website"] }, @@ -16,15 +20,11 @@ "executor": "nx:run-commands", "options": { "cwd": "apps/website", - "commands": [{ "command": "docusaurus start" }] - } - }, - "type-check": { - "executor": "nx:run-commands", - "options": { - "cwd": "apps/website", - "commands": [{ "command": "tsc -b --pretty" }], - "outputPath": [] + "commands": [ + { + "command": "docusaurus start" + } + ] } } }, diff --git a/apps/website/tsconfig.json b/apps/website/tsconfig.json index 31be612bb..4db04bcb7 100644 --- a/apps/website/tsconfig.json +++ b/apps/website/tsconfig.json @@ -6,14 +6,20 @@ "checkJs": true, "jsx": "react", "noEmit": true, - "outDir": "../../dist/out-tsc", + "outDir": "./out-tsc", "types": [ "../../node_modules/@docusaurus/module-type-aliases", "../../node_modules/@docusaurus/theme-classic", "environment", "static-assets", "webpack-env" - ] + ], + "composite": false }, - "include": ["./src/**/*.ts", "./src/**/*.tsx", "./src/**/*.js"] + "include": ["./src/**/*.ts", "./src/**/*.tsx", "./src/**/*.js"], + "references": [ + { + "path": "../../packages/core" + } + ] } diff --git a/e2e/eslint/package.json b/e2e/eslint/package.json index 4f3194f1e..65c2d105d 100644 --- a/e2e/eslint/package.json +++ b/e2e/eslint/package.json @@ -2,5 +2,10 @@ "name": "@griffel/e2e-eslint", "version": "0.0.0", "private": true, - "type": "module" + "type": "module", + "devDependencies": { + "@griffel/e2e-utils": "workspace:*", + "@griffel/eslint-plugin": "workspace:*", + "@griffel/react": "workspace:*" + } } diff --git a/e2e/eslint/project.json b/e2e/eslint/project.json index f8e12f007..28bc52550 100644 --- a/e2e/eslint/project.json +++ b/e2e/eslint/project.json @@ -7,20 +7,21 @@ "targets": { "test": { "executor": "nx:run-commands", - "dependsOn": [{ "target": "build", "dependencies": true }], + "dependsOn": [ + { + "target": "build", + "dependencies": true + } + ], "options": { "cwd": "e2e/eslint", - "commands": [{ "command": "node src/test.ts" }] + "commands": [ + { + "command": "node src/test.ts" + } + ] }, "outputs": [] - }, - "type-check": { - "executor": "nx:run-commands", - "options": { - "cwd": "e2e/eslint", - "commands": [{ "command": "tsc -b --pretty" }], - "outputPath": [] - } } }, "tags": [] diff --git a/e2e/eslint/tsconfig.json b/e2e/eslint/tsconfig.json index 1f8121e7c..c23e61c80 100644 --- a/e2e/eslint/tsconfig.json +++ b/e2e/eslint/tsconfig.json @@ -1,13 +1,5 @@ { "extends": "../../tsconfig.base.json", - "compilerOptions": { - "allowJs": true, - "checkJs": true, - "module": "nodenext", - "moduleResolution": "nodenext", - "allowImportingTsExtensions": true, - "noEmit": true - }, "files": [], "include": [], "references": [ diff --git a/e2e/eslint/tsconfig.lib.json b/e2e/eslint/tsconfig.lib.json index a1a9a85ca..c00c175e7 100644 --- a/e2e/eslint/tsconfig.lib.json +++ b/e2e/eslint/tsconfig.lib.json @@ -1,9 +1,23 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "module": "nodenext", + "moduleResolution": "nodenext", + "allowImportingTsExtensions": true, + "emitDeclarationOnly": true, + "outDir": "./dist", "types": ["node", "environment"] }, - "include": ["**/*.ts", "**/*.js"], - "exclude": ["src/assets"] + "include": ["src/**/*.ts", "src/**/*.tsx"], + "references": [ + { + "path": "../../packages/react/tsconfig.lib.json" + }, + { + "path": "../../packages/eslint-plugin/tsconfig.lib.json" + }, + { + "path": "../utils/tsconfig.lib.json" + } + ] } diff --git a/e2e/rspack/project.json b/e2e/rspack/project.json index 9debfe8c6..fb485245c 100644 --- a/e2e/rspack/project.json +++ b/e2e/rspack/project.json @@ -7,23 +7,25 @@ "test": { "executor": "nx:run-commands", "dependsOn": [ - { "target": "build", "dependencies": true }, - { "target": "build-cjs", "dependencies": true } + { + "target": "build", + "dependencies": true + }, + { + "target": "build-cjs", + "dependencies": true + } ], "options": { "cwd": "e2e/rspack", - "commands": [{ "command": "node src/test.ts" }] + "commands": [ + { + "command": "node src/test.ts" + } + ] }, "outputs": [] }, - "type-check": { - "executor": "nx:run-commands", - "options": { - "cwd": "e2e/rspack", - "commands": [{ "command": "tsc -b --pretty" }], - "outputPath": [] - } - }, "lint": { "executor": "@nx/eslint:lint", "outputs": ["{options.outputFile}"] diff --git a/e2e/rspack/tsconfig.json b/e2e/rspack/tsconfig.json index 9718d1d60..c23e61c80 100644 --- a/e2e/rspack/tsconfig.json +++ b/e2e/rspack/tsconfig.json @@ -1,15 +1,5 @@ { "extends": "../../tsconfig.base.json", - "compilerOptions": { - "allowJs": true, - "checkJs": true, - "target": "es2020", - "module": "nodenext", - "moduleResolution": "nodenext", - "allowImportingTsExtensions": true, - "jsx": "react-jsx", - "noEmit": true - }, "files": [], "include": [], "references": [ diff --git a/e2e/rspack/tsconfig.lib.json b/e2e/rspack/tsconfig.lib.json index 62c8b285f..a7985d35a 100644 --- a/e2e/rspack/tsconfig.lib.json +++ b/e2e/rspack/tsconfig.lib.json @@ -1,8 +1,29 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "module": "nodenext", + "moduleResolution": "nodenext", + "allowImportingTsExtensions": true, + "emitDeclarationOnly": true, + "outDir": "./dist", "types": ["node", "environment", "static-assets"] }, - "include": ["**/*.ts", "**/*.tsx", "**/*.js"] + "include": ["src/**/*.ts", "src/**/*.tsx"], + "references": [ + { + "path": "../../packages/webpack-plugin/tsconfig.lib.json" + }, + { + "path": "../../packages/webpack-loader/tsconfig.lib.json" + }, + { + "path": "../../packages/webpack-extraction-plugin/tsconfig.lib.json" + }, + { + "path": "../../packages/react/tsconfig.lib.json" + }, + { + "path": "../utils/tsconfig.lib.json" + } + ] } diff --git a/e2e/typescript/package.json b/e2e/typescript/package.json index 3946842ab..3a4027bd4 100644 --- a/e2e/typescript/package.json +++ b/e2e/typescript/package.json @@ -2,5 +2,9 @@ "name": "@griffel/e2e-typescript", "version": "0.0.0", "private": true, - "type": "module" + "type": "module", + "devDependencies": { + "@griffel/e2e-utils": "workspace:*", + "@griffel/style-types": "workspace:*" + } } diff --git a/e2e/typescript/project.json b/e2e/typescript/project.json index 4bab732f8..a490f6a9a 100644 --- a/e2e/typescript/project.json +++ b/e2e/typescript/project.json @@ -6,20 +6,21 @@ "targets": { "test": { "executor": "nx:run-commands", - "dependsOn": [{ "target": "build", "dependencies": true }], + "dependsOn": [ + { + "target": "build", + "dependencies": true + } + ], "options": { "cwd": "e2e/typescript", - "commands": [{ "command": "node src/test.ts" }] + "commands": [ + { + "command": "node src/test.ts" + } + ] }, "outputs": [] - }, - "type-check": { - "executor": "nx:run-commands", - "options": { - "cwd": "e2e/typescript", - "commands": [{ "command": "tsc -b --pretty" }], - "outputPath": [] - } } }, "tags": [] diff --git a/e2e/typescript/tsconfig.json b/e2e/typescript/tsconfig.json index 1f8121e7c..c23e61c80 100644 --- a/e2e/typescript/tsconfig.json +++ b/e2e/typescript/tsconfig.json @@ -1,13 +1,5 @@ { "extends": "../../tsconfig.base.json", - "compilerOptions": { - "allowJs": true, - "checkJs": true, - "module": "nodenext", - "moduleResolution": "nodenext", - "allowImportingTsExtensions": true, - "noEmit": true - }, "files": [], "include": [], "references": [ diff --git a/e2e/typescript/tsconfig.lib.json b/e2e/typescript/tsconfig.lib.json index 0893e0a68..9bfdd7d09 100644 --- a/e2e/typescript/tsconfig.lib.json +++ b/e2e/typescript/tsconfig.lib.json @@ -1,8 +1,20 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "module": "nodenext", + "moduleResolution": "nodenext", + "allowImportingTsExtensions": true, + "emitDeclarationOnly": true, + "outDir": "./dist", "types": ["node", "environment"] }, - "include": ["**/*.ts", "**/*.js"] + "include": ["src/**/*.ts", "src/**/*.tsx"], + "references": [ + { + "path": "../../packages/style-types/tsconfig.lib.json" + }, + { + "path": "../utils/tsconfig.lib.json" + } + ] } diff --git a/e2e/utils/package.json b/e2e/utils/package.json index 38ee26cdf..99b33930f 100644 --- a/e2e/utils/package.json +++ b/e2e/utils/package.json @@ -4,6 +4,11 @@ "private": true, "type": "module", "exports": { - ".": "./src/index.ts" + ".": { + "@griffel/source": "./src/index.ts", + "types": "./src/index.ts", + "default": "./src/index.ts" + }, + "./package.json": "./package.json" } } diff --git a/e2e/utils/project.json b/e2e/utils/project.json index efc02b00a..80cb74844 100644 --- a/e2e/utils/project.json +++ b/e2e/utils/project.json @@ -3,15 +3,6 @@ "$schema": "../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "e2e/utils/src", "projectType": "library", - "targets": { - "type-check": { - "executor": "nx:run-commands", - "options": { - "cwd": "e2e/utils", - "commands": [{ "command": "tsc -b --pretty" }] - }, - "outputs": [] - } - }, + "targets": {}, "tags": [] } diff --git a/e2e/utils/src/packLocalPackage.ts b/e2e/utils/src/packLocalPackage.ts index 40d58fa37..474ea605e 100644 --- a/e2e/utils/src/packLocalPackage.ts +++ b/e2e/utils/src/packLocalPackage.ts @@ -4,11 +4,12 @@ import fs from 'fs'; import { sh } from './sh.ts'; export async function packLocalPackage(rootDir: string, tempDir: string, packageName: string) { - const packagePath = path.resolve(rootDir, 'dist', 'packages', packageName.split('/')[1]); - const packagePathExists = !!(await fs.promises.stat(packagePath).catch(() => false)); + const packagePath = path.resolve(rootDir, 'packages', packageName.split('/')[1]); + const distPath = path.resolve(packagePath, 'dist'); + const distExists = !!(await fs.promises.stat(distPath).catch(() => false)); - if (!packagePathExists) { - throw new Error(`A directory with artifacts (${packagePath}) does not exist`); + if (!distExists) { + throw new Error(`Build artifacts not found at "${distPath}" — run "nx run ${packageName}:build" first`); } // Use `npm pack` because `yarn pack` incorrectly calculates the included files when the diff --git a/e2e/utils/tsconfig.json b/e2e/utils/tsconfig.json index 1f8121e7c..c23e61c80 100644 --- a/e2e/utils/tsconfig.json +++ b/e2e/utils/tsconfig.json @@ -1,13 +1,5 @@ { "extends": "../../tsconfig.base.json", - "compilerOptions": { - "allowJs": true, - "checkJs": true, - "module": "nodenext", - "moduleResolution": "nodenext", - "allowImportingTsExtensions": true, - "noEmit": true - }, "files": [], "include": [], "references": [ diff --git a/e2e/utils/tsconfig.lib.json b/e2e/utils/tsconfig.lib.json index 2954c1047..63bcbcc17 100644 --- a/e2e/utils/tsconfig.lib.json +++ b/e2e/utils/tsconfig.lib.json @@ -1,8 +1,12 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "module": "nodenext", + "moduleResolution": "nodenext", + "allowImportingTsExtensions": true, + "emitDeclarationOnly": true, + "outDir": "./dist", "types": ["node", "environment"] }, - "include": ["**/*.ts"] + "include": ["src/**/*.ts", "src/**/*.tsx"] } diff --git a/nx.json b/nx.json index a31352694..b0c3c2d2f 100644 --- a/nx.json +++ b/nx.json @@ -29,12 +29,25 @@ "inputs": ["default", "^default"] } }, + "plugins": [ + { + "plugin": "@nx/js/typescript", + "options": { + "typecheck": { + "targetName": "type-check" + } + } + } + ], "pluginsConfig": { "@nx/js": { "analyzeSourceFiles": true } }, - "useInferencePlugins": false, + "useInferencePlugins": true, + "sync": { + "applyChanges": true + }, "defaultBase": "main", "tui": { "enabled": false diff --git a/package.json b/package.json index ac3a5f028..cdbc3e11a 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "url": "https://github.com/microsoft/griffel" }, "workspaces": [ + "apps/*", "e2e/*", "packages/*", "tools/*" diff --git a/packages/babel-preset/package.json b/packages/babel-preset/package.json index 8f4d6e216..ab1eadb69 100644 --- a/packages/babel-preset/package.json +++ b/packages/babel-preset/package.json @@ -19,5 +19,21 @@ "ajv": "^8.20.0", "stylis": "^4.4.0", "tslib": "^2.1.0" - } + }, + "types": "./dist/index.d.ts", + "main": "./dist/index.js", + "exports": { + ".": { + "@griffel/source": "./src/index.ts", + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "./package.json": "./package.json" + }, + "files": [ + "dist/", + "README.md", + "LICENSE.md", + "CHANGELOG.md" + ] } diff --git a/packages/babel-preset/project.json b/packages/babel-preset/project.json index dfe0c2966..e2a39d86f 100644 --- a/packages/babel-preset/project.json +++ b/packages/babel-preset/project.json @@ -17,35 +17,16 @@ } }, "build": { - "executor": "@nx/js:tsc", - "outputs": ["{options.outputPath}"], - "options": { - "outputPath": "dist/packages/babel-preset", - "tsConfig": "packages/babel-preset/tsconfig.lib.json", - "skipTypeField": true, - "packageJson": "packages/babel-preset/package.json", - "main": "packages/babel-preset/src/index.ts", - "assets": [ - "packages/babel-preset/README.md", - { - "glob": "LICENSE.md", - "input": ".", - "output": "." - } - ] - } - }, - "type-check": { "executor": "nx:run-commands", + "outputs": ["{workspaceRoot}/packages/babel-preset/dist"], "options": { "cwd": "packages/babel-preset", "commands": [ - { - "command": "tsc -b --pretty" - } - ] - }, - "outputs": [] + "tsc --build tsconfig.lib.json --pretty", + "node ../../tools/copy-pkg-assets.mjs packages/babel-preset" + ], + "parallel": false + } } } } diff --git a/packages/babel-preset/tsconfig.build.json b/packages/babel-preset/tsconfig.build.json new file mode 100644 index 000000000..77ee22186 --- /dev/null +++ b/packages/babel-preset/tsconfig.build.json @@ -0,0 +1,20 @@ +{ + "extends": "./tsconfig.lib.json", + "compilerOptions": { + "composite": false, + "module": "node16", + "moduleResolution": "node16", + "customConditions": [], + "emitDeclarationOnly": false, + "declaration": true, + "outDir": "./dist" + }, + "references": [ + { + "path": "../core/tsconfig.lib.json" + }, + { + "path": "../react/tsconfig.lib.json" + } + ] +} diff --git a/packages/babel-preset/tsconfig.json b/packages/babel-preset/tsconfig.json index 915d41150..62ebbd946 100644 --- a/packages/babel-preset/tsconfig.json +++ b/packages/babel-preset/tsconfig.json @@ -1,9 +1,5 @@ { "extends": "../../tsconfig.base.json", - "compilerOptions": { - "allowJs": true, - "esModuleInterop": true - }, "files": [], "include": [], "references": [ diff --git a/packages/babel-preset/tsconfig.lib.json b/packages/babel-preset/tsconfig.lib.json index 9121cf848..322399716 100644 --- a/packages/babel-preset/tsconfig.lib.json +++ b/packages/babel-preset/tsconfig.lib.json @@ -1,11 +1,19 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "module": "commonjs", - "outDir": "../../dist/out-tsc", - "declaration": true, + "outDir": "./out-tsc/lib", + "rootDir": "./src", + "emitDeclarationOnly": true, "types": ["node", "environment"] }, - "exclude": ["__fixtures__/**/*", "**/*.spec.ts", "**/*.test.ts", "jest.config.ts"], - "include": ["**/*.ts"] + "include": ["src/**/*.ts", "src/**/*.tsx"], + "exclude": ["**/*.spec.ts", "**/*.test.ts", "**/*.spec.tsx", "**/*.test.tsx", "vitest.config.ts"], + "references": [ + { + "path": "../core/tsconfig.lib.json" + }, + { + "path": "../react/tsconfig.lib.json" + } + ] } diff --git a/packages/babel-preset/tsconfig.spec.json b/packages/babel-preset/tsconfig.spec.json index 16b4d408b..103a0cd43 100644 --- a/packages/babel-preset/tsconfig.spec.json +++ b/packages/babel-preset/tsconfig.spec.json @@ -1,23 +1,25 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "jsx": "react-jsx", - "outDir": "../../dist/out-tsc", + "outDir": "./out-tsc/spec", "typeRoots": ["../../node_modules", "../../node_modules/@types", "../../typings"], - "types": ["vitest/importMeta", "vite/client", "node", "vitest", "environment", "static-assets"] + "types": ["vitest/importMeta", "vite/client", "node", "vitest", "environment"], + "jsx": "react-jsx", + "allowJs": true }, "include": [ - "vitest.config.mts", - "__fixtures__/**/code.ts", - "__fixtures__/**/fixture.ts", + "vitest.config.ts", + "src/common/**/*.ts", "**/*.test.ts", "**/*.spec.ts", "**/*.test.tsx", "**/*.spec.tsx", - "**/*.test.js", - "**/*.spec.js", - "**/*.test.jsx", - "**/*.spec.jsx", - "**/*.d.ts" - ] + "__fixtures__/**/*.js" + ], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ], + "exclude": ["out-tsc/**", "dist/**"] } diff --git a/packages/babel-preset/vitest.config.mts b/packages/babel-preset/vitest.config.mts index 07f6c649b..fc73d2c91 100644 --- a/packages/babel-preset/vitest.config.mts +++ b/packages/babel-preset/vitest.config.mts @@ -2,6 +2,8 @@ import { defineConfig } from 'vitest/config'; import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ + resolve: { conditions: ['@griffel/source'] }, + ssr: { resolve: { conditions: ['@griffel/source'] } }, root: __dirname, cacheDir: '../../node_modules/.vite/packages/babel-preset', plugins: [nxViteTsPaths()], diff --git a/packages/core/package.json b/packages/core/package.json index c333659c3..f1359dc12 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -9,14 +9,18 @@ }, "sideEffects": false, "type": "module", - "main": "./lib/index.cjs", - "module": "./src/index.js", - "types": "./src/index.d.ts", + "main": "./dist/cjs/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { ".": { - "types": "./src/index.d.ts", - "import": "./src/index.js", - "require": "./lib/index.cjs" + "@griffel/source": "./src/index.ts", + "types": "./dist/index.d.ts", + "import": "./dist/index.js", + "require": { + "types": "./dist/cjs/index.d.cts", + "default": "./dist/cjs/index.cjs" + } }, "./package.json": "./package.json" }, @@ -27,5 +31,11 @@ "rtl-css-js": "^1.16.1", "stylis": "^4.4.0", "tslib": "^2.1.0" - } + }, + "files": [ + "dist/", + "README.md", + "LICENSE.md", + "CHANGELOG.md" + ] } diff --git a/packages/core/project.json b/packages/core/project.json index 879f63e06..9bfcc0de9 100644 --- a/packages/core/project.json +++ b/packages/core/project.json @@ -6,30 +6,11 @@ "tags": [], "targets": { "build": { - "executor": "@nx/js:tsc", - "outputs": ["{options.outputPath}"], - "options": { - "outputPath": "dist/packages/core", - "tsConfig": "packages/core/tsconfig.lib.json", - "skipTypeField": true, - "packageJson": "packages/core/package.json", - "main": "packages/core/src/index.ts", - "assets": [ - "packages/core/README.md", - { - "glob": "LICENSE.md", - "input": ".", - "output": "." - } - ] - } - }, - "build-cjs": { - "dependsOn": ["build"], "executor": "nx:run-commands", - "outputs": ["{workspaceRoot}/dist/packages/core/lib"], + "dependsOn": ["_build_tsc"], + "outputs": ["{workspaceRoot}/packages/core/dist/cjs"], "options": { - "command": "node tools/build-cjs.mjs dist/packages/core/src dist/packages/core/lib" + "command": "node tools/build-cjs.mjs packages/core/dist packages/core/dist/cjs" } }, "lint": { @@ -55,17 +36,14 @@ ] } }, - "type-check": { + "_build_tsc": { "executor": "nx:run-commands", + "outputs": ["{workspaceRoot}/packages/core/dist"], "options": { "cwd": "packages/core", - "commands": [ - { - "command": "tsc -b --pretty" - } - ] - }, - "outputs": [] + "commands": ["tsc --build tsconfig.lib.json --pretty", "node ../../tools/copy-pkg-assets.mjs packages/core"], + "parallel": false + } } } } diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json index df5d3be6b..62ebbd946 100644 --- a/packages/core/tsconfig.json +++ b/packages/core/tsconfig.json @@ -1,10 +1,5 @@ { "extends": "../../tsconfig.base.json", - "compilerOptions": { - "allowJs": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true - }, "files": [], "include": [], "references": [ diff --git a/packages/core/tsconfig.lib.json b/packages/core/tsconfig.lib.json index 95fa77096..f0c017270 100644 --- a/packages/core/tsconfig.lib.json +++ b/packages/core/tsconfig.lib.json @@ -1,24 +1,15 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "module": "NodeNext", - "moduleResolution": "NodeNext", - "outDir": "../../dist/out-tsc", - "declaration": true, + "outDir": "./dist", + "rootDir": "./src", "types": ["node", "environment"] }, - "exclude": [ - "**/*.spec.ts", - "**/*.test.ts", - "**/*.spec.tsx", - "**/*.test.tsx", - "**/*.spec.js", - "**/*.test.js", - "**/*.spec.jsx", - "**/*.test.jsx", - "jest.config.ts", - "vitest.config.ts", - "bundle-size/**" - ], - "include": ["src/**/*.ts", "src/**/*.tsx"] + "include": ["src/**/*.ts", "src/**/*.tsx"], + "exclude": ["**/*.spec.ts", "**/*.test.ts", "**/*.spec.tsx", "**/*.test.tsx", "vitest.config.ts", "bundle-size/**"], + "references": [ + { + "path": "../style-types/tsconfig.lib.json" + } + ] } diff --git a/packages/core/tsconfig.spec.json b/packages/core/tsconfig.spec.json index f7128fd9d..57c1db01b 100644 --- a/packages/core/tsconfig.spec.json +++ b/packages/core/tsconfig.spec.json @@ -1,7 +1,7 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "outDir": "./out-tsc/spec", "typeRoots": ["../../node_modules", "../../node_modules/@types", "../../typings"], "types": ["vitest/importMeta", "vite/client", "node", "vitest", "environment"] }, @@ -11,11 +11,12 @@ "**/*.test.ts", "**/*.spec.ts", "**/*.test.tsx", - "**/*.spec.tsx", - "**/*.test.js", - "**/*.spec.js", - "**/*.test.jsx", - "**/*.spec.jsx", - "**/*.d.ts" - ] + "**/*.spec.tsx" + ], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ], + "exclude": ["out-tsc/**", "dist/**"] } diff --git a/packages/core/vitest.config.ts b/packages/core/vitest.config.ts index 0229c87f1..e551c7e6c 100644 --- a/packages/core/vitest.config.ts +++ b/packages/core/vitest.config.ts @@ -4,6 +4,8 @@ import { defineBrowserCommand } from '@vitest/browser-playwright'; import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ + resolve: { conditions: ['@griffel/source'] }, + ssr: { resolve: { conditions: ['@griffel/source'] } }, root: __dirname, cacheDir: '../../node_modules/.vite/packages/core', plugins: [nxViteTsPaths()], diff --git a/packages/devtools/project.json b/packages/devtools/project.json index 1796ff83e..aedac0f8a 100644 --- a/packages/devtools/project.json +++ b/packages/devtools/project.json @@ -40,18 +40,6 @@ "reportsDirectory": "{projectRoot}/../../coverage/packages/devtools" } }, - "type-check": { - "executor": "nx:run-commands", - "options": { - "cwd": "packages/devtools", - "commands": [ - { - "command": "tsc -b --pretty" - } - ] - }, - "outputs": [] - }, "watch": { "executor": "nx:run-commands", "options": { diff --git a/packages/devtools/tsconfig.json b/packages/devtools/tsconfig.json index 1fa5f8e7c..37ab84bcd 100644 --- a/packages/devtools/tsconfig.json +++ b/packages/devtools/tsconfig.json @@ -14,9 +14,6 @@ }, { "path": "./tsconfig.spec.json" - }, - { - "path": "./tsconfig.storybook.json" } ] } diff --git a/packages/devtools/tsconfig.lib.json b/packages/devtools/tsconfig.lib.json index ac89bd5f7..e4a82d01e 100644 --- a/packages/devtools/tsconfig.lib.json +++ b/packages/devtools/tsconfig.lib.json @@ -1,24 +1,29 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "jsx": "react-jsx", + "emitDeclarationOnly": true, + "outDir": "./out-tsc/lib", + "rootDir": "./src", "types": ["chrome", "node", "environment"] }, + "include": ["src/**/*.ts", "src/**/*.tsx"], "exclude": [ "**/*.spec.ts", "**/*.test.ts", "**/*.spec.tsx", "**/*.test.tsx", - "**/*.spec.js", - "**/*.test.js", - "**/*.spec.jsx", - "**/*.test.jsx", "**/*.stories.ts", - "**/*.stories.js", - "**/*.stories.jsx", "**/*.stories.tsx", "vite.config.ts", "vitest.setup.ts" ], - "include": ["**/*.ts", "**/*.tsx"] + "references": [ + { + "path": "../core/tsconfig.lib.json" + }, + { + "path": "../react/tsconfig.lib.json" + } + ] } diff --git a/packages/devtools/tsconfig.spec.json b/packages/devtools/tsconfig.spec.json index 0e6e6d0aa..bb317f1fb 100644 --- a/packages/devtools/tsconfig.spec.json +++ b/packages/devtools/tsconfig.spec.json @@ -1,8 +1,8 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", - "moduleResolution": "bundler", + "jsx": "react-jsx", + "outDir": "./out-tsc/spec", "typeRoots": ["../../node_modules", "../../node_modules/@types", "../../typings"], "types": ["vitest/importMeta", "vite/client", "chrome", "node", "vitest", "environment"] }, @@ -13,10 +13,12 @@ "src/**/*.spec.ts", "src/**/*.test.tsx", "src/**/*.spec.tsx", - "src/**/*.test.js", - "src/**/*.spec.js", - "src/**/*.test.jsx", - "src/**/*.spec.jsx", "src/**/*.d.ts" - ] + ], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ], + "exclude": ["out-tsc/**", "dist/**"] } diff --git a/packages/devtools/tsconfig.storybook.json b/packages/devtools/tsconfig.storybook.json index 33a39097e..a567768bc 100644 --- a/packages/devtools/tsconfig.storybook.json +++ b/packages/devtools/tsconfig.storybook.json @@ -4,7 +4,8 @@ "emitDecoratorMetadata": true, "moduleResolution": "bundler", "noEmit": true, - "outDir": "" + "outDir": "./out-tsc/storybook", + "composite": false }, "files": [ "../../node_modules/@nx/react/typings/styled-jsx.d.ts", diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index e4928a75e..e23213176 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -15,5 +15,21 @@ }, "peerDependencies": { "eslint": "^9.0.0 || ^10.0.0" - } + }, + "types": "./dist/index.d.ts", + "main": "./dist/index.js", + "exports": { + ".": { + "@griffel/source": "./src/index.ts", + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "./package.json": "./package.json" + }, + "files": [ + "dist/", + "README.md", + "LICENSE.md", + "CHANGELOG.md" + ] } diff --git a/packages/eslint-plugin/project.json b/packages/eslint-plugin/project.json index c0c1493ac..e2bb5f7c6 100644 --- a/packages/eslint-plugin/project.json +++ b/packages/eslint-plugin/project.json @@ -14,35 +14,16 @@ "outputs": ["{workspaceRoot}/coverage/packages/eslint-plugin"] }, "build": { - "executor": "@nx/js:tsc", - "outputs": ["{options.outputPath}"], - "options": { - "outputPath": "dist/packages/eslint-plugin", - "tsConfig": "packages/eslint-plugin/tsconfig.lib.json", - "skipTypeField": true, - "packageJson": "packages/eslint-plugin/package.json", - "main": "packages/eslint-plugin/src/index.ts", - "assets": [ - "packages/eslint-plugin/README.md", - { - "glob": "LICENSE.md", - "input": ".", - "output": "." - } - ] - } - }, - "type-check": { "executor": "nx:run-commands", + "outputs": ["{workspaceRoot}/packages/eslint-plugin/dist"], "options": { - "cwd": "packages/babel-preset", + "cwd": "packages/eslint-plugin", "commands": [ - { - "command": "tsc -b --pretty" - } - ] - }, - "outputs": [] + "tsc --build tsconfig.lib.json --pretty", + "node ../../tools/copy-pkg-assets.mjs packages/eslint-plugin" + ], + "parallel": false + } } } } diff --git a/packages/eslint-plugin/tsconfig.json b/packages/eslint-plugin/tsconfig.json index 7eea1bc24..62ebbd946 100644 --- a/packages/eslint-plugin/tsconfig.json +++ b/packages/eslint-plugin/tsconfig.json @@ -1,10 +1,5 @@ { "extends": "../../tsconfig.base.json", - "compilerOptions": { - "allowJs": true, - "module": "nodenext", - "moduleResolution": "nodenext" - }, "files": [], "include": [], "references": [ diff --git a/packages/eslint-plugin/tsconfig.lib.json b/packages/eslint-plugin/tsconfig.lib.json index 124ee9eda..afcb2d147 100644 --- a/packages/eslint-plugin/tsconfig.lib.json +++ b/packages/eslint-plugin/tsconfig.lib.json @@ -1,10 +1,10 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", - "declaration": true, + "outDir": "./dist", + "rootDir": "./src", "types": ["node", "environment"] }, - "exclude": ["**/*.spec.ts", "**/*.test.ts", "jest.config.ts"], - "include": ["**/*.ts"] + "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.mts"], + "exclude": ["**/*.spec.ts", "**/*.test.ts", "**/*.spec.tsx", "**/*.test.tsx", "vitest.config.ts"] } diff --git a/packages/eslint-plugin/tsconfig.spec.json b/packages/eslint-plugin/tsconfig.spec.json index 34c36bf98..57c1db01b 100644 --- a/packages/eslint-plugin/tsconfig.spec.json +++ b/packages/eslint-plugin/tsconfig.spec.json @@ -1,19 +1,22 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "outDir": "./out-tsc/spec", + "typeRoots": ["../../node_modules", "../../node_modules/@types", "../../typings"], "types": ["vitest/importMeta", "vite/client", "node", "vitest", "environment"] }, "include": [ - "vitest.config.mts", + "vitest.config.ts", + "src/common/**/*.ts", "**/*.test.ts", "**/*.spec.ts", "**/*.test.tsx", - "**/*.spec.tsx", - "**/*.test.js", - "**/*.spec.js", - "**/*.test.jsx", - "**/*.spec.jsx", - "**/*.d.ts" - ] + "**/*.spec.tsx" + ], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ], + "exclude": ["out-tsc/**", "dist/**"] } diff --git a/packages/eslint-plugin/vitest.config.mts b/packages/eslint-plugin/vitest.config.mts index 62dfe805a..268b91cb5 100644 --- a/packages/eslint-plugin/vitest.config.mts +++ b/packages/eslint-plugin/vitest.config.mts @@ -2,6 +2,8 @@ import { defineConfig } from 'vitest/config'; import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ + resolve: { conditions: ['@griffel/source'] }, + ssr: { resolve: { conditions: ['@griffel/source'] } }, root: __dirname, cacheDir: '../../node_modules/.vite/packages/eslint-plugin', plugins: [nxViteTsPaths()], diff --git a/packages/jest-serializer/package.json b/packages/jest-serializer/package.json index 1b4a415d0..eb94935ad 100644 --- a/packages/jest-serializer/package.json +++ b/packages/jest-serializer/package.json @@ -10,5 +10,21 @@ "dependencies": { "@griffel/core": "^1.21.2", "tslib": "^2.1.0" - } + }, + "types": "./dist/index.d.ts", + "main": "./dist/index.js", + "exports": { + ".": { + "@griffel/source": "./src/index.ts", + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "./package.json": "./package.json" + }, + "files": [ + "dist/", + "README.md", + "LICENSE.md", + "CHANGELOG.md" + ] } diff --git a/packages/jest-serializer/project.json b/packages/jest-serializer/project.json index 260c64d3c..f20a629a2 100644 --- a/packages/jest-serializer/project.json +++ b/packages/jest-serializer/project.json @@ -17,35 +17,16 @@ } }, "build": { - "executor": "@nx/js:tsc", - "outputs": ["{options.outputPath}"], - "options": { - "outputPath": "dist/packages/jest-serializer", - "tsConfig": "packages/jest-serializer/tsconfig.lib.json", - "skipTypeField": true, - "packageJson": "packages/jest-serializer/package.json", - "main": "packages/jest-serializer/src/index.ts", - "assets": [ - "packages/jest-serializer/README.md", - { - "glob": "LICENSE.md", - "input": ".", - "output": "." - } - ] - } - }, - "type-check": { "executor": "nx:run-commands", + "outputs": ["{workspaceRoot}/packages/jest-serializer/dist"], "options": { "cwd": "packages/jest-serializer", "commands": [ - { - "command": "tsc -b --pretty" - } - ] - }, - "outputs": [] + "tsc --build tsconfig.lib.json --pretty", + "node ../../tools/copy-pkg-assets.mjs packages/jest-serializer" + ], + "parallel": false + } } } } diff --git a/packages/jest-serializer/tsconfig.build.json b/packages/jest-serializer/tsconfig.build.json new file mode 100644 index 000000000..a8f13e64e --- /dev/null +++ b/packages/jest-serializer/tsconfig.build.json @@ -0,0 +1,20 @@ +{ + "extends": "./tsconfig.lib.json", + "compilerOptions": { + "composite": false, + "module": "node16", + "moduleResolution": "node16", + "customConditions": [], + "emitDeclarationOnly": false, + "declaration": true, + "outDir": "./dist" + }, + "references": [ + { + "path": "../react/tsconfig.lib.json" + }, + { + "path": "../core/tsconfig.lib.json" + } + ] +} diff --git a/packages/jest-serializer/tsconfig.json b/packages/jest-serializer/tsconfig.json index 915d41150..62ebbd946 100644 --- a/packages/jest-serializer/tsconfig.json +++ b/packages/jest-serializer/tsconfig.json @@ -1,9 +1,5 @@ { "extends": "../../tsconfig.base.json", - "compilerOptions": { - "allowJs": true, - "esModuleInterop": true - }, "files": [], "include": [], "references": [ diff --git a/packages/jest-serializer/tsconfig.lib.json b/packages/jest-serializer/tsconfig.lib.json index 0c32ed38a..c48a037ea 100644 --- a/packages/jest-serializer/tsconfig.lib.json +++ b/packages/jest-serializer/tsconfig.lib.json @@ -1,11 +1,19 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "module": "commonjs", - "outDir": "../../dist/out-tsc", - "declaration": true, + "outDir": "./out-tsc/lib", + "rootDir": "./src", + "emitDeclarationOnly": true, "types": ["node", "environment"] }, - "exclude": ["**/*.spec.ts", "**/*.test.ts", "jest.config.ts", "jest.setup.ts"], - "include": ["**/*.ts"] + "include": ["src/**/*.ts", "src/**/*.tsx"], + "exclude": ["**/*.spec.ts", "**/*.test.ts", "**/*.spec.tsx", "**/*.test.tsx", "vitest.config.ts"], + "references": [ + { + "path": "../react/tsconfig.lib.json" + }, + { + "path": "../core/tsconfig.lib.json" + } + ] } diff --git a/packages/jest-serializer/tsconfig.spec.json b/packages/jest-serializer/tsconfig.spec.json index b44cb9f09..3ce360d52 100644 --- a/packages/jest-serializer/tsconfig.spec.json +++ b/packages/jest-serializer/tsconfig.spec.json @@ -1,22 +1,24 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "jsx": "react-jsx", - "outDir": "../../dist/out-tsc", + "outDir": "./out-tsc/spec", "typeRoots": ["../../node_modules", "../../node_modules/@types", "../../typings"], - "types": ["vitest/importMeta", "vite/client", "node", "vitest", "environment"] + "types": ["vitest/importMeta", "vite/client", "node", "vitest", "environment"], + "jsx": "react-jsx" }, "include": [ - "vitest.config.mts", "vitest.setup.ts", + "vitest.config.ts", + "src/common/**/*.ts", "**/*.test.ts", "**/*.spec.ts", "**/*.test.tsx", - "**/*.spec.tsx", - "**/*.test.js", - "**/*.spec.js", - "**/*.test.jsx", - "**/*.spec.jsx", - "**/*.d.ts" - ] + "**/*.spec.tsx" + ], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ], + "exclude": ["out-tsc/**", "dist/**"] } diff --git a/packages/jest-serializer/vitest.config.mts b/packages/jest-serializer/vitest.config.mts index fa5a41eef..7fb7276dc 100644 --- a/packages/jest-serializer/vitest.config.mts +++ b/packages/jest-serializer/vitest.config.mts @@ -2,6 +2,8 @@ import { defineConfig } from 'vitest/config'; import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ + resolve: { conditions: ['@griffel/source'] }, + ssr: { resolve: { conditions: ['@griffel/source'] } }, root: __dirname, cacheDir: '../../node_modules/.vite/packages/jest-serializer', plugins: [nxViteTsPaths()], diff --git a/packages/postcss-syntax/package.json b/packages/postcss-syntax/package.json index 01c08826f..913883077 100644 --- a/packages/postcss-syntax/package.json +++ b/packages/postcss-syntax/package.json @@ -13,5 +13,20 @@ "@griffel/babel-preset": "^1.8.6", "postcss": "^8.5.14" }, - "main": "./src/index.js" + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "exports": { + ".": { + "@griffel/source": "./src/index.ts", + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "./package.json": "./package.json" + }, + "files": [ + "dist/", + "README.md", + "LICENSE.md", + "CHANGELOG.md" + ] } diff --git a/packages/postcss-syntax/project.json b/packages/postcss-syntax/project.json index 8e29d2534..b5c61cc0d 100644 --- a/packages/postcss-syntax/project.json +++ b/packages/postcss-syntax/project.json @@ -17,35 +17,16 @@ } }, "build": { - "executor": "@nx/js:tsc", - "outputs": ["{options.outputPath}"], - "options": { - "outputPath": "dist/packages/postcss-syntax", - "tsConfig": "packages/postcss-syntax/tsconfig.lib.json", - "skipTypeField": true, - "packageJson": "packages/postcss-syntax/package.json", - "main": "packages/postcss-syntax/src/index.ts", - "assets": [ - "packages/postcss-syntax/README.md", - { - "glob": "LICENSE.md", - "input": ".", - "output": "." - } - ] - } - }, - "type-check": { "executor": "nx:run-commands", + "outputs": ["{workspaceRoot}/packages/postcss-syntax/dist"], "options": { - "cwd": "packages/babel-preset", + "cwd": "packages/postcss-syntax", "commands": [ - { - "command": "tsc -b --pretty" - } - ] - }, - "outputs": [] + "tsc --build tsconfig.lib.json --pretty", + "node ../../tools/copy-pkg-assets.mjs packages/postcss-syntax" + ], + "parallel": false + } } } } diff --git a/packages/postcss-syntax/tsconfig.json b/packages/postcss-syntax/tsconfig.json index 2bd6d6f0a..62ebbd946 100644 --- a/packages/postcss-syntax/tsconfig.json +++ b/packages/postcss-syntax/tsconfig.json @@ -1,8 +1,5 @@ { "extends": "../../tsconfig.base.json", - "compilerOptions": { - "allowJs": true - }, "files": [], "include": [], "references": [ diff --git a/packages/postcss-syntax/tsconfig.lib.json b/packages/postcss-syntax/tsconfig.lib.json index 0a5aff6ef..4f633a30a 100644 --- a/packages/postcss-syntax/tsconfig.lib.json +++ b/packages/postcss-syntax/tsconfig.lib.json @@ -1,11 +1,17 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "module": "commonjs", - "outDir": "../../dist/out-tsc", - "declaration": true, + "module": "node16", + "moduleResolution": "node16", + "outDir": "./dist", + "rootDir": "./src", "types": ["node", "environment"] }, - "exclude": ["**/*.spec.ts", "**/*.test.ts", "jest.config.ts"], - "include": ["**/*.ts"] + "include": ["src/**/*.ts", "src/**/*.tsx"], + "exclude": ["**/*.spec.ts", "**/*.test.ts", "**/*.spec.tsx", "**/*.test.tsx", "vitest.config.ts"], + "references": [ + { + "path": "../babel-preset/tsconfig.lib.json" + } + ] } diff --git a/packages/postcss-syntax/tsconfig.spec.json b/packages/postcss-syntax/tsconfig.spec.json index 4784313a6..57c1db01b 100644 --- a/packages/postcss-syntax/tsconfig.spec.json +++ b/packages/postcss-syntax/tsconfig.spec.json @@ -1,20 +1,22 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "outDir": "./out-tsc/spec", "typeRoots": ["../../node_modules", "../../node_modules/@types", "../../typings"], "types": ["vitest/importMeta", "vite/client", "node", "vitest", "environment"] }, "include": [ - "vitest.config.mts", + "vitest.config.ts", + "src/common/**/*.ts", "**/*.test.ts", "**/*.spec.ts", "**/*.test.tsx", - "**/*.spec.tsx", - "**/*.test.js", - "**/*.spec.js", - "**/*.test.jsx", - "**/*.spec.jsx", - "**/*.d.ts" - ] + "**/*.spec.tsx" + ], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ], + "exclude": ["out-tsc/**", "dist/**"] } diff --git a/packages/postcss-syntax/vitest.config.mts b/packages/postcss-syntax/vitest.config.mts index 68e5ff484..4417251cf 100644 --- a/packages/postcss-syntax/vitest.config.mts +++ b/packages/postcss-syntax/vitest.config.mts @@ -2,6 +2,8 @@ import { defineConfig } from 'vitest/config'; import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ + resolve: { conditions: ['@griffel/source'] }, + ssr: { resolve: { conditions: ['@griffel/source'] } }, root: __dirname, cacheDir: '../../node_modules/.vite/packages/postcss-syntax', plugins: [nxViteTsPaths()], diff --git a/packages/react/package.json b/packages/react/package.json index b73c0bc5f..12cec4214 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -9,14 +9,18 @@ }, "sideEffects": false, "type": "module", - "main": "./lib/index.cjs", - "module": "./src/index.js", - "types": "./src/index.d.ts", + "main": "./dist/cjs/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { ".": { - "types": "./src/index.d.ts", - "import": "./src/index.js", - "require": "./lib/index.cjs" + "@griffel/source": "./src/index.ts", + "types": "./dist/index.d.ts", + "import": "./dist/index.js", + "require": { + "types": "./dist/cjs/index.d.cts", + "default": "./dist/cjs/index.cjs" + } }, "./package.json": "./package.json" }, @@ -32,5 +36,11 @@ }, "peerDependencies": { "react": ">=16.14.0 <20.0.0" - } + }, + "files": [ + "dist/", + "README.md", + "LICENSE.md", + "CHANGELOG.md" + ] } diff --git a/packages/react/project.json b/packages/react/project.json index 2d48dbac2..354722034 100644 --- a/packages/react/project.json +++ b/packages/react/project.json @@ -6,30 +6,11 @@ "tags": [], "targets": { "build": { - "executor": "@nx/js:tsc", - "outputs": ["{options.outputPath}"], - "options": { - "outputPath": "dist/packages/react", - "tsConfig": "packages/react/tsconfig.lib.json", - "skipTypeField": true, - "packageJson": "packages/react/package.json", - "main": "packages/react/src/index.ts", - "assets": [ - "packages/react/README.md", - { - "glob": "LICENSE.md", - "input": ".", - "output": "." - } - ] - } - }, - "build-cjs": { - "dependsOn": ["build"], "executor": "nx:run-commands", - "outputs": ["{workspaceRoot}/dist/packages/react/lib"], + "dependsOn": ["_build_tsc"], + "outputs": ["{workspaceRoot}/packages/react/dist/cjs"], "options": { - "command": "node tools/build-cjs.mjs dist/packages/react/src dist/packages/react/lib" + "command": "node tools/build-cjs.mjs packages/react/dist packages/react/dist/cjs" } }, "lint": { @@ -80,17 +61,14 @@ } } }, - "type-check": { + "_build_tsc": { "executor": "nx:run-commands", + "outputs": ["{workspaceRoot}/packages/react/dist"], "options": { "cwd": "packages/react", - "commands": [ - { - "command": "tsc -b --pretty" - } - ] - }, - "outputs": [] + "commands": ["tsc --build tsconfig.lib.json --pretty", "node ../../tools/copy-pkg-assets.mjs packages/react"], + "parallel": false + } } } } diff --git a/packages/react/tsconfig.json b/packages/react/tsconfig.json index 71dbfe6cf..62ebbd946 100644 --- a/packages/react/tsconfig.json +++ b/packages/react/tsconfig.json @@ -1,9 +1,5 @@ { "extends": "../../tsconfig.base.json", - "compilerOptions": { - "jsx": "react-jsx", - "allowJs": true - }, "files": [], "include": [], "references": [ @@ -12,9 +8,6 @@ }, { "path": "./tsconfig.spec.json" - }, - { - "path": "./tsconfig.storybook.json" } ] } diff --git a/packages/react/tsconfig.lib.json b/packages/react/tsconfig.lib.json index 9287e6039..f5292f2cf 100644 --- a/packages/react/tsconfig.lib.json +++ b/packages/react/tsconfig.lib.json @@ -1,28 +1,24 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "module": "NodeNext", - "moduleResolution": "NodeNext", - "outDir": "../../dist/out-tsc", - "declaration": true, - "stripInternal": true, - "types": ["node", "environment"] + "outDir": "./dist", + "rootDir": "./src", + "types": ["node", "environment"], + "jsx": "react-jsx" }, + "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.mts"], "exclude": [ "**/*.spec.ts", "**/*.test.ts", "**/*.spec.tsx", "**/*.test.tsx", - "**/*.spec.js", - "**/*.test.js", - "**/*.spec.jsx", - "**/*.test.jsx", + "vitest.config.ts", "**/*.stories.ts", - "**/*.stories.js", - "**/*.stories.jsx", - "**/*.stories.tsx", - "jest.config.ts", - "vitest.config.ts" + "**/*.stories.tsx" ], - "include": ["src/**/*.ts", "src/**/*.tsx"] + "references": [ + { + "path": "../core/tsconfig.lib.json" + } + ] } diff --git a/packages/react/tsconfig.spec.json b/packages/react/tsconfig.spec.json index 2be2b8559..13bb8116d 100644 --- a/packages/react/tsconfig.spec.json +++ b/packages/react/tsconfig.spec.json @@ -1,21 +1,23 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", - "allowSyntheticDefaultImports": true, + "outDir": "./out-tsc/spec", "typeRoots": ["../../node_modules", "../../node_modules/@types", "../../typings"], - "types": ["vitest/importMeta", "vite/client", "node", "vitest", "environment"] + "types": ["vitest/importMeta", "vite/client", "node", "vitest", "environment"], + "jsx": "react-jsx" }, "include": [ "vitest.config.ts", + "src/common/**/*.ts", "**/*.test.ts", "**/*.spec.ts", "**/*.test.tsx", - "**/*.spec.tsx", - "**/*.test.js", - "**/*.spec.js", - "**/*.test.jsx", - "**/*.spec.jsx", - "**/*.d.ts" - ] + "**/*.spec.tsx" + ], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ], + "exclude": ["out-tsc/**", "dist/**"] } diff --git a/packages/react/tsconfig.storybook.json b/packages/react/tsconfig.storybook.json index c3076d8e3..625584196 100644 --- a/packages/react/tsconfig.storybook.json +++ b/packages/react/tsconfig.storybook.json @@ -5,7 +5,8 @@ "moduleResolution": "bundler", "allowSyntheticDefaultImports": true, "noEmit": true, - "outDir": "" + "outDir": "./out-tsc/storybook", + "composite": false }, "exclude": ["src/**/*.spec.ts", "src/**/*.spec.js", "src/**/*.spec.tsx", "src/**/*.spec.jsx", "jest.config.ts"], "include": ["src/**/*", ".storybook/*.js"] diff --git a/packages/react/vitest.config.ts b/packages/react/vitest.config.ts index 3440e6e04..45cbd276e 100644 --- a/packages/react/vitest.config.ts +++ b/packages/react/vitest.config.ts @@ -2,6 +2,8 @@ import { defineConfig } from 'vitest/config'; import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ + resolve: { conditions: ['@griffel/source'] }, + ssr: { resolve: { conditions: ['@griffel/source'] } }, root: __dirname, cacheDir: '../../node_modules/.vite/packages/react', plugins: [nxViteTsPaths()], diff --git a/packages/shadow-dom/package.json b/packages/shadow-dom/package.json index 87602d408..bb6cef6a3 100644 --- a/packages/shadow-dom/package.json +++ b/packages/shadow-dom/package.json @@ -9,19 +9,29 @@ }, "sideEffects": false, "type": "module", - "main": "./lib/index.cjs", - "module": "./src/index.js", - "types": "./src/index.d.ts", + "main": "./dist/cjs/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { ".": { - "types": "./src/index.d.ts", - "import": "./src/index.js", - "require": "./lib/index.cjs" + "@griffel/source": "./src/index.ts", + "types": "./dist/index.d.ts", + "import": "./dist/index.js", + "require": { + "types": "./dist/cjs/index.d.cts", + "default": "./dist/cjs/index.cjs" + } }, "./package.json": "./package.json" }, "dependencies": { "@griffel/core": "^1.21.2", "tslib": "^2.1.0" - } + }, + "files": [ + "dist/", + "README.md", + "LICENSE.md", + "CHANGELOG.md" + ] } diff --git a/packages/shadow-dom/project.json b/packages/shadow-dom/project.json index d1aa20a6f..769691315 100644 --- a/packages/shadow-dom/project.json +++ b/packages/shadow-dom/project.json @@ -6,30 +6,11 @@ "tags": [], "targets": { "build": { - "executor": "@nx/js:tsc", - "outputs": ["{options.outputPath}"], - "options": { - "outputPath": "dist/packages/shadow-dom", - "tsConfig": "packages/shadow-dom/tsconfig.lib.json", - "skipTypeField": true, - "packageJson": "packages/shadow-dom/package.json", - "main": "packages/shadow-dom/src/index.ts", - "assets": [ - "packages/shadow-dom/README.md", - { - "glob": "LICENSE.md", - "input": ".", - "output": "." - } - ] - } - }, - "build-cjs": { - "dependsOn": ["build"], "executor": "nx:run-commands", - "outputs": ["{workspaceRoot}/dist/packages/shadow-dom/lib"], + "dependsOn": ["_build_tsc"], + "outputs": ["{workspaceRoot}/packages/shadow-dom/dist/cjs"], "options": { - "command": "node tools/build-cjs.mjs dist/packages/shadow-dom/src dist/packages/shadow-dom/lib" + "command": "node tools/build-cjs.mjs packages/shadow-dom/dist packages/shadow-dom/dist/cjs" } }, "lint": { @@ -80,17 +61,17 @@ } } }, - "type-check": { + "_build_tsc": { "executor": "nx:run-commands", + "outputs": ["{workspaceRoot}/packages/shadow-dom/dist"], "options": { "cwd": "packages/shadow-dom", "commands": [ - { - "command": "tsc -b --pretty" - } - ] - }, - "outputs": [] + "tsc --build tsconfig.lib.json --pretty", + "node ../../tools/copy-pkg-assets.mjs packages/shadow-dom" + ], + "parallel": false + } } } } diff --git a/packages/shadow-dom/tsconfig.json b/packages/shadow-dom/tsconfig.json index fb0d53b73..62ebbd946 100644 --- a/packages/shadow-dom/tsconfig.json +++ b/packages/shadow-dom/tsconfig.json @@ -1,10 +1,5 @@ { "extends": "../../tsconfig.base.json", - "compilerOptions": { - "allowJs": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true - }, "files": [], "include": [], "references": [ @@ -13,9 +8,6 @@ }, { "path": "./tsconfig.spec.json" - }, - { - "path": "./tsconfig.storybook.json" } ] } diff --git a/packages/shadow-dom/tsconfig.lib.json b/packages/shadow-dom/tsconfig.lib.json index 4118563c3..93dd77084 100644 --- a/packages/shadow-dom/tsconfig.lib.json +++ b/packages/shadow-dom/tsconfig.lib.json @@ -1,27 +1,27 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "module": "NodeNext", - "moduleResolution": "NodeNext", - "outDir": "../../dist/out-tsc", - "declaration": true, - "types": ["node", "environment"] + "outDir": "./dist", + "rootDir": "./src", + "types": ["node", "environment"], + "jsx": "react-jsx" }, + "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.mts"], "exclude": [ "**/*.spec.ts", "**/*.test.ts", "**/*.spec.tsx", "**/*.test.tsx", - "**/*.spec.js", - "**/*.test.js", - "**/*.spec.jsx", - "**/*.test.jsx", + "vitest.config.ts", "**/*.stories.ts", - "**/*.stories.js", - "**/*.stories.jsx", - "**/*.stories.tsx", - "jest.config.ts", - "vitest.config.ts" + "**/*.stories.tsx" ], - "include": ["src/**/*.ts", "src/**/*.tsx"] + "references": [ + { + "path": "../react/tsconfig.lib.json" + }, + { + "path": "../core/tsconfig.lib.json" + } + ] } diff --git a/packages/shadow-dom/tsconfig.spec.json b/packages/shadow-dom/tsconfig.spec.json index 3227aa648..13bb8116d 100644 --- a/packages/shadow-dom/tsconfig.spec.json +++ b/packages/shadow-dom/tsconfig.spec.json @@ -1,20 +1,23 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "outDir": "./out-tsc/spec", "typeRoots": ["../../node_modules", "../../node_modules/@types", "../../typings"], - "types": ["vitest/importMeta", "vite/client", "node", "vitest", "environment"] + "types": ["vitest/importMeta", "vite/client", "node", "vitest", "environment"], + "jsx": "react-jsx" }, "include": [ "vitest.config.ts", + "src/common/**/*.ts", "**/*.test.ts", "**/*.spec.ts", "**/*.test.tsx", - "**/*.spec.tsx", - "**/*.test.js", - "**/*.spec.js", - "**/*.test.jsx", - "**/*.spec.jsx", - "**/*.d.ts" - ] + "**/*.spec.tsx" + ], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ], + "exclude": ["out-tsc/**", "dist/**"] } diff --git a/packages/shadow-dom/tsconfig.storybook.json b/packages/shadow-dom/tsconfig.storybook.json index da6c6b19f..0c0e62d47 100644 --- a/packages/shadow-dom/tsconfig.storybook.json +++ b/packages/shadow-dom/tsconfig.storybook.json @@ -5,7 +5,8 @@ "emitDecoratorMetadata": true, "noPropertyAccessFromIndexSignature": false, "noEmit": true, - "outDir": "" + "outDir": "./out-tsc/storybook", + "composite": false }, "exclude": ["src/**/*.spec.ts", "src/**/*.spec.js", "src/**/*.spec.tsx", "src/**/*.spec.jsx", "jest.config.ts"], "include": ["src/**/*", ".storybook/*.js"] diff --git a/packages/shadow-dom/vitest.config.ts b/packages/shadow-dom/vitest.config.ts index ec013ca2a..39769efa0 100644 --- a/packages/shadow-dom/vitest.config.ts +++ b/packages/shadow-dom/vitest.config.ts @@ -2,6 +2,8 @@ import { defineConfig } from 'vitest/config'; import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ + resolve: { conditions: ['@griffel/source'] }, + ssr: { resolve: { conditions: ['@griffel/source'] } }, root: __dirname, cacheDir: '../../node_modules/.vite/packages/shadow-dom', plugins: [nxViteTsPaths()], diff --git a/packages/style-types/package.json b/packages/style-types/package.json index 01399a493..015e14173 100644 --- a/packages/style-types/package.json +++ b/packages/style-types/package.json @@ -11,5 +11,20 @@ "dependencies": { "csstype": "^3.2.3" }, - "types": "src/index.d.ts" + "types": "./dist/index.d.ts", + "main": "./dist/index.js", + "exports": { + ".": { + "@griffel/source": "./src/index.ts", + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "./package.json": "./package.json" + }, + "files": [ + "dist/", + "README.md", + "LICENSE.md", + "CHANGELOG.md" + ] } diff --git a/packages/style-types/project.json b/packages/style-types/project.json index 6b7bb3974..17c5287b3 100644 --- a/packages/style-types/project.json +++ b/packages/style-types/project.json @@ -6,39 +6,20 @@ "tags": [], "targets": { "build": { - "executor": "@nx/js:tsc", - "outputs": ["{options.outputPath}"], + "executor": "nx:run-commands", + "outputs": ["{workspaceRoot}/packages/style-types/dist"], "options": { - "outputPath": "dist/packages/style-types", - "tsConfig": "packages/style-types/tsconfig.lib.json", - "skipTypeField": true, - "packageJson": "packages/style-types/package.json", - "main": "packages/style-types/src/index.ts", - "assets": [ - "packages/style-types/README.md", - { - "glob": "LICENSE.md", - "input": ".", - "output": "." - } - ] + "cwd": "packages/style-types", + "commands": [ + "tsc --build tsconfig.lib.json --pretty", + "node ../../tools/copy-pkg-assets.mjs packages/style-types" + ], + "parallel": false } }, "lint": { "executor": "@nx/eslint:lint", "outputs": ["{options.outputFile}"] - }, - "type-check": { - "executor": "nx:run-commands", - "options": { - "cwd": "packages/style-types", - "commands": [ - { - "command": "tsc -b --pretty" - } - ] - }, - "outputs": [] } } } diff --git a/packages/style-types/tsconfig.json b/packages/style-types/tsconfig.json index 15ee67174..62ebbd946 100644 --- a/packages/style-types/tsconfig.json +++ b/packages/style-types/tsconfig.json @@ -1,15 +1,13 @@ { "extends": "../../tsconfig.base.json", - "compilerOptions": { - "allowJs": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true - }, "files": [], "include": [], "references": [ { "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" } ] } diff --git a/packages/style-types/tsconfig.lib.json b/packages/style-types/tsconfig.lib.json index fb8516565..4bafdd34e 100644 --- a/packages/style-types/tsconfig.lib.json +++ b/packages/style-types/tsconfig.lib.json @@ -1,20 +1,12 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", - "declaration": true, + "module": "node16", + "moduleResolution": "node16", + "outDir": "./dist", + "rootDir": "./src", "types": ["node", "environment"] }, - "exclude": [ - "**/*.spec.ts", - "**/*.test.ts", - "**/*.spec.tsx", - "**/*.test.tsx", - "**/*.spec.js", - "**/*.test.js", - "**/*.spec.jsx", - "**/*.test.jsx", - "jest.config.ts" - ], - "include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"] + "include": ["src/**/*.ts", "src/**/*.tsx"], + "exclude": ["**/*.spec.ts", "**/*.test.ts", "**/*.spec.tsx", "**/*.test.tsx", "vitest.config.ts"] } diff --git a/packages/style-types/tsconfig.spec.json b/packages/style-types/tsconfig.spec.json new file mode 100644 index 000000000..57c1db01b --- /dev/null +++ b/packages/style-types/tsconfig.spec.json @@ -0,0 +1,22 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./out-tsc/spec", + "typeRoots": ["../../node_modules", "../../node_modules/@types", "../../typings"], + "types": ["vitest/importMeta", "vite/client", "node", "vitest", "environment"] + }, + "include": [ + "vitest.config.ts", + "src/common/**/*.ts", + "**/*.test.ts", + "**/*.spec.ts", + "**/*.test.tsx", + "**/*.spec.tsx" + ], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ], + "exclude": ["out-tsc/**", "dist/**"] +} diff --git a/packages/transform-shaker/package.json b/packages/transform-shaker/package.json index 199c6b3f6..b0fe71a1a 100644 --- a/packages/transform-shaker/package.json +++ b/packages/transform-shaker/package.json @@ -8,12 +8,13 @@ "url": "https://github.com/microsoft/griffel" }, "type": "module", - "main": "./src/index.js", - "types": "./src/index.d.ts", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { ".": { - "types": "./src/index.d.ts", - "default": "./src/index.js" + "@griffel/source": "./src/index.ts", + "types": "./dist/index.d.ts", + "default": "./dist/index.js" }, "./package.json": "./package.json" }, @@ -22,5 +23,11 @@ "magic-string": "^0.30.19", "oxc-parser": "^0.132.0", "oxc-transform": "^0.132.0" - } + }, + "files": [ + "dist/", + "README.md", + "LICENSE.md", + "CHANGELOG.md" + ] } diff --git a/packages/transform-shaker/project.json b/packages/transform-shaker/project.json index 2f68d8b88..3c8b6159e 100644 --- a/packages/transform-shaker/project.json +++ b/packages/transform-shaker/project.json @@ -17,35 +17,16 @@ } }, "build": { - "executor": "@nx/js:tsc", - "outputs": ["{options.outputPath}"], - "options": { - "outputPath": "dist/packages/transform-shaker", - "tsConfig": "packages/transform-shaker/tsconfig.lib.json", - "skipTypeField": true, - "packageJson": "packages/transform-shaker/package.json", - "main": "packages/transform-shaker/src/index.ts", - "assets": [ - "packages/transform-shaker/README.md", - { - "glob": "LICENSE.md", - "input": ".", - "output": "." - } - ] - } - }, - "type-check": { "executor": "nx:run-commands", + "outputs": ["{workspaceRoot}/packages/transform-shaker/dist"], "options": { "cwd": "packages/transform-shaker", "commands": [ - { - "command": "tsc -b --pretty" - } - ] - }, - "outputs": [] + "tsc --build tsconfig.lib.json --pretty", + "node ../../tools/copy-pkg-assets.mjs packages/transform-shaker" + ], + "parallel": false + } } } } diff --git a/packages/transform-shaker/tsconfig.json b/packages/transform-shaker/tsconfig.json index 00433f885..62ebbd946 100644 --- a/packages/transform-shaker/tsconfig.json +++ b/packages/transform-shaker/tsconfig.json @@ -1,11 +1,5 @@ { "extends": "../../tsconfig.base.json", - "compilerOptions": { - "allowJs": true, - "module": "NodeNext", - "moduleResolution": "NodeNext", - "target": "ES2022" - }, "files": [], "include": [], "references": [ diff --git a/packages/transform-shaker/tsconfig.lib.json b/packages/transform-shaker/tsconfig.lib.json index e52065737..afcb2d147 100644 --- a/packages/transform-shaker/tsconfig.lib.json +++ b/packages/transform-shaker/tsconfig.lib.json @@ -1,29 +1,10 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "module": "ESNext", - "moduleResolution": "bundler", - "outDir": "../../dist/out-tsc", - "declaration": true, - "types": ["node"] + "outDir": "./dist", + "rootDir": "./src", + "types": ["node", "environment"] }, - "exclude": [ - "**/*.spec.ts", - "**/*.test.ts", - "jest.config.ts", - "vite.config.ts", - "vite.config.mts", - "vitest.config.ts", - "vitest.config.mts", - "src/**/*.test.ts", - "src/**/*.test.mts", - "src/**/*.spec.ts", - "src/**/*.test.tsx", - "src/**/*.spec.tsx", - "src/**/*.test.js", - "src/**/*.spec.js", - "src/**/*.test.jsx", - "src/**/*.spec.jsx" - ], - "include": ["**/*.ts"] + "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.mts"], + "exclude": ["**/*.spec.ts", "**/*.test.ts", "**/*.spec.tsx", "**/*.test.tsx", "vitest.config.ts"] } diff --git a/packages/transform-shaker/tsconfig.spec.json b/packages/transform-shaker/tsconfig.spec.json index a4e266438..57c1db01b 100644 --- a/packages/transform-shaker/tsconfig.spec.json +++ b/packages/transform-shaker/tsconfig.spec.json @@ -1,24 +1,22 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "outDir": "./out-tsc/spec", "typeRoots": ["../../node_modules", "../../node_modules/@types", "../../typings"], - "types": ["vitest/importMeta", "vite/client", "node", "vitest"] + "types": ["vitest/importMeta", "vite/client", "node", "vitest", "environment"] }, "include": [ - "vite.config.ts", - "vite.config.mts", "vitest.config.ts", - "vitest.config.mts", - "src/**/*.test.ts", - "src/**/*.test.mts", - "src/**/*.spec.ts", - "src/**/*.test.tsx", - "src/**/*.spec.tsx", - "src/**/*.test.js", - "src/**/*.spec.js", - "src/**/*.test.jsx", - "src/**/*.spec.jsx", - "src/**/*.d.ts" - ] + "src/common/**/*.ts", + "**/*.test.ts", + "**/*.spec.ts", + "**/*.test.tsx", + "**/*.spec.tsx" + ], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ], + "exclude": ["out-tsc/**", "dist/**"] } diff --git a/packages/transform-shaker/vitest.config.mts b/packages/transform-shaker/vitest.config.mts index 00c9709f6..52f6c094f 100644 --- a/packages/transform-shaker/vitest.config.mts +++ b/packages/transform-shaker/vitest.config.mts @@ -2,6 +2,8 @@ import { defineConfig } from 'vitest/config'; import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ + resolve: { conditions: ['@griffel/source'] }, + ssr: { resolve: { conditions: ['@griffel/source'] } }, root: __dirname, cacheDir: '../../node_modules/.vite/packages/transform-shaker', plugins: [nxViteTsPaths()], diff --git a/packages/transform/package.json b/packages/transform/package.json index 18aaad238..e386d458f 100644 --- a/packages/transform/package.json +++ b/packages/transform/package.json @@ -8,12 +8,13 @@ "url": "https://github.com/microsoft/griffel" }, "type": "module", - "main": "./src/index.mjs", - "types": "./src/index.d.mts", + "main": "./dist/index.mjs", + "types": "./dist/index.d.mts", "exports": { ".": { - "types": "./src/index.d.mts", - "default": "./src/index.mjs" + "@griffel/source": "./src/index.mts", + "types": "./dist/index.d.mts", + "default": "./dist/index.mjs" }, "./package.json": "./package.json" }, @@ -24,5 +25,11 @@ "magic-string": "^0.30.19", "oxc-parser": "^0.132.0", "oxc-walker": "^1.0.0" - } + }, + "files": [ + "dist/", + "README.md", + "LICENSE.md", + "CHANGELOG.md" + ] } diff --git a/packages/transform/project.json b/packages/transform/project.json index d983b9e3a..eb8f9d406 100644 --- a/packages/transform/project.json +++ b/packages/transform/project.json @@ -17,35 +17,16 @@ } }, "build": { - "executor": "@nx/js:tsc", - "outputs": ["{options.outputPath}"], - "options": { - "outputPath": "dist/packages/transform", - "tsConfig": "packages/transform/tsconfig.lib.json", - "skipTypeField": true, - "packageJson": "packages/transform/package.json", - "main": "packages/transform/src/index.mts", - "assets": [ - "packages/transform/README.md", - { - "glob": "LICENSE.md", - "input": ".", - "output": "." - } - ] - } - }, - "type-check": { "executor": "nx:run-commands", + "outputs": ["{workspaceRoot}/packages/transform/dist"], "options": { "cwd": "packages/transform", "commands": [ - { - "command": "tsc -b --pretty" - } - ] - }, - "outputs": [] + "tsc --build tsconfig.lib.json --pretty", + "node ../../tools/copy-pkg-assets.mjs packages/transform" + ], + "parallel": false + } } } } diff --git a/packages/transform/src/evaluation/module.test.mts b/packages/transform/src/evaluation/module.test.mts index 563fec244..8f42edad5 100644 --- a/packages/transform/src/evaluation/module.test.mts +++ b/packages/transform/src/evaluation/module.test.mts @@ -73,7 +73,7 @@ describe('Module', () => { at /child.js: at Script.runInContext (node:vm:) at Module.evaluate (/packages/transform/src/evaluation/module.mts:) - at require.Object.assign.ensure (/packages/transform/src/evaluation/module.mts:) + at Module.require.Object.assign.ensure (/packages/transform/src/evaluation/module.mts:) at /entry.js: at /entry.js: at Script.runInContext (node:vm:) diff --git a/packages/transform/tsconfig.json b/packages/transform/tsconfig.json index 00433f885..62ebbd946 100644 --- a/packages/transform/tsconfig.json +++ b/packages/transform/tsconfig.json @@ -1,11 +1,5 @@ { "extends": "../../tsconfig.base.json", - "compilerOptions": { - "allowJs": true, - "module": "NodeNext", - "moduleResolution": "NodeNext", - "target": "ES2022" - }, "files": [], "include": [], "references": [ diff --git a/packages/transform/tsconfig.lib.json b/packages/transform/tsconfig.lib.json index 6d2b82de4..60d8a91c0 100644 --- a/packages/transform/tsconfig.lib.json +++ b/packages/transform/tsconfig.lib.json @@ -1,30 +1,21 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "module": "ESNext", - "moduleResolution": "bundler", - "outDir": "../../dist/out-tsc", - "declaration": true, + "outDir": "./dist", + "rootDir": "./src", "types": ["node", "environment"] }, - "exclude": [ - "__fixtures__/**/*", - "**/*.spec.ts", - "**/*.test.ts", - "jest.config.ts", - "vite.config.ts", - "vite.config.mts", - "vitest.config.ts", - "vitest.config.mts", - "src/**/*.test.ts", - "src/**/*.test.mts", - "src/**/*.spec.ts", - "src/**/*.test.tsx", - "src/**/*.spec.tsx", - "src/**/*.test.js", - "src/**/*.spec.js", - "src/**/*.test.jsx", - "src/**/*.spec.jsx" - ], - "include": ["**/*.mts"] + "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.mts"], + "exclude": ["**/*.spec.ts", "**/*.test.ts", "**/*.spec.tsx", "**/*.test.tsx", "vitest.config.ts"], + "references": [ + { + "path": "../transform-shaker/tsconfig.lib.json" + }, + { + "path": "../core/tsconfig.lib.json" + }, + { + "path": "../react/tsconfig.lib.json" + } + ] } diff --git a/packages/transform/tsconfig.spec.json b/packages/transform/tsconfig.spec.json index b37a60f5c..57c1db01b 100644 --- a/packages/transform/tsconfig.spec.json +++ b/packages/transform/tsconfig.spec.json @@ -1,24 +1,22 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "outDir": "./out-tsc/spec", "typeRoots": ["../../node_modules", "../../node_modules/@types", "../../typings"], "types": ["vitest/importMeta", "vite/client", "node", "vitest", "environment"] }, "include": [ - "vite.config.ts", - "vite.config.mts", "vitest.config.ts", - "vitest.config.mts", - "src/**/*.test.ts", - "src/**/*.test.mts", - "src/**/*.spec.ts", - "src/**/*.test.tsx", - "src/**/*.spec.tsx", - "src/**/*.test.js", - "src/**/*.spec.js", - "src/**/*.test.jsx", - "src/**/*.spec.jsx", - "src/**/*.d.ts" - ] + "src/common/**/*.ts", + "**/*.test.ts", + "**/*.spec.ts", + "**/*.test.tsx", + "**/*.spec.tsx" + ], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ], + "exclude": ["out-tsc/**", "dist/**"] } diff --git a/packages/transform/vitest.config.mts b/packages/transform/vitest.config.mts index 89b69bdee..5eaaf9b04 100644 --- a/packages/transform/vitest.config.mts +++ b/packages/transform/vitest.config.mts @@ -2,6 +2,8 @@ import { defineConfig } from 'vitest/config'; import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ + resolve: { conditions: ['@griffel/source'] }, + ssr: { resolve: { conditions: ['@griffel/source'] } }, root: __dirname, cacheDir: '../../node_modules/.vite/packages/transform', plugins: [nxViteTsPaths()], diff --git a/packages/webpack-extraction-plugin/package.json b/packages/webpack-extraction-plugin/package.json index 8ce10c817..c3f77901b 100644 --- a/packages/webpack-extraction-plugin/package.json +++ b/packages/webpack-extraction-plugin/package.json @@ -17,5 +17,21 @@ }, "peerDependencies": { "webpack": "^5" - } + }, + "types": "./dist/index.d.ts", + "main": "./dist/index.js", + "exports": { + ".": { + "@griffel/source": "./src/index.ts", + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "./package.json": "./package.json" + }, + "files": [ + "dist/", + "README.md", + "LICENSE.md", + "CHANGELOG.md" + ] } diff --git a/packages/webpack-extraction-plugin/project.json b/packages/webpack-extraction-plugin/project.json index 2395f022f..f6d63190b 100644 --- a/packages/webpack-extraction-plugin/project.json +++ b/packages/webpack-extraction-plugin/project.json @@ -17,40 +17,16 @@ } }, "build": { - "executor": "@nx/js:tsc", - "outputs": ["{options.outputPath}"], - "options": { - "outputPath": "dist/packages/webpack-extraction-plugin", - "tsConfig": "packages/webpack-extraction-plugin/tsconfig.lib.json", - "skipTypeField": true, - "packageJson": "packages/webpack-extraction-plugin/package.json", - "main": "packages/webpack-extraction-plugin/src/index.ts", - "assets": [ - "packages/webpack-extraction-plugin/README.md", - { - "glob": "LICENSE.md", - "input": ".", - "output": "." - }, - { - "glob": "*.(css|js)", - "input": "packages/webpack-extraction-plugin/virtual-loader", - "output": "./virtual-loader" - } - ] - } - }, - "type-check": { "executor": "nx:run-commands", + "outputs": ["{workspaceRoot}/packages/webpack-extraction-plugin/dist"], "options": { "cwd": "packages/webpack-extraction-plugin", "commands": [ - { - "command": "tsc -b --pretty" - } - ] - }, - "outputs": [] + "tsc --build tsconfig.lib.json --pretty", + "node ../../tools/copy-pkg-assets.mjs packages/webpack-extraction-plugin" + ], + "parallel": false + } } } } diff --git a/packages/webpack-extraction-plugin/tsconfig.build.json b/packages/webpack-extraction-plugin/tsconfig.build.json new file mode 100644 index 000000000..77ee22186 --- /dev/null +++ b/packages/webpack-extraction-plugin/tsconfig.build.json @@ -0,0 +1,20 @@ +{ + "extends": "./tsconfig.lib.json", + "compilerOptions": { + "composite": false, + "module": "node16", + "moduleResolution": "node16", + "customConditions": [], + "emitDeclarationOnly": false, + "declaration": true, + "outDir": "./dist" + }, + "references": [ + { + "path": "../core/tsconfig.lib.json" + }, + { + "path": "../react/tsconfig.lib.json" + } + ] +} diff --git a/packages/webpack-extraction-plugin/tsconfig.json b/packages/webpack-extraction-plugin/tsconfig.json index 4393873b8..62ebbd946 100644 --- a/packages/webpack-extraction-plugin/tsconfig.json +++ b/packages/webpack-extraction-plugin/tsconfig.json @@ -1,10 +1,5 @@ { "extends": "../../tsconfig.base.json", - "compilerOptions": { - "allowJs": true, - "esModuleInterop": true, - "checkJs": true - }, "files": [], "include": [], "references": [ diff --git a/packages/webpack-extraction-plugin/tsconfig.lib.json b/packages/webpack-extraction-plugin/tsconfig.lib.json index ed62f0e15..322399716 100644 --- a/packages/webpack-extraction-plugin/tsconfig.lib.json +++ b/packages/webpack-extraction-plugin/tsconfig.lib.json @@ -1,11 +1,19 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "module": "commonjs", - "outDir": "../../dist/out-tsc", - "declaration": true, + "outDir": "./out-tsc/lib", + "rootDir": "./src", + "emitDeclarationOnly": true, "types": ["node", "environment"] }, - "exclude": ["__fixtures__/**/*/*.ts", "**/*.spec.ts", "**/*.test.ts", "src/common/**", "jest.config.ts"], - "include": ["**/*.ts", "virtual-loader/index.js"] + "include": ["src/**/*.ts", "src/**/*.tsx"], + "exclude": ["**/*.spec.ts", "**/*.test.ts", "**/*.spec.tsx", "**/*.test.tsx", "vitest.config.ts"], + "references": [ + { + "path": "../core/tsconfig.lib.json" + }, + { + "path": "../react/tsconfig.lib.json" + } + ] } diff --git a/packages/webpack-extraction-plugin/tsconfig.spec.json b/packages/webpack-extraction-plugin/tsconfig.spec.json index d66c6803c..57c1db01b 100644 --- a/packages/webpack-extraction-plugin/tsconfig.spec.json +++ b/packages/webpack-extraction-plugin/tsconfig.spec.json @@ -1,22 +1,22 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "jsx": "react-jsx", - "outDir": "../../dist/out-tsc", + "outDir": "./out-tsc/spec", "typeRoots": ["../../node_modules", "../../node_modules/@types", "../../typings"], - "types": ["vitest/importMeta", "vite/client", "node", "vitest", "environment", "static-assets"] + "types": ["vitest/importMeta", "vite/client", "node", "vitest", "environment"] }, "include": [ - "vitest.config.mts", - "__fixtures__/**/*/code.ts", + "vitest.config.ts", + "src/common/**/*.ts", "**/*.test.ts", "**/*.spec.ts", "**/*.test.tsx", - "**/*.spec.tsx", - "**/*.test.js", - "**/*.spec.js", - "**/*.test.jsx", - "**/*.spec.jsx", - "**/*.d.ts" - ] + "**/*.spec.tsx" + ], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ], + "exclude": ["out-tsc/**", "dist/**"] } diff --git a/packages/webpack-extraction-plugin/vitest.config.mts b/packages/webpack-extraction-plugin/vitest.config.mts index a8f30bf12..2f0e51d6a 100644 --- a/packages/webpack-extraction-plugin/vitest.config.mts +++ b/packages/webpack-extraction-plugin/vitest.config.mts @@ -2,6 +2,8 @@ import { defineConfig } from 'vitest/config'; import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ + resolve: { conditions: ['@griffel/source'] }, + ssr: { resolve: { conditions: ['@griffel/source'] } }, root: __dirname, cacheDir: '../../node_modules/.vite/packages/webpack-extraction-plugin', plugins: [nxViteTsPaths()], diff --git a/packages/webpack-loader/package.json b/packages/webpack-loader/package.json index f5dfefaaa..7d032ea5e 100644 --- a/packages/webpack-loader/package.json +++ b/packages/webpack-loader/package.json @@ -15,5 +15,21 @@ }, "peerDependencies": { "webpack": "^5" - } + }, + "types": "./dist/index.d.ts", + "main": "./dist/index.js", + "exports": { + ".": { + "@griffel/source": "./src/index.ts", + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "./package.json": "./package.json" + }, + "files": [ + "dist/", + "README.md", + "LICENSE.md", + "CHANGELOG.md" + ] } diff --git a/packages/webpack-loader/project.json b/packages/webpack-loader/project.json index ac4d21fcd..3b80494ef 100644 --- a/packages/webpack-loader/project.json +++ b/packages/webpack-loader/project.json @@ -17,35 +17,16 @@ } }, "build": { - "executor": "@nx/js:tsc", - "outputs": ["{options.outputPath}"], - "options": { - "outputPath": "dist/packages/webpack-loader", - "tsConfig": "packages/webpack-loader/tsconfig.lib.json", - "skipTypeField": true, - "packageJson": "packages/webpack-loader/package.json", - "main": "packages/webpack-loader/src/index.ts", - "assets": [ - "packages/webpack-loader/README.md", - { - "glob": "LICENSE.md", - "input": ".", - "output": "." - } - ] - } - }, - "type-check": { "executor": "nx:run-commands", + "outputs": ["{workspaceRoot}/packages/webpack-loader/dist"], "options": { "cwd": "packages/webpack-loader", "commands": [ - { - "command": "tsc -b --pretty" - } - ] - }, - "outputs": [] + "tsc --build tsconfig.lib.json --pretty", + "node ../../tools/copy-pkg-assets.mjs packages/webpack-loader" + ], + "parallel": false + } } } } diff --git a/packages/webpack-loader/tsconfig.json b/packages/webpack-loader/tsconfig.json index 915d41150..62ebbd946 100644 --- a/packages/webpack-loader/tsconfig.json +++ b/packages/webpack-loader/tsconfig.json @@ -1,9 +1,5 @@ { "extends": "../../tsconfig.base.json", - "compilerOptions": { - "allowJs": true, - "esModuleInterop": true - }, "files": [], "include": [], "references": [ diff --git a/packages/webpack-loader/tsconfig.lib.json b/packages/webpack-loader/tsconfig.lib.json index c5908aa5b..70bf795d0 100644 --- a/packages/webpack-loader/tsconfig.lib.json +++ b/packages/webpack-loader/tsconfig.lib.json @@ -1,11 +1,20 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "module": "commonjs", - "outDir": "../../dist/out-tsc", - "declaration": true, + "module": "node16", + "moduleResolution": "node16", + "outDir": "./dist", + "rootDir": "./src", "types": ["node", "environment"] }, - "exclude": ["__fixtures__/*/*.ts", "**/*.spec.ts", "**/*.test.ts", "src/common/**", "jest.config.ts"], - "include": ["**/*.ts"] + "include": ["src/**/*.ts", "src/**/*.tsx"], + "exclude": ["**/*.spec.ts", "**/*.test.ts", "**/*.spec.tsx", "**/*.test.tsx", "vitest.config.ts"], + "references": [ + { + "path": "../babel-preset/tsconfig.lib.json" + }, + { + "path": "../react/tsconfig.lib.json" + } + ] } diff --git a/packages/webpack-loader/tsconfig.spec.json b/packages/webpack-loader/tsconfig.spec.json index c75ea2cf1..57c1db01b 100644 --- a/packages/webpack-loader/tsconfig.spec.json +++ b/packages/webpack-loader/tsconfig.spec.json @@ -1,22 +1,22 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "jsx": "react-jsx", - "outDir": "../../dist/out-tsc", + "outDir": "./out-tsc/spec", "typeRoots": ["../../node_modules", "../../node_modules/@types", "../../typings"], "types": ["vitest/importMeta", "vite/client", "node", "vitest", "environment"] }, "include": [ - "vitest.config.mts", - "__fixtures__/*/code.ts", + "vitest.config.ts", + "src/common/**/*.ts", "**/*.test.ts", "**/*.spec.ts", "**/*.test.tsx", - "**/*.spec.tsx", - "**/*.test.js", - "**/*.spec.js", - "**/*.test.jsx", - "**/*.spec.jsx", - "**/*.d.ts" - ] + "**/*.spec.tsx" + ], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ], + "exclude": ["out-tsc/**", "dist/**"] } diff --git a/packages/webpack-loader/vitest.config.mts b/packages/webpack-loader/vitest.config.mts index 13d3c63e6..2a7e8c4dd 100644 --- a/packages/webpack-loader/vitest.config.mts +++ b/packages/webpack-loader/vitest.config.mts @@ -2,6 +2,8 @@ import { defineConfig } from 'vitest/config'; import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ + resolve: { conditions: ['@griffel/source'] }, + ssr: { resolve: { conditions: ['@griffel/source'] } }, root: __dirname, cacheDir: '../../node_modules/.vite/packages/webpack-loader', plugins: [nxViteTsPaths()], diff --git a/packages/webpack-plugin/package.json b/packages/webpack-plugin/package.json index 6ed095952..5c717ed01 100644 --- a/packages/webpack-plugin/package.json +++ b/packages/webpack-plugin/package.json @@ -8,16 +8,18 @@ "url": "https://github.com/microsoft/griffel" }, "type": "module", - "main": "./src/index.mjs", - "types": "./src/index.d.mts", + "main": "./dist/index.mjs", + "types": "./dist/index.d.mts", "exports": { ".": { - "types": "./src/index.d.mts", - "default": "./src/index.mjs" + "@griffel/source": "./src/index.mts", + "types": "./dist/index.d.mts", + "default": "./dist/index.mjs" }, "./loader": { - "types": "./src/webpackLoader.d.mts", - "default": "./src/webpackLoader.mjs" + "@griffel/source": "./src/webpackLoader.mts", + "types": "./dist/webpackLoader.d.mts", + "default": "./dist/webpackLoader.mjs" }, "./package.json": "./package.json" }, @@ -29,5 +31,11 @@ }, "peerDependencies": { "webpack": "^5" - } + }, + "files": [ + "dist/", + "README.md", + "LICENSE.md", + "CHANGELOG.md" + ] } diff --git a/packages/webpack-plugin/project.json b/packages/webpack-plugin/project.json index 596462dea..c1babf161 100644 --- a/packages/webpack-plugin/project.json +++ b/packages/webpack-plugin/project.json @@ -10,40 +10,16 @@ "outputs": ["{options.outputFile}"] }, "build": { - "executor": "@nx/js:tsc", - "outputs": ["{options.outputPath}"], - "options": { - "outputPath": "dist/packages/webpack-plugin", - "tsConfig": "packages/webpack-plugin/tsconfig.lib.json", - "skipTypeField": true, - "packageJson": "packages/webpack-plugin/package.json", - "main": "packages/webpack-plugin/src/index.mts", - "assets": [ - "packages/webpack-plugin/README.md", - { - "glob": "LICENSE.md", - "input": ".", - "output": "." - }, - { - "glob": "*", - "input": "packages/webpack-plugin/src/virtual-loader", - "output": "src/virtual-loader" - } - ] - } - }, - "type-check": { "executor": "nx:run-commands", + "outputs": ["{workspaceRoot}/packages/webpack-plugin/dist"], "options": { "cwd": "packages/webpack-plugin", "commands": [ - { - "command": "tsc -b --pretty" - } - ] - }, - "outputs": [] + "tsc --build tsconfig.lib.json --pretty", + "node ../../tools/copy-pkg-assets.mjs packages/webpack-plugin" + ], + "parallel": false + } }, "test": { "executor": "@nx/vitest:test", diff --git a/packages/webpack-plugin/src/GriffelPlugin.test.mts b/packages/webpack-plugin/src/GriffelPlugin.test.mts index 1631084ca..09fa53f47 100644 --- a/packages/webpack-plugin/src/GriffelPlugin.test.mts +++ b/packages/webpack-plugin/src/GriffelPlugin.test.mts @@ -473,7 +473,7 @@ describe('GriffelCSSExtractionPlugin', () => { at /packages/webpack-plugin/__fixtures__/vm-error-trace/broken.ts: at Script.runInContext (node:vm:) at Module.evaluate (/packages/transform/src/evaluation/module.mts:) - at require.Object.assign.ensure (/packages/transform/src/evaluation/module.mts:) + at Module.require.Object.assign.ensure (/packages/transform/src/evaluation/module.mts:) at /packages/webpack-plugin/__fixtures__/vm-error-trace/code.ts: at /packages/webpack-plugin/__fixtures__/vm-error-trace/code.ts: at Script.runInContext (node:vm:) diff --git a/packages/webpack-plugin/tsconfig.json b/packages/webpack-plugin/tsconfig.json index d824d4bb0..62ebbd946 100644 --- a/packages/webpack-plugin/tsconfig.json +++ b/packages/webpack-plugin/tsconfig.json @@ -1,10 +1,5 @@ { "extends": "../../tsconfig.base.json", - "compilerOptions": { - "module": "NodeNext", - "moduleResolution": "NodeNext", - "target": "ES2022" - }, "files": [], "include": [], "references": [ diff --git a/packages/webpack-plugin/tsconfig.lib.json b/packages/webpack-plugin/tsconfig.lib.json index 6d2b82de4..ab08e75c5 100644 --- a/packages/webpack-plugin/tsconfig.lib.json +++ b/packages/webpack-plugin/tsconfig.lib.json @@ -1,30 +1,23 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "module": "ESNext", - "moduleResolution": "bundler", - "outDir": "../../dist/out-tsc", - "declaration": true, - "types": ["node", "environment"] + "outDir": "./dist", + "rootDir": "./src", + "types": ["node", "environment"], + "target": "es2020", + "lib": ["es2020", "dom", "DOM.Iterable"] }, - "exclude": [ - "__fixtures__/**/*", - "**/*.spec.ts", - "**/*.test.ts", - "jest.config.ts", - "vite.config.ts", - "vite.config.mts", - "vitest.config.ts", - "vitest.config.mts", - "src/**/*.test.ts", - "src/**/*.test.mts", - "src/**/*.spec.ts", - "src/**/*.test.tsx", - "src/**/*.spec.tsx", - "src/**/*.test.js", - "src/**/*.spec.js", - "src/**/*.test.jsx", - "src/**/*.spec.jsx" - ], - "include": ["**/*.mts"] + "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.mts"], + "exclude": ["**/*.spec.ts", "**/*.test.ts", "**/*.spec.tsx", "**/*.test.tsx", "vitest.config.ts"], + "references": [ + { + "path": "../transform/tsconfig.lib.json" + }, + { + "path": "../core/tsconfig.lib.json" + }, + { + "path": "../react/tsconfig.lib.json" + } + ] } diff --git a/packages/webpack-plugin/tsconfig.spec.json b/packages/webpack-plugin/tsconfig.spec.json index 499262f90..769a13f50 100644 --- a/packages/webpack-plugin/tsconfig.spec.json +++ b/packages/webpack-plugin/tsconfig.spec.json @@ -1,23 +1,25 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", - "types": ["node", "environment"] + "outDir": "./out-tsc/spec", + "typeRoots": ["../../node_modules", "../../node_modules/@types", "../../typings"], + "types": ["vitest/importMeta", "vite/client", "node", "vitest", "environment"], + "jsx": "react-jsx", + "target": "es2020", + "lib": ["es2020", "dom", "DOM.Iterable"] }, "include": [ - "vite.config.ts", - "vite.config.mts", "vitest.config.ts", - "vitest.config.mts", - "src/**/*.test.ts", - "src/**/*.test.mts", - "src/**/*.spec.ts", - "src/**/*.test.tsx", - "src/**/*.spec.tsx", - "src/**/*.test.js", - "src/**/*.spec.js", - "src/**/*.test.jsx", - "src/**/*.spec.jsx", - "src/**/*.d.ts" - ] + "src/common/**/*.ts", + "**/*.test.ts", + "**/*.spec.ts", + "**/*.test.tsx", + "**/*.spec.tsx" + ], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ], + "exclude": ["out-tsc/**", "dist/**"] } diff --git a/packages/webpack-plugin/vitest.config.mts b/packages/webpack-plugin/vitest.config.mts index 93f5bea6f..fd385af1a 100644 --- a/packages/webpack-plugin/vitest.config.mts +++ b/packages/webpack-plugin/vitest.config.mts @@ -2,6 +2,8 @@ import { defineConfig } from 'vitest/config'; import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ + resolve: { conditions: ['@griffel/source'] }, + ssr: { resolve: { conditions: ['@griffel/source'] } }, root: __dirname, cacheDir: '../../node_modules/.vite/packages/webpack-plugin', plugins: [nxViteTsPaths()], diff --git a/tools/build-cjs.mjs b/tools/build-cjs.mjs index 355527d0a..ff18813d1 100644 --- a/tools/build-cjs.mjs +++ b/tools/build-cjs.mjs @@ -1,10 +1,13 @@ /** * Converts ESM .js files to CJS .cjs files using SWC. + * Also copies .d.ts files alongside as .d.cts so consumers using the + * `require` exports condition under moduleResolution: node16/nodenext + * see CJS-context type declarations. * * Usage: node tools/build-cjs.mjs */ import { transformFileSync } from '@swc/core'; -import { mkdirSync, readdirSync, writeFileSync } from 'node:fs'; +import { mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs'; import { dirname, join, resolve, relative } from 'node:path'; const [esmDir, cjsDir] = process.argv.slice(2); @@ -17,20 +20,21 @@ if (!esmDir || !cjsDir) { const absEsmDir = resolve(esmDir); const absCjsDir = resolve(cjsDir); -function collectJsFiles(dir) { +function collectFiles(dir, predicate) { const results = []; for (const entry of readdirSync(dir, { withFileTypes: true })) { + if (entry.name === 'cjs') continue; // skip output sub-directory const fullPath = join(dir, entry.name); if (entry.isDirectory()) { - results.push(...collectJsFiles(fullPath)); - } else if (entry.name.endsWith('.js')) { + results.push(...collectFiles(fullPath, predicate)); + } else if (predicate(entry.name)) { results.push(fullPath); } } return results; } -const jsFiles = collectJsFiles(absEsmDir); +const jsFiles = collectFiles(absEsmDir, name => name.endsWith('.js')); for (const absInput of jsFiles) { const rel = relative(absEsmDir, absInput); @@ -52,4 +56,18 @@ for (const absInput of jsFiles) { writeFileSync(absOutput, cjsCode); } -console.log(`Converted ${jsFiles.length} ESM → CJS files into ${cjsDir}`); +const dtsFiles = collectFiles(absEsmDir, name => name.endsWith('.d.ts') && !name.endsWith('.d.cts')); + +for (const absInput of dtsFiles) { + const rel = relative(absEsmDir, absInput); + const absOutput = join(absCjsDir, rel.replace(/\.d\.ts$/, '.d.cts')); + // Rewrite relative .js extensions in import/export specifiers to .cjs + const dtsCode = readFileSync(absInput, 'utf8').replace( + /(from\s+["']\.\.?\/[^"']+)\.js(["'])/g, + '$1.cjs$2', + ); + mkdirSync(dirname(absOutput), { recursive: true }); + writeFileSync(absOutput, dtsCode); +} + +console.log(`Converted ${jsFiles.length} ESM → CJS files and ${dtsFiles.length} .d.ts → .d.cts into ${cjsDir}`); diff --git a/tools/copy-pkg-assets.mjs b/tools/copy-pkg-assets.mjs new file mode 100644 index 000000000..4f96ac6ca --- /dev/null +++ b/tools/copy-pkg-assets.mjs @@ -0,0 +1,33 @@ +/** + * Copies package.json, README.md, LICENSE.md into the package's dist/. + * + * Usage: node tools/copy-pkg-assets.mjs + * + * Reads /{package.json,README.md} and copies them along with + * the workspace-root LICENSE.md into /dist/. + */ +import { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'; +import { dirname, join, resolve } from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const [pkgDir] = process.argv.slice(2); +if (!pkgDir) { + console.error('Usage: node tools/copy-pkg-assets.mjs '); + process.exit(1); +} + +const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..'); +const absPkg = resolve(repoRoot, pkgDir); +const distDir = join(absPkg, 'dist'); + +mkdirSync(distDir, { recursive: true }); + +const pkgJson = JSON.parse(readFileSync(join(absPkg, 'package.json'), 'utf8')); +delete pkgJson.scripts; +delete pkgJson.devDependencies; +writeFileSync(join(distDir, 'package.json'), JSON.stringify(pkgJson, null, 2) + '\n'); + +for (const f of ['README.md', 'LICENSE.md']) { + const src = existsSync(join(absPkg, f)) ? join(absPkg, f) : join(repoRoot, f); + if (existsSync(src)) copyFileSync(src, join(distDir, f)); +} diff --git a/tools/deprecate-broken-release.mjs b/tools/deprecate-broken-release.mjs new file mode 100644 index 000000000..b30bba7f0 --- /dev/null +++ b/tools/deprecate-broken-release.mjs @@ -0,0 +1,58 @@ +/** + * Deprecates the broken versions published by commit ef0b28a1. + * + * Usage: + * node tools/deprecate-broken-release.mjs # dry-run, prints commands + * node tools/deprecate-broken-release.mjs --apply # actually run npm deprecate + * + * Requires being logged in to npm with publish rights for @griffel/*. + */ +import { spawnSync } from 'node:child_process'; + +const MESSAGE = + 'This version was published from a broken build artifact (commit ef0b28a1). ' + + 'Please upgrade to the next patch release.'; + +const VERSIONS = { + '@griffel/babel-preset': '1.8.5', + '@griffel/core': '1.21.1', + '@griffel/devtools': '0.3.11', + '@griffel/eslint-plugin': '3.0.1', + '@griffel/jest-serializer': '1.1.40', + '@griffel/postcss-syntax': '1.3.11', + '@griffel/react': '1.7.3', + '@griffel/shadow-dom': '0.2.16', + '@griffel/style-types': '1.4.1', + '@griffel/transform': '3.0.5', + '@griffel/transform-shaker': '1.0.6', + '@griffel/webpack-extraction-plugin': '0.5.18', + '@griffel/webpack-loader': '2.2.27', + '@griffel/webpack-plugin': '4.0.5', +}; + +const apply = process.argv.includes('--apply'); + +if (!apply) { + console.log('Dry-run. Pass --apply to actually deprecate.\n'); +} + +let failed = 0; +for (const [name, version] of Object.entries(VERSIONS)) { + const spec = `${name}@${version}`; + const args = ['deprecate', spec, MESSAGE]; + + console.log(`npm ${args.map(a => (a.includes(' ') ? JSON.stringify(a) : a)).join(' ')}`); + + if (!apply) continue; + + const result = spawnSync('npm', args, { stdio: 'inherit' }); + if (result.status !== 0) { + console.error(` failed (exit ${result.status})`); + failed++; + } +} + +if (apply) { + console.log(`\nDone. ${failed === 0 ? 'All deprecations succeeded.' : `${failed} failed.`}`); + process.exit(failed === 0 ? 0 : 1); +} diff --git a/tools/update-shorthands/package.json b/tools/update-shorthands/package.json index 6c8cf8425..14d2dccbc 100644 --- a/tools/update-shorthands/package.json +++ b/tools/update-shorthands/package.json @@ -2,5 +2,9 @@ "name": "@griffel/update-shorthands", "version": "0.0.0", "private": true, - "type": "module" + "type": "module", + "devDependencies": { + "@griffel/core": "workspace:*", + "@griffel/style-types": "workspace:*" + } } diff --git a/tools/update-shorthands/project.json b/tools/update-shorthands/project.json index c27da15af..2ca7ece33 100644 --- a/tools/update-shorthands/project.json +++ b/tools/update-shorthands/project.json @@ -28,18 +28,6 @@ "options": { "reportsDirectory": "{projectRoot}/../../coverage/tools/update-shorthands" } - }, - "type-check": { - "executor": "nx:run-commands", - "options": { - "cwd": "tools/update-shorthands", - "commands": [ - { - "command": "tsc -b --pretty" - } - ] - }, - "outputs": [] } } } diff --git a/tools/update-shorthands/tsconfig.json b/tools/update-shorthands/tsconfig.json index 2e00bfa0e..c23e61c80 100644 --- a/tools/update-shorthands/tsconfig.json +++ b/tools/update-shorthands/tsconfig.json @@ -1,19 +1,10 @@ { "extends": "../../tsconfig.base.json", - "compilerOptions": { - "allowJs": true, - "module": "nodenext", - "moduleResolution": "nodenext", - "allowImportingTsExtensions": true - }, "files": [], "include": [], "references": [ { "path": "./tsconfig.lib.json" - }, - { - "path": "./tsconfig.spec.json" } ] } diff --git a/tools/update-shorthands/tsconfig.lib.json b/tools/update-shorthands/tsconfig.lib.json index 215af9f85..b7c68b095 100644 --- a/tools/update-shorthands/tsconfig.lib.json +++ b/tools/update-shorthands/tsconfig.lib.json @@ -1,9 +1,20 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "noEmit": true, + "module": "nodenext", + "moduleResolution": "nodenext", + "allowImportingTsExtensions": true, + "emitDeclarationOnly": true, + "outDir": "./dist", "types": ["node", "environment"] }, - "exclude": ["__fixtures__/*/*.ts", "**/*.spec.ts", "**/*.test.ts", "jest.config.ts"], - "include": ["**/*.ts"] + "include": ["src/**/*.ts", "src/**/*.tsx"], + "references": [ + { + "path": "../../packages/style-types/tsconfig.lib.json" + }, + { + "path": "../../packages/core/tsconfig.lib.json" + } + ] } diff --git a/tools/update-shorthands/tsconfig.spec.json b/tools/update-shorthands/tsconfig.spec.json index 7583c3782..25b22b6a8 100644 --- a/tools/update-shorthands/tsconfig.spec.json +++ b/tools/update-shorthands/tsconfig.spec.json @@ -1,24 +1,17 @@ { - "extends": "./tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "jsx": "react-jsx", - "outDir": "../../dist/out-tsc", - "noEmit": true, "module": "nodenext", - "typeRoots": ["../../node_modules", "../../node_modules/@types", "../../typings"], - "types": ["vitest/importMeta", "vite/client", "node", "vitest", "environment"] + "moduleResolution": "nodenext", + "allowImportingTsExtensions": true, + "emitDeclarationOnly": true, + "outDir": "./out-tsc/spec", + "types": ["vitest/importMeta", "node", "vitest", "environment"] }, - "include": [ - "vitest.config.ts", - "__fixtures__/*/code.ts", - "**/*.test.ts", - "**/*.spec.ts", - "**/*.test.tsx", - "**/*.spec.tsx", - "**/*.test.js", - "**/*.spec.js", - "**/*.test.jsx", - "**/*.spec.jsx", - "**/*.d.ts" + "include": ["**/*.test.ts", "**/*.spec.ts"], + "references": [ + { + "path": "./tsconfig.lib.json" + } ] } diff --git a/tsconfig.base.json b/tsconfig.base.json index c9f65a370..3aa843259 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1,12 +1,12 @@ { "compileOnSave": false, "compilerOptions": { - "rootDir": ".", + "composite": true, + "declarationMap": true, "sourceMap": true, - "declaration": false, - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, + "moduleResolution": "bundler", + "customConditions": ["@griffel/source"], + "isolatedModules": true, "importHelpers": true, "target": "es2019", "module": "esnext", @@ -19,25 +19,7 @@ "forceConsistentCasingInFileNames": true, "skipLibCheck": true, "skipDefaultLibCheck": true, - "baseUrl": ".", - "paths": { - "@griffel/babel-preset": ["packages/babel-preset/src/index.ts"], - "@griffel/core": ["packages/core/src/index.ts"], - "@griffel/devtools": ["packages/devtools/src/index.ts"], - "@griffel/e2e-utils": ["e2e/utils/src/index.ts"], - "@griffel/eslint-plugin": ["packages/eslint-plugin/src/index.ts"], - "@griffel/jest-serializer": ["packages/jest-serializer/src/index.ts"], - "@griffel/postcss-syntax": ["packages/postcss-syntax/src/index.ts"], - "@griffel/react": ["packages/react/src/index.ts"], - "@griffel/style-types": ["packages/style-types/src/index.ts"], - "@griffel/transform": ["packages/transform/src/index.mts"], - "@griffel/transform-shaker": ["packages/transform-shaker/src/index.ts"], - "@griffel/update-shorthands": ["tools/update-shorthands/src/index.ts"], - "@griffel/webpack-extraction-plugin": ["packages/webpack-extraction-plugin/src/index.ts"], - "@griffel/webpack-loader": ["packages/webpack-loader/src/index.ts"], - "@griffel/webpack-plugin": ["packages/webpack-plugin/src/index.mts"] - }, - "typeRoots": ["node_modules/@types", "./typings"] + "typeRoots": ["./node_modules/@types", "./typings"] }, "exclude": ["node_modules", "tmp"] } diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 000000000..180eacece --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,63 @@ +{ + "extends": "./tsconfig.base.json", + "files": [], + "references": [ + { + "path": "./e2e/eslint" + }, + { + "path": "./e2e/rspack" + }, + { + "path": "./e2e/typescript" + }, + { + "path": "./e2e/utils" + }, + { + "path": "./packages/babel-preset" + }, + { + "path": "./packages/core" + }, + { + "path": "./packages/devtools" + }, + { + "path": "./packages/eslint-plugin" + }, + { + "path": "./packages/jest-serializer" + }, + { + "path": "./packages/postcss-syntax" + }, + { + "path": "./packages/react" + }, + { + "path": "./packages/shadow-dom" + }, + { + "path": "./packages/style-types" + }, + { + "path": "./packages/transform" + }, + { + "path": "./packages/transform-shaker" + }, + { + "path": "./packages/webpack-extraction-plugin" + }, + { + "path": "./packages/webpack-loader" + }, + { + "path": "./packages/webpack-plugin" + }, + { + "path": "./tools/update-shorthands" + } + ] +} diff --git a/yarn.lock b/yarn.lock index 471495011..6c2f43cf4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3747,7 +3747,7 @@ __metadata: languageName: unknown linkType: soft -"@griffel/core@npm:^1.21.2, @griffel/core@workspace:packages/core": +"@griffel/core@npm:^1.21.2, @griffel/core@workspace:*, @griffel/core@workspace:packages/core": version: 0.0.0-use.local resolution: "@griffel/core@workspace:packages/core" dependencies: @@ -3771,6 +3771,10 @@ __metadata: "@griffel/e2e-eslint@workspace:e2e/eslint": version: 0.0.0-use.local resolution: "@griffel/e2e-eslint@workspace:e2e/eslint" + dependencies: + "@griffel/e2e-utils": "workspace:*" + "@griffel/eslint-plugin": "workspace:*" + "@griffel/react": "workspace:*" languageName: unknown linkType: soft @@ -3789,16 +3793,19 @@ __metadata: "@griffel/e2e-typescript@workspace:e2e/typescript": version: 0.0.0-use.local resolution: "@griffel/e2e-typescript@workspace:e2e/typescript" + dependencies: + "@griffel/e2e-utils": "workspace:*" + "@griffel/style-types": "workspace:*" languageName: unknown linkType: soft -"@griffel/e2e-utils@npm:*, @griffel/e2e-utils@workspace:e2e/utils": +"@griffel/e2e-utils@npm:*, @griffel/e2e-utils@workspace:*, @griffel/e2e-utils@workspace:e2e/utils": version: 0.0.0-use.local resolution: "@griffel/e2e-utils@workspace:e2e/utils" languageName: unknown linkType: soft -"@griffel/eslint-plugin@workspace:packages/eslint-plugin": +"@griffel/eslint-plugin@workspace:*, @griffel/eslint-plugin@workspace:packages/eslint-plugin": version: 0.0.0-use.local resolution: "@griffel/eslint-plugin@workspace:packages/eslint-plugin" dependencies: @@ -3830,7 +3837,7 @@ __metadata: languageName: unknown linkType: soft -"@griffel/react@npm:^1.7.4, @griffel/react@workspace:packages/react": +"@griffel/react@npm:^1.7.4, @griffel/react@workspace:*, @griffel/react@workspace:packages/react": version: 0.0.0-use.local resolution: "@griffel/react@workspace:packages/react" dependencies: @@ -3850,7 +3857,7 @@ __metadata: languageName: unknown linkType: soft -"@griffel/style-types@npm:^1.4.2, @griffel/style-types@workspace:packages/style-types": +"@griffel/style-types@npm:^1.4.2, @griffel/style-types@workspace:*, @griffel/style-types@workspace:packages/style-types": version: 0.0.0-use.local resolution: "@griffel/style-types@workspace:packages/style-types" dependencies: @@ -3885,6 +3892,9 @@ __metadata: "@griffel/update-shorthands@workspace:tools/update-shorthands": version: 0.0.0-use.local resolution: "@griffel/update-shorthands@workspace:tools/update-shorthands" + dependencies: + "@griffel/core": "workspace:*" + "@griffel/style-types": "workspace:*" languageName: unknown linkType: soft @@ -3929,6 +3939,12 @@ __metadata: languageName: unknown linkType: soft +"@griffel/website@workspace:apps/website": + version: 0.0.0-use.local + resolution: "@griffel/website@workspace:apps/website" + languageName: unknown + linkType: soft + "@hapi/hoek@npm:^9.0.0": version: 9.3.0 resolution: "@hapi/hoek@npm:9.3.0" From 863599dee093292c14bcbe97a2694d008412f21d Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Thu, 21 May 2026 12:23:12 +0200 Subject: [PATCH 02/26] fix: align workspace migration with current main after rebase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Switch CJS-with-issue packages (babel-preset/jest-serializer/ webpack-extraction-plugin) build target to tsconfig.build.json so they actually emit ./dist/ (their tsconfig.lib.json is typecheck-only with emitDeclarationOnly). - Move per-condition `types` from top-level into the `import`/`require` branches of core/react/shadow-dom exports so CJS consumers resolve to ./dist/cjs/index.d.cts under moduleResolution: node16/nodenext. - Drop the beachball patch — the workspace-level dist/packages/X path it redirects to no longer exists with per-package dist/. Publish works from packages/X/ directly thanks to the per-package `files` field. - Include virtual-loader/ in webpack-extraction-plugin's files, and point virtual-loader/index.js at ../dist/constants.js (was source TS). - Pin @typescript-eslint/utils to a single version via resolutions (the nested @typescript-eslint/rule-tester copy caused RuleModule type identity mismatch in eslint-plugin tests). Co-Authored-By: Claude Opus 4.7 (1M context) --- .../beachball-npm-2.65.4-4bf34ce8d5.patch | 34 ---------------- package.json | 5 ++- packages/babel-preset/project.json | 2 +- packages/core/package.json | 7 ++-- packages/jest-serializer/project.json | 2 +- packages/react/package.json | 7 ++-- packages/shadow-dom/package.json | 7 ++-- .../webpack-extraction-plugin/package.json | 1 + .../webpack-extraction-plugin/project.json | 2 +- .../virtual-loader/index.js | 4 +- yarn.lock | 39 +------------------ 11 files changed, 23 insertions(+), 87 deletions(-) delete mode 100644 .yarn/patches/beachball-npm-2.65.4-4bf34ce8d5.patch diff --git a/.yarn/patches/beachball-npm-2.65.4-4bf34ce8d5.patch b/.yarn/patches/beachball-npm-2.65.4-4bf34ce8d5.patch deleted file mode 100644 index d4d9d04ed..000000000 --- a/.yarn/patches/beachball-npm-2.65.4-4bf34ce8d5.patch +++ /dev/null @@ -1,34 +0,0 @@ -diff --git a/lib/packageManager/packagePublish.js b/lib/packageManager/packagePublish.js -index 8d5ae6204d540df07ee9e019febbc2b04a825d81..f486f46991b732bc1af69a61587117a5b1703899 100644 ---- a/lib/packageManager/packagePublish.js -+++ b/lib/packageManager/packagePublish.js -@@ -15,11 +15,17 @@ async function packagePublish(packageInfo, options) { - const publishArgs = (0, npmArgs_1.getNpmPublishArgs)(packageInfo, options); - const authEnv = (0, npmArgs_1.getNpmAuthEnv)(options); - const packageRoot = path_1.default.dirname(packageInfo.packageJsonPath); -+ // Griffel: publish from the built artifact directory under the workspace-level -+ // `dist/`, mirroring the source-tree layout. The source package.json's -+ // `main`/`exports`/etc. paths assume the published package root is `dist/`, -+ // not the source package directory. -+ const packageDir = path_1.default.relative(options.path, packageRoot); -+ const publishCwd = path_1.default.resolve(options.path, 'dist', packageDir); - const publishTag = publishArgs[publishArgs.indexOf('--tag') + 1]; - const packageSpec = `${packageInfo.name}@${packageInfo.version}`; - console.log(`Publishing - ${packageSpec} with tag ${publishTag}`); - console.log(` publish command: ${publishArgs.join(' ')}`); -- console.log(` (cwd: ${packageRoot}${authEnv ? `, auth env var: ${Object.keys(authEnv)[0]}=****` : ''})\n`); -+ console.log(` (cwd: ${publishCwd}${authEnv ? `, auth env var: ${Object.keys(authEnv)[0]}=****` : ''})\n`); - let result; - // Unclear whether `options.retries` should be interpreted as "X attempts" or "initial attempt + X retries"... - // It was previously implemented as the latter, so keep that for now. -@@ -28,8 +34,8 @@ async function packagePublish(packageInfo, options) { - console.log(`Retrying... (${retries}/${options.retries})\n`); - } - result = await (0, npm_1.npm)(publishArgs, { -- // Run npm publish in the package directory -- cwd: packageRoot, -+ // Run npm publish in the built artifact directory (see Griffel comment above). -+ cwd: publishCwd, - timeout: options.timeout, - all: true, - preferLocal: false, diff --git a/package.json b/package.json index cdbc3e11a..3414356e1 100644 --- a/package.json +++ b/package.json @@ -106,7 +106,7 @@ "@vitest/coverage-v8": "4.1.5", "@vitest/ui": "4.1.5", "babel-plugin-tester": "12.0.0", - "beachball": "patch:beachball@npm%3A2.65.4#~/.yarn/patches/beachball-npm-2.65.4-4bf34ce8d5.patch", + "beachball": "2.65.4", "bestzip": "2.2.0", "css-loader": "^7.1.4", "dedent": "^1.7.2", @@ -151,6 +151,7 @@ "webpack-merge": "6.0.1" }, "resolutions": { - "source-map-js@npm:1.2.1": "patch:source-map-js@npm%3A1.2.1#~/.yarn/patches/source-map-js-npm-1.2.1-b9a47d7e1a.patch" + "source-map-js@npm:1.2.1": "patch:source-map-js@npm%3A1.2.1#~/.yarn/patches/source-map-js-npm-1.2.1-b9a47d7e1a.patch", + "@typescript-eslint/utils": "^8.59.3" } } diff --git a/packages/babel-preset/project.json b/packages/babel-preset/project.json index e2a39d86f..3a73db360 100644 --- a/packages/babel-preset/project.json +++ b/packages/babel-preset/project.json @@ -22,7 +22,7 @@ "options": { "cwd": "packages/babel-preset", "commands": [ - "tsc --build tsconfig.lib.json --pretty", + "tsc --build tsconfig.build.json --pretty", "node ../../tools/copy-pkg-assets.mjs packages/babel-preset" ], "parallel": false diff --git a/packages/core/package.json b/packages/core/package.json index f1359dc12..54b734c50 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -11,12 +11,13 @@ "type": "module", "main": "./dist/cjs/index.cjs", "module": "./dist/index.js", - "types": "./dist/index.d.ts", "exports": { ".": { "@griffel/source": "./src/index.ts", - "types": "./dist/index.d.ts", - "import": "./dist/index.js", + "import": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, "require": { "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" diff --git a/packages/jest-serializer/project.json b/packages/jest-serializer/project.json index f20a629a2..83386eebe 100644 --- a/packages/jest-serializer/project.json +++ b/packages/jest-serializer/project.json @@ -22,7 +22,7 @@ "options": { "cwd": "packages/jest-serializer", "commands": [ - "tsc --build tsconfig.lib.json --pretty", + "tsc --build tsconfig.build.json --pretty", "node ../../tools/copy-pkg-assets.mjs packages/jest-serializer" ], "parallel": false diff --git a/packages/react/package.json b/packages/react/package.json index 12cec4214..106a5e62b 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -11,12 +11,13 @@ "type": "module", "main": "./dist/cjs/index.cjs", "module": "./dist/index.js", - "types": "./dist/index.d.ts", "exports": { ".": { "@griffel/source": "./src/index.ts", - "types": "./dist/index.d.ts", - "import": "./dist/index.js", + "import": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, "require": { "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" diff --git a/packages/shadow-dom/package.json b/packages/shadow-dom/package.json index bb6cef6a3..cbd745383 100644 --- a/packages/shadow-dom/package.json +++ b/packages/shadow-dom/package.json @@ -11,12 +11,13 @@ "type": "module", "main": "./dist/cjs/index.cjs", "module": "./dist/index.js", - "types": "./dist/index.d.ts", "exports": { ".": { "@griffel/source": "./src/index.ts", - "types": "./dist/index.d.ts", - "import": "./dist/index.js", + "import": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, "require": { "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" diff --git a/packages/webpack-extraction-plugin/package.json b/packages/webpack-extraction-plugin/package.json index c3f77901b..1b4f3edba 100644 --- a/packages/webpack-extraction-plugin/package.json +++ b/packages/webpack-extraction-plugin/package.json @@ -29,6 +29,7 @@ "./package.json": "./package.json" }, "files": [ + "virtual-loader/", "dist/", "README.md", "LICENSE.md", diff --git a/packages/webpack-extraction-plugin/project.json b/packages/webpack-extraction-plugin/project.json index f6d63190b..5febe76ec 100644 --- a/packages/webpack-extraction-plugin/project.json +++ b/packages/webpack-extraction-plugin/project.json @@ -22,7 +22,7 @@ "options": { "cwd": "packages/webpack-extraction-plugin", "commands": [ - "tsc --build tsconfig.lib.json --pretty", + "tsc --build tsconfig.build.json --pretty", "node ../../tools/copy-pkg-assets.mjs packages/webpack-extraction-plugin" ], "parallel": false diff --git a/packages/webpack-extraction-plugin/virtual-loader/index.js b/packages/webpack-extraction-plugin/virtual-loader/index.js index e3574ad94..f50c9db8b 100644 --- a/packages/webpack-extraction-plugin/virtual-loader/index.js +++ b/packages/webpack-extraction-plugin/virtual-loader/index.js @@ -1,7 +1,7 @@ -const { GriffelCssLoaderContextKey } = require('../src/constants'); +const { GriffelCssLoaderContextKey } = require('../dist/constants.js'); /** - * @this {import("../src/constants").SupplementedLoaderContext} + * @this {import("../dist/constants").SupplementedLoaderContext} * @return {String} */ function virtualLoader() { diff --git a/yarn.lock b/yarn.lock index 6c2f43cf4..137c0e296 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9500,22 +9500,7 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/utils@npm:8.59.2": - version: 8.59.2 - resolution: "@typescript-eslint/utils@npm:8.59.2" - dependencies: - "@eslint-community/eslint-utils": "npm:^4.9.1" - "@typescript-eslint/scope-manager": "npm:8.59.2" - "@typescript-eslint/types": "npm:8.59.2" - "@typescript-eslint/typescript-estree": "npm:8.59.2" - peerDependencies: - eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 - typescript: ">=4.8.4 <6.1.0" - checksum: 10/4e157a18b28d656b13ae07583765cc871d992abad0ae0aeb2cde819dd632d62b89da9f9e468dfefead18b9440aa2b9040ca36841525dff4ea97479583114afe0 - languageName: node - linkType: hard - -"@typescript-eslint/utils@npm:8.59.4, @typescript-eslint/utils@npm:^8.0.0, @typescript-eslint/utils@npm:^8.48.0, @typescript-eslint/utils@npm:^8.59.1, @typescript-eslint/utils@npm:^8.59.3": +"@typescript-eslint/utils@npm:^8.59.3": version: 8.59.4 resolution: "@typescript-eslint/utils@npm:8.59.4" dependencies: @@ -10902,26 +10887,6 @@ __metadata: languageName: node linkType: hard -"beachball@patch:beachball@npm%3A2.65.4#~/.yarn/patches/beachball-npm-2.65.4-4bf34ce8d5.patch": - version: 2.65.4 - resolution: "beachball@patch:beachball@npm%3A2.65.4#~/.yarn/patches/beachball-npm-2.65.4-4bf34ce8d5.patch::version=2.65.4&hash=95942e" - dependencies: - "@vercel/detect-agent": "npm:^1.2.1" - cosmiconfig: "npm:^9.0.1" - execa: "npm:^5.1.1" - minimatch: "npm:^3.1.5" - p-graph: "npm:^1.3.0" - p-limit: "npm:^3.1.0" - prompts: "npm:^2.4.2" - semver: "npm:^7.7.4" - workspace-tools: "npm:^0.41.6" - yargs-parser: "npm:^21.1.1" - bin: - beachball: bin/beachball.js - checksum: 10/b7e0c08a5eaeed94df8369208bdbdad9ecbdf60e9100b960f1b2f0864f3ba295a9fc30ed274c9ab79a5f8e8ce8c72fe567d7fb5ce1861ce7549d39bebca0bcef - languageName: node - linkType: hard - "bestzip@npm:2.2.0": version: 2.2.0 resolution: "bestzip@npm:2.2.0" @@ -15295,7 +15260,7 @@ __metadata: "@vitest/ui": "npm:4.1.5" ajv: "npm:^8.20.0" babel-plugin-tester: "npm:12.0.0" - beachball: "patch:beachball@npm%3A2.65.4#~/.yarn/patches/beachball-npm-2.65.4-4bf34ce8d5.patch" + beachball: "npm:2.65.4" bestzip: "npm:2.2.0" css-loader: "npm:^7.1.4" csstype: "npm:^3.2.3" From 4770faf2e92f327069596ed85f922d6da409d5fb Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Thu, 21 May 2026 12:28:55 +0200 Subject: [PATCH 03/26] chore: add type:none changefiles for workspace migration Internal-only change (build pipeline + tsconfig restructuring); no version bumps intended. Co-Authored-By: Claude Opus 4.7 (1M context) --- ...-babel-preset-5c7ca657-6f16-4831-add5-ec10fa461db1.json | 7 +++++++ ...@griffel-core-488ea0f9-cccb-4721-86a4-b2491be089ce.json | 7 +++++++ ...ffel-devtools-a0037621-c810-4227-b642-4dcad066cf08.json | 7 +++++++ ...eslint-plugin-40aaef23-b998-4a26-a088-eb7c058b307b.json | 7 +++++++ ...st-serializer-14b11c90-c293-4a16-9682-a278877a5ed6.json | 7 +++++++ ...ostcss-syntax-cf05402a-d49d-4061-9c0b-1942aad275f8.json | 7 +++++++ ...griffel-react-bc97d453-9e78-491a-8956-522c5558ff31.json | 7 +++++++ ...el-shadow-dom-bdffa7d7-6265-4763-826e-0057fa91d215.json | 7 +++++++ ...l-style-types-6312bb23-b468-4396-9648-72063566db45.json | 7 +++++++ ...fel-transform-87d14893-72a5-4b6e-8458-a4d4e5eb572e.json | 7 +++++++ ...nsform-shaker-0accdf23-15f3-4f87-bf5b-88581795b1e4.json | 7 +++++++ ...action-plugin-77ddbf00-8fb4-4a21-8093-48e6b5efc497.json | 7 +++++++ ...ebpack-loader-c5a41871-e1fe-49bd-915c-e24254eb6ede.json | 7 +++++++ ...ebpack-plugin-49de74bc-716f-43a5-a2b3-9892a585faba.json | 7 +++++++ 14 files changed, 98 insertions(+) create mode 100644 change/@griffel-babel-preset-5c7ca657-6f16-4831-add5-ec10fa461db1.json create mode 100644 change/@griffel-core-488ea0f9-cccb-4721-86a4-b2491be089ce.json create mode 100644 change/@griffel-devtools-a0037621-c810-4227-b642-4dcad066cf08.json create mode 100644 change/@griffel-eslint-plugin-40aaef23-b998-4a26-a088-eb7c058b307b.json create mode 100644 change/@griffel-jest-serializer-14b11c90-c293-4a16-9682-a278877a5ed6.json create mode 100644 change/@griffel-postcss-syntax-cf05402a-d49d-4061-9c0b-1942aad275f8.json create mode 100644 change/@griffel-react-bc97d453-9e78-491a-8956-522c5558ff31.json create mode 100644 change/@griffel-shadow-dom-bdffa7d7-6265-4763-826e-0057fa91d215.json create mode 100644 change/@griffel-style-types-6312bb23-b468-4396-9648-72063566db45.json create mode 100644 change/@griffel-transform-87d14893-72a5-4b6e-8458-a4d4e5eb572e.json create mode 100644 change/@griffel-transform-shaker-0accdf23-15f3-4f87-bf5b-88581795b1e4.json create mode 100644 change/@griffel-webpack-extraction-plugin-77ddbf00-8fb4-4a21-8093-48e6b5efc497.json create mode 100644 change/@griffel-webpack-loader-c5a41871-e1fe-49bd-915c-e24254eb6ede.json create mode 100644 change/@griffel-webpack-plugin-49de74bc-716f-43a5-a2b3-9892a585faba.json diff --git a/change/@griffel-babel-preset-5c7ca657-6f16-4831-add5-ec10fa461db1.json b/change/@griffel-babel-preset-5c7ca657-6f16-4831-add5-ec10fa461db1.json new file mode 100644 index 000000000..6c4e0d9eb --- /dev/null +++ b/change/@griffel-babel-preset-5c7ca657-6f16-4831-add5-ec10fa461db1.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "chore: migrate from TS path aliases to yarn workspaces + TS project references", + "packageName": "@griffel/babel-preset", + "email": "olfedias@microsoft.com", + "dependentChangeType": "none" +} diff --git a/change/@griffel-core-488ea0f9-cccb-4721-86a4-b2491be089ce.json b/change/@griffel-core-488ea0f9-cccb-4721-86a4-b2491be089ce.json new file mode 100644 index 000000000..b4e1d3ff1 --- /dev/null +++ b/change/@griffel-core-488ea0f9-cccb-4721-86a4-b2491be089ce.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "chore: migrate from TS path aliases to yarn workspaces + TS project references", + "packageName": "@griffel/core", + "email": "olfedias@microsoft.com", + "dependentChangeType": "none" +} diff --git a/change/@griffel-devtools-a0037621-c810-4227-b642-4dcad066cf08.json b/change/@griffel-devtools-a0037621-c810-4227-b642-4dcad066cf08.json new file mode 100644 index 000000000..912b88244 --- /dev/null +++ b/change/@griffel-devtools-a0037621-c810-4227-b642-4dcad066cf08.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "chore: migrate from TS path aliases to yarn workspaces + TS project references", + "packageName": "@griffel/devtools", + "email": "olfedias@microsoft.com", + "dependentChangeType": "none" +} diff --git a/change/@griffel-eslint-plugin-40aaef23-b998-4a26-a088-eb7c058b307b.json b/change/@griffel-eslint-plugin-40aaef23-b998-4a26-a088-eb7c058b307b.json new file mode 100644 index 000000000..99397391d --- /dev/null +++ b/change/@griffel-eslint-plugin-40aaef23-b998-4a26-a088-eb7c058b307b.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "chore: migrate from TS path aliases to yarn workspaces + TS project references", + "packageName": "@griffel/eslint-plugin", + "email": "olfedias@microsoft.com", + "dependentChangeType": "none" +} diff --git a/change/@griffel-jest-serializer-14b11c90-c293-4a16-9682-a278877a5ed6.json b/change/@griffel-jest-serializer-14b11c90-c293-4a16-9682-a278877a5ed6.json new file mode 100644 index 000000000..d45aef55b --- /dev/null +++ b/change/@griffel-jest-serializer-14b11c90-c293-4a16-9682-a278877a5ed6.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "chore: migrate from TS path aliases to yarn workspaces + TS project references", + "packageName": "@griffel/jest-serializer", + "email": "olfedias@microsoft.com", + "dependentChangeType": "none" +} diff --git a/change/@griffel-postcss-syntax-cf05402a-d49d-4061-9c0b-1942aad275f8.json b/change/@griffel-postcss-syntax-cf05402a-d49d-4061-9c0b-1942aad275f8.json new file mode 100644 index 000000000..5a5ccdcfc --- /dev/null +++ b/change/@griffel-postcss-syntax-cf05402a-d49d-4061-9c0b-1942aad275f8.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "chore: migrate from TS path aliases to yarn workspaces + TS project references", + "packageName": "@griffel/postcss-syntax", + "email": "olfedias@microsoft.com", + "dependentChangeType": "none" +} diff --git a/change/@griffel-react-bc97d453-9e78-491a-8956-522c5558ff31.json b/change/@griffel-react-bc97d453-9e78-491a-8956-522c5558ff31.json new file mode 100644 index 000000000..414d18f22 --- /dev/null +++ b/change/@griffel-react-bc97d453-9e78-491a-8956-522c5558ff31.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "chore: migrate from TS path aliases to yarn workspaces + TS project references", + "packageName": "@griffel/react", + "email": "olfedias@microsoft.com", + "dependentChangeType": "none" +} diff --git a/change/@griffel-shadow-dom-bdffa7d7-6265-4763-826e-0057fa91d215.json b/change/@griffel-shadow-dom-bdffa7d7-6265-4763-826e-0057fa91d215.json new file mode 100644 index 000000000..ca95a624e --- /dev/null +++ b/change/@griffel-shadow-dom-bdffa7d7-6265-4763-826e-0057fa91d215.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "chore: migrate from TS path aliases to yarn workspaces + TS project references", + "packageName": "@griffel/shadow-dom", + "email": "olfedias@microsoft.com", + "dependentChangeType": "none" +} diff --git a/change/@griffel-style-types-6312bb23-b468-4396-9648-72063566db45.json b/change/@griffel-style-types-6312bb23-b468-4396-9648-72063566db45.json new file mode 100644 index 000000000..852af0838 --- /dev/null +++ b/change/@griffel-style-types-6312bb23-b468-4396-9648-72063566db45.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "chore: migrate from TS path aliases to yarn workspaces + TS project references", + "packageName": "@griffel/style-types", + "email": "olfedias@microsoft.com", + "dependentChangeType": "none" +} diff --git a/change/@griffel-transform-87d14893-72a5-4b6e-8458-a4d4e5eb572e.json b/change/@griffel-transform-87d14893-72a5-4b6e-8458-a4d4e5eb572e.json new file mode 100644 index 000000000..99ae9642a --- /dev/null +++ b/change/@griffel-transform-87d14893-72a5-4b6e-8458-a4d4e5eb572e.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "chore: migrate from TS path aliases to yarn workspaces + TS project references", + "packageName": "@griffel/transform", + "email": "olfedias@microsoft.com", + "dependentChangeType": "none" +} diff --git a/change/@griffel-transform-shaker-0accdf23-15f3-4f87-bf5b-88581795b1e4.json b/change/@griffel-transform-shaker-0accdf23-15f3-4f87-bf5b-88581795b1e4.json new file mode 100644 index 000000000..503dbcf33 --- /dev/null +++ b/change/@griffel-transform-shaker-0accdf23-15f3-4f87-bf5b-88581795b1e4.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "chore: migrate from TS path aliases to yarn workspaces + TS project references", + "packageName": "@griffel/transform-shaker", + "email": "olfedias@microsoft.com", + "dependentChangeType": "none" +} diff --git a/change/@griffel-webpack-extraction-plugin-77ddbf00-8fb4-4a21-8093-48e6b5efc497.json b/change/@griffel-webpack-extraction-plugin-77ddbf00-8fb4-4a21-8093-48e6b5efc497.json new file mode 100644 index 000000000..36622c1d9 --- /dev/null +++ b/change/@griffel-webpack-extraction-plugin-77ddbf00-8fb4-4a21-8093-48e6b5efc497.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "chore: migrate from TS path aliases to yarn workspaces + TS project references", + "packageName": "@griffel/webpack-extraction-plugin", + "email": "olfedias@microsoft.com", + "dependentChangeType": "none" +} diff --git a/change/@griffel-webpack-loader-c5a41871-e1fe-49bd-915c-e24254eb6ede.json b/change/@griffel-webpack-loader-c5a41871-e1fe-49bd-915c-e24254eb6ede.json new file mode 100644 index 000000000..4d1236025 --- /dev/null +++ b/change/@griffel-webpack-loader-c5a41871-e1fe-49bd-915c-e24254eb6ede.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "chore: migrate from TS path aliases to yarn workspaces + TS project references", + "packageName": "@griffel/webpack-loader", + "email": "olfedias@microsoft.com", + "dependentChangeType": "none" +} diff --git a/change/@griffel-webpack-plugin-49de74bc-716f-43a5-a2b3-9892a585faba.json b/change/@griffel-webpack-plugin-49de74bc-716f-43a5-a2b3-9892a585faba.json new file mode 100644 index 000000000..88bd4433c --- /dev/null +++ b/change/@griffel-webpack-plugin-49de74bc-716f-43a5-a2b3-9892a585faba.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "chore: migrate from TS path aliases to yarn workspaces + TS project references", + "packageName": "@griffel/webpack-plugin", + "email": "olfedias@microsoft.com", + "dependentChangeType": "none" +} From 7bfa4a96f3309db0f19507585b63d9768e4375fb Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Thu, 21 May 2026 12:42:58 +0200 Subject: [PATCH 04/26] fix: address syncpack check-dependencies failures - Bump @typescript-eslint/utils to ^8.59.3 in root and packages/eslint-plugin/ so the version ranges align with the resolution we already pin. - Add version: 0.0.0 to apps/website/package.json so syncpack stops complaining about VERSION_IS_MISSING. Co-Authored-By: Claude Opus 4.7 (1M context) --- apps/website/package.json | 1 + package.json | 2 +- packages/eslint-plugin/package.json | 2 +- yarn.lock | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/website/package.json b/apps/website/package.json index 2b22f2eab..1bfafd394 100644 --- a/apps/website/package.json +++ b/apps/website/package.json @@ -1,5 +1,6 @@ { "name": "@griffel/website", + "version": "0.0.0", "description": "Docusaurus has update notifier that checks presence of package.json file, if it's missing it throws", "private": true } diff --git a/package.json b/package.json index 3414356e1..638e04dcf 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@emotion/hash": "^0.9.0", "@linaria/babel-preset": "^3.0.0-beta.24", "@linaria/shaker": "^3.0.0-beta.22", - "@typescript-eslint/utils": "^8.59.1", + "@typescript-eslint/utils": "^8.59.3", "ajv": "^8.20.0", "csstype": "^3.2.3", "debug": "^4.3.0", diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index e23213176..f07ec5ce4 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -9,7 +9,7 @@ "url": "https://github.com/microsoft/griffel" }, "dependencies": { - "@typescript-eslint/utils": "^8.59.1", + "@typescript-eslint/utils": "^8.59.3", "csstype": "^3.2.3", "tslib": "^2.1.0" }, diff --git a/yarn.lock b/yarn.lock index 137c0e296..03068825a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3809,7 +3809,7 @@ __metadata: version: 0.0.0-use.local resolution: "@griffel/eslint-plugin@workspace:packages/eslint-plugin" dependencies: - "@typescript-eslint/utils": "npm:^8.59.1" + "@typescript-eslint/utils": "npm:^8.59.3" csstype: "npm:^3.2.3" tslib: "npm:^2.1.0" peerDependencies: @@ -15252,7 +15252,7 @@ __metadata: "@types/stylis": "npm:4.2.7" "@types/webpack-env": "npm:1.18.4" "@typescript-eslint/rule-tester": "npm:^8.0.0" - "@typescript-eslint/utils": "npm:^8.59.1" + "@typescript-eslint/utils": "npm:^8.59.3" "@vitejs/plugin-react": "npm:^6.0.1" "@vitest/browser": "npm:4.1.5" "@vitest/browser-playwright": "npm:4.1.5" From 2ab0fa56098d6a18d73dc61ecbbef689080948dd Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Thu, 21 May 2026 12:43:50 +0200 Subject: [PATCH 05/26] fix(bundle-size): update monosize aliases to per-package dist/ layout Build outputs moved from `/dist/packages/X/src/` to `/packages/X/dist/` as part of the workspace migration. Co-Authored-By: Claude Opus 4.7 (1M context) --- monosize.config.mjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/monosize.config.mjs b/monosize.config.mjs index ead35cc79..7d58463d4 100644 --- a/monosize.config.mjs +++ b/monosize.config.mjs @@ -11,9 +11,9 @@ export default { resolve: { ...config.resolve, alias: { - '@griffel/core': path.resolve(dirname, './dist/packages/core/src/index.js'), - '@griffel/shadow-dom': path.resolve(dirname, './dist/packages/shadow-dom/src/index.js'), - '@griffel/react': path.resolve(dirname, './dist/packages/react/src/index.js'), + '@griffel/core': path.resolve(dirname, './packages/core/dist/index.js'), + '@griffel/shadow-dom': path.resolve(dirname, './packages/shadow-dom/dist/index.js'), + '@griffel/react': path.resolve(dirname, './packages/react/dist/index.js'), }, }, externals: { From aa19ca493a4e2d8a0935a67e083c6a847e421476 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Thu, 21 May 2026 13:30:39 +0200 Subject: [PATCH 06/26] fix(update-shorthands): import @griffel/core via package name Drop the workaround that imported from `../../../dist/packages/core/src/index.js` (broken anyway after the workspace migration moved build outputs). Add `resolve.conditions: ['@griffel/source']` to the package's vitest.config so the @griffel/source export condition resolves to core's TS source under test. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../src/filterShorthandsProperties.ts | 10 +--------- tools/update-shorthands/vitest.config.ts | 2 ++ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/tools/update-shorthands/src/filterShorthandsProperties.ts b/tools/update-shorthands/src/filterShorthandsProperties.ts index e114be85a..95f4a7299 100644 --- a/tools/update-shorthands/src/filterShorthandsProperties.ts +++ b/tools/update-shorthands/src/filterShorthandsProperties.ts @@ -1,12 +1,4 @@ -// TODO: prefer `import { UNSUPPORTED_CSS_PROPERTIES } from '@griffel/core'`. Today the -// workspace symlink resolves to packages/core which only ships .ts sources, and Node -// can't resolve the package.json `import` field (./src/index.js). Options to revisit: -// 1. A custom Node loader hook that rewrites @griffel/core to the dist path. -// 2. Repoint the node_modules/@griffel/core symlink at dist/packages/core post-build. -// 3. Add a "source" export condition to packages/core/package.json and run with -// `node --conditions=source`. -// 4. Inline the constant or read it from the source TS file directly. -import { UNSUPPORTED_CSS_PROPERTIES } from '../../../dist/packages/core/src/index.js'; +import { UNSUPPORTED_CSS_PROPERTIES } from '@griffel/core'; import type { MdnData, MdnShorthandProperty } from './types.ts'; import { isShorthandProperty, isVendorProperty, toCamelCase } from './utils.ts'; diff --git a/tools/update-shorthands/vitest.config.ts b/tools/update-shorthands/vitest.config.ts index e9a7300e5..37ff1d699 100644 --- a/tools/update-shorthands/vitest.config.ts +++ b/tools/update-shorthands/vitest.config.ts @@ -2,6 +2,8 @@ import { defineConfig } from 'vitest/config'; import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ + resolve: { conditions: ['@griffel/source'] }, + ssr: { resolve: { conditions: ['@griffel/source'] } }, root: __dirname, cacheDir: '../../node_modules/.vite/tools/update-shorthands', plugins: [nxViteTsPaths()], From ea697bba74fd5ef85f6e8fbcd602bbf87c5e6832 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Thu, 21 May 2026 14:18:01 +0200 Subject: [PATCH 07/26] fix(webpack-plugin): copy src/virtual-loader/ into dist/ during build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit webpackLoader.mts resolves its virtual-loader via path.resolve(__dirname, 'virtual-loader', 'index.cjs') — that path needs to exist next to the compiled .mjs in dist/. tsc only emits .ts/.mts files, so the .cjs loader was missing from dist/, breaking rspack's CSS extraction (no griffel chunk → null .files crash in processAssets). Co-Authored-By: Claude Opus 4.7 (1M context) --- packages/webpack-plugin/project.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/webpack-plugin/project.json b/packages/webpack-plugin/project.json index c1babf161..d8a3f51e1 100644 --- a/packages/webpack-plugin/project.json +++ b/packages/webpack-plugin/project.json @@ -16,7 +16,8 @@ "cwd": "packages/webpack-plugin", "commands": [ "tsc --build tsconfig.lib.json --pretty", - "node ../../tools/copy-pkg-assets.mjs packages/webpack-plugin" + "node ../../tools/copy-pkg-assets.mjs packages/webpack-plugin", + "node -e \"require('node:fs').cpSync('src/virtual-loader', 'dist/virtual-loader', { recursive: true })\"" ], "parallel": false } From 74f1069b83a35f31276b884e5d75360c93118efb Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Thu, 21 May 2026 18:59:05 +0200 Subject: [PATCH 08/26] chore: replace tools/copy-pkg-assets.mjs with a beachball prepublish hook MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Move the README/LICENSE staging from a per-build run-commands step into beachball's per-package `prepublish` hook. Build no longer touches these files; only publish does. - Drop tools/copy-pkg-assets.mjs and remove its invocation from every project.json build target. - Stop copying package.json into dist/ — `beachball publish` (and the matching `npm pack`) runs from the package root, so dist/package.json was dead weight. - Drop tools/deprecate-broken-release.mjs (one-off script no longer needed). - Drop CHANGELOG.md from every published package.json `files` field. - Drop the @griffel/* aliases from monosize.config.mjs — webpack now resolves them via the workspace symlink + exports map. - Drop the nxViteTsPaths() plugin from every vitest.config — there are no tsconfig paths left for it to expose; resolve.conditions: ["@griffel/source"] handles workspace resolution. - azure-pipelines.yml: add an explicit "Build all packages" step before the publish step, since the prepublish hook no longer triggers the build itself. Co-Authored-By: Claude Opus 4.7 (1M context) --- azure-pipelines.yml | 3 + beachball.hooks.js | 35 +++++++---- monosize.config.mjs | 11 ---- packages/babel-preset/package.json | 3 +- packages/babel-preset/project.json | 5 +- packages/babel-preset/vitest.config.mts | 2 - packages/core/package.json | 3 +- packages/core/project.json | 2 +- packages/core/vitest.config.ts | 6 +- packages/eslint-plugin/package.json | 3 +- packages/eslint-plugin/project.json | 5 +- packages/eslint-plugin/vitest.config.mts | 2 - packages/jest-serializer/package.json | 3 +- packages/jest-serializer/project.json | 5 +- packages/jest-serializer/vitest.config.mts | 2 - packages/postcss-syntax/package.json | 3 +- packages/postcss-syntax/project.json | 5 +- packages/postcss-syntax/vitest.config.mts | 2 - packages/react/package.json | 3 +- packages/react/project.json | 2 +- packages/react/vitest.config.ts | 2 - packages/shadow-dom/package.json | 3 +- packages/shadow-dom/project.json | 5 +- packages/shadow-dom/vitest.config.ts | 2 - packages/style-types/package.json | 3 +- packages/style-types/project.json | 5 +- packages/transform-shaker/package.json | 3 +- packages/transform-shaker/project.json | 5 +- packages/transform-shaker/vitest.config.mts | 2 - packages/transform/package.json | 3 +- packages/transform/project.json | 5 +- packages/transform/vitest.config.mts | 2 - .../webpack-extraction-plugin/package.json | 3 +- .../webpack-extraction-plugin/project.json | 5 +- .../vitest.config.mts | 2 - packages/webpack-loader/package.json | 3 +- packages/webpack-loader/project.json | 5 +- packages/webpack-loader/vitest.config.mts | 2 - packages/webpack-plugin/package.json | 3 +- packages/webpack-plugin/project.json | 1 - packages/webpack-plugin/vitest.config.mts | 2 - tools/copy-pkg-assets.mjs | 33 ----------- tools/deprecate-broken-release.mjs | 58 ------------------- tools/update-shorthands/vitest.config.ts | 2 - 44 files changed, 55 insertions(+), 209 deletions(-) delete mode 100644 tools/copy-pkg-assets.mjs delete mode 100644 tools/deprecate-broken-release.mjs diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b65763adf..900b45a19 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -51,6 +51,9 @@ extends: - script: yarn install --frozen-lockfile displayName: Install dependencies + - script: yarn nx run-many --target=build --all --parallel + displayName: Build all packages + - script: | git config user.name "Fluent UI Build" git config user.email "fluentui-internal@service.microsoft.com" diff --git a/beachball.hooks.js b/beachball.hooks.js index c5b5afa0c..91038d1c7 100644 --- a/beachball.hooks.js +++ b/beachball.hooks.js @@ -1,6 +1,8 @@ // @ts-check const childProcess = require('child_process'); +const fs = require('fs'); +const path = require('path'); /** * @param {String} command @@ -38,21 +40,34 @@ function sh(command) { }); } -let completedPrepublish = false; +const REPO_ROOT = __dirname; + +/** + * Make sure a workspace-rooted asset is present at the package root so `npm pack` + * picks it up via the `files` field. Falls back to copying the workspace-root copy + * when the package itself doesn't ship one (the LICENSE.md is shared across the + * monorepo; some packages also rely on the root README). + * + * @param {string} packagePath + * @param {string} asset + */ +function ensurePackageAsset(packagePath, asset) { + const target = path.join(packagePath, asset); + if (fs.existsSync(target)) return; + const source = path.join(REPO_ROOT, asset); + if (!fs.existsSync(source)) return; + fs.copyFileSync(source, target); +} /** * @type {import('beachball').BeachballConfig['hooks']} */ module.exports = { - // Executed after all package versions were bumped -> run build - // If we run build before `beachball publish`, artifacts would have - // old (without bump) versions. - async prepublish() { - // `beachball` runs this hook for every package, we want to run it only once. - if (!completedPrepublish) { - await sh('yarn nx run-many --target=build,build-cjs --all --parallel --max-parallel=3'); - completedPrepublish = true; - } + // Per-package: stage the workspace-root LICENSE/README into the package root so + // `npm pack` (which beachball runs from the package root) finds them via `files`. + async prepublish(packagePath) { + ensurePackageAsset(packagePath, 'LICENSE.md'); + ensurePackageAsset(packagePath, 'README.md'); }, // Runs once after all bumps, before committing — update lockfile so it stays in sync async precommit() { diff --git a/monosize.config.mjs b/monosize.config.mjs index 7d58463d4..092418793 100644 --- a/monosize.config.mjs +++ b/monosize.config.mjs @@ -1,21 +1,10 @@ -import path from 'node:path'; import upstashStorage from 'monosize-storage-upstash'; import webpackBundler from 'monosize-bundler-webpack'; -const dirname = new URL('.', import.meta.url).pathname; - export default { repository: 'https://github.com/microsoft/griffel', bundler: webpackBundler(config => ({ ...config, - resolve: { - ...config.resolve, - alias: { - '@griffel/core': path.resolve(dirname, './packages/core/dist/index.js'), - '@griffel/shadow-dom': path.resolve(dirname, './packages/shadow-dom/dist/index.js'), - '@griffel/react': path.resolve(dirname, './packages/react/dist/index.js'), - }, - }, externals: { ...config.externals, 'react/jsx-runtime': 'JSX', diff --git a/packages/babel-preset/package.json b/packages/babel-preset/package.json index ab1eadb69..f9f2a0516 100644 --- a/packages/babel-preset/package.json +++ b/packages/babel-preset/package.json @@ -33,7 +33,6 @@ "files": [ "dist/", "README.md", - "LICENSE.md", - "CHANGELOG.md" + "LICENSE.md" ] } diff --git a/packages/babel-preset/project.json b/packages/babel-preset/project.json index 3a73db360..c5a4f47a9 100644 --- a/packages/babel-preset/project.json +++ b/packages/babel-preset/project.json @@ -21,10 +21,7 @@ "outputs": ["{workspaceRoot}/packages/babel-preset/dist"], "options": { "cwd": "packages/babel-preset", - "commands": [ - "tsc --build tsconfig.build.json --pretty", - "node ../../tools/copy-pkg-assets.mjs packages/babel-preset" - ], + "commands": ["tsc --build tsconfig.build.json --pretty"], "parallel": false } } diff --git a/packages/babel-preset/vitest.config.mts b/packages/babel-preset/vitest.config.mts index fc73d2c91..302a066a9 100644 --- a/packages/babel-preset/vitest.config.mts +++ b/packages/babel-preset/vitest.config.mts @@ -1,12 +1,10 @@ import { defineConfig } from 'vitest/config'; -import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ resolve: { conditions: ['@griffel/source'] }, ssr: { resolve: { conditions: ['@griffel/source'] } }, root: __dirname, cacheDir: '../../node_modules/.vite/packages/babel-preset', - plugins: [nxViteTsPaths()], test: { watch: false, // babel-plugin-tester reads describe/it from globalThis at call time diff --git a/packages/core/package.json b/packages/core/package.json index 54b734c50..b79306d61 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -36,7 +36,6 @@ "files": [ "dist/", "README.md", - "LICENSE.md", - "CHANGELOG.md" + "LICENSE.md" ] } diff --git a/packages/core/project.json b/packages/core/project.json index 9bfcc0de9..8bc926733 100644 --- a/packages/core/project.json +++ b/packages/core/project.json @@ -41,7 +41,7 @@ "outputs": ["{workspaceRoot}/packages/core/dist"], "options": { "cwd": "packages/core", - "commands": ["tsc --build tsconfig.lib.json --pretty", "node ../../tools/copy-pkg-assets.mjs packages/core"], + "commands": ["tsc --build tsconfig.lib.json --pretty"], "parallel": false } } diff --git a/packages/core/vitest.config.ts b/packages/core/vitest.config.ts index e551c7e6c..43482346a 100644 --- a/packages/core/vitest.config.ts +++ b/packages/core/vitest.config.ts @@ -1,14 +1,12 @@ import { defineConfig } from 'vitest/config'; import { playwright } from '@vitest/browser-playwright'; import { defineBrowserCommand } from '@vitest/browser-playwright'; -import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ resolve: { conditions: ['@griffel/source'] }, ssr: { resolve: { conditions: ['@griffel/source'] } }, root: __dirname, cacheDir: '../../node_modules/.vite/packages/core', - plugins: [nxViteTsPaths()], test: { watch: false, reporters: ['default'], @@ -18,7 +16,7 @@ export default defineConfig({ }, projects: [ { - plugins: [nxViteTsPaths()], + plugins: [], test: { name: 'unit', environment: 'jsdom', @@ -27,7 +25,7 @@ export default defineConfig({ }, }, { - plugins: [nxViteTsPaths()], + plugins: [], test: { name: 'browser', include: ['{src,tests}/**/*.browser.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index f07ec5ce4..dc12c963f 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -29,7 +29,6 @@ "files": [ "dist/", "README.md", - "LICENSE.md", - "CHANGELOG.md" + "LICENSE.md" ] } diff --git a/packages/eslint-plugin/project.json b/packages/eslint-plugin/project.json index e2bb5f7c6..efb3abc9d 100644 --- a/packages/eslint-plugin/project.json +++ b/packages/eslint-plugin/project.json @@ -18,10 +18,7 @@ "outputs": ["{workspaceRoot}/packages/eslint-plugin/dist"], "options": { "cwd": "packages/eslint-plugin", - "commands": [ - "tsc --build tsconfig.lib.json --pretty", - "node ../../tools/copy-pkg-assets.mjs packages/eslint-plugin" - ], + "commands": ["tsc --build tsconfig.lib.json --pretty"], "parallel": false } } diff --git a/packages/eslint-plugin/vitest.config.mts b/packages/eslint-plugin/vitest.config.mts index 268b91cb5..ffb78c8f9 100644 --- a/packages/eslint-plugin/vitest.config.mts +++ b/packages/eslint-plugin/vitest.config.mts @@ -1,12 +1,10 @@ import { defineConfig } from 'vitest/config'; -import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ resolve: { conditions: ['@griffel/source'] }, ssr: { resolve: { conditions: ['@griffel/source'] } }, root: __dirname, cacheDir: '../../node_modules/.vite/packages/eslint-plugin', - plugins: [nxViteTsPaths()], test: { watch: false, // @typescript-eslint/rule-tester reads describe/it from globalThis at call time diff --git a/packages/jest-serializer/package.json b/packages/jest-serializer/package.json index eb94935ad..9ca5aea56 100644 --- a/packages/jest-serializer/package.json +++ b/packages/jest-serializer/package.json @@ -24,7 +24,6 @@ "files": [ "dist/", "README.md", - "LICENSE.md", - "CHANGELOG.md" + "LICENSE.md" ] } diff --git a/packages/jest-serializer/project.json b/packages/jest-serializer/project.json index 83386eebe..30ec2a92a 100644 --- a/packages/jest-serializer/project.json +++ b/packages/jest-serializer/project.json @@ -21,10 +21,7 @@ "outputs": ["{workspaceRoot}/packages/jest-serializer/dist"], "options": { "cwd": "packages/jest-serializer", - "commands": [ - "tsc --build tsconfig.build.json --pretty", - "node ../../tools/copy-pkg-assets.mjs packages/jest-serializer" - ], + "commands": ["tsc --build tsconfig.build.json --pretty"], "parallel": false } } diff --git a/packages/jest-serializer/vitest.config.mts b/packages/jest-serializer/vitest.config.mts index 7fb7276dc..188916696 100644 --- a/packages/jest-serializer/vitest.config.mts +++ b/packages/jest-serializer/vitest.config.mts @@ -1,12 +1,10 @@ import { defineConfig } from 'vitest/config'; -import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ resolve: { conditions: ['@griffel/source'] }, ssr: { resolve: { conditions: ['@griffel/source'] } }, root: __dirname, cacheDir: '../../node_modules/.vite/packages/jest-serializer', - plugins: [nxViteTsPaths()], test: { watch: false, environment: 'jsdom', diff --git a/packages/postcss-syntax/package.json b/packages/postcss-syntax/package.json index 913883077..66831a367 100644 --- a/packages/postcss-syntax/package.json +++ b/packages/postcss-syntax/package.json @@ -26,7 +26,6 @@ "files": [ "dist/", "README.md", - "LICENSE.md", - "CHANGELOG.md" + "LICENSE.md" ] } diff --git a/packages/postcss-syntax/project.json b/packages/postcss-syntax/project.json index b5c61cc0d..4a2e96ae0 100644 --- a/packages/postcss-syntax/project.json +++ b/packages/postcss-syntax/project.json @@ -21,10 +21,7 @@ "outputs": ["{workspaceRoot}/packages/postcss-syntax/dist"], "options": { "cwd": "packages/postcss-syntax", - "commands": [ - "tsc --build tsconfig.lib.json --pretty", - "node ../../tools/copy-pkg-assets.mjs packages/postcss-syntax" - ], + "commands": ["tsc --build tsconfig.lib.json --pretty"], "parallel": false } } diff --git a/packages/postcss-syntax/vitest.config.mts b/packages/postcss-syntax/vitest.config.mts index 4417251cf..564e80a78 100644 --- a/packages/postcss-syntax/vitest.config.mts +++ b/packages/postcss-syntax/vitest.config.mts @@ -1,12 +1,10 @@ import { defineConfig } from 'vitest/config'; -import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ resolve: { conditions: ['@griffel/source'] }, ssr: { resolve: { conditions: ['@griffel/source'] } }, root: __dirname, cacheDir: '../../node_modules/.vite/packages/postcss-syntax', - plugins: [nxViteTsPaths()], test: { watch: false, environment: 'node', diff --git a/packages/react/package.json b/packages/react/package.json index 106a5e62b..6cb74539f 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -41,7 +41,6 @@ "files": [ "dist/", "README.md", - "LICENSE.md", - "CHANGELOG.md" + "LICENSE.md" ] } diff --git a/packages/react/project.json b/packages/react/project.json index 354722034..705f0598a 100644 --- a/packages/react/project.json +++ b/packages/react/project.json @@ -66,7 +66,7 @@ "outputs": ["{workspaceRoot}/packages/react/dist"], "options": { "cwd": "packages/react", - "commands": ["tsc --build tsconfig.lib.json --pretty", "node ../../tools/copy-pkg-assets.mjs packages/react"], + "commands": ["tsc --build tsconfig.lib.json --pretty"], "parallel": false } } diff --git a/packages/react/vitest.config.ts b/packages/react/vitest.config.ts index 45cbd276e..5b1c62ae4 100644 --- a/packages/react/vitest.config.ts +++ b/packages/react/vitest.config.ts @@ -1,12 +1,10 @@ import { defineConfig } from 'vitest/config'; -import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ resolve: { conditions: ['@griffel/source'] }, ssr: { resolve: { conditions: ['@griffel/source'] } }, root: __dirname, cacheDir: '../../node_modules/.vite/packages/react', - plugins: [nxViteTsPaths()], define: { IS_REACT_ACT_ENVIRONMENT: true, }, diff --git a/packages/shadow-dom/package.json b/packages/shadow-dom/package.json index cbd745383..c3eefaf15 100644 --- a/packages/shadow-dom/package.json +++ b/packages/shadow-dom/package.json @@ -32,7 +32,6 @@ "files": [ "dist/", "README.md", - "LICENSE.md", - "CHANGELOG.md" + "LICENSE.md" ] } diff --git a/packages/shadow-dom/project.json b/packages/shadow-dom/project.json index 769691315..f9312ca55 100644 --- a/packages/shadow-dom/project.json +++ b/packages/shadow-dom/project.json @@ -66,10 +66,7 @@ "outputs": ["{workspaceRoot}/packages/shadow-dom/dist"], "options": { "cwd": "packages/shadow-dom", - "commands": [ - "tsc --build tsconfig.lib.json --pretty", - "node ../../tools/copy-pkg-assets.mjs packages/shadow-dom" - ], + "commands": ["tsc --build tsconfig.lib.json --pretty"], "parallel": false } } diff --git a/packages/shadow-dom/vitest.config.ts b/packages/shadow-dom/vitest.config.ts index 39769efa0..697a9e312 100644 --- a/packages/shadow-dom/vitest.config.ts +++ b/packages/shadow-dom/vitest.config.ts @@ -1,12 +1,10 @@ import { defineConfig } from 'vitest/config'; -import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ resolve: { conditions: ['@griffel/source'] }, ssr: { resolve: { conditions: ['@griffel/source'] } }, root: __dirname, cacheDir: '../../node_modules/.vite/packages/shadow-dom', - plugins: [nxViteTsPaths()], test: { watch: false, environment: 'jsdom', diff --git a/packages/style-types/package.json b/packages/style-types/package.json index 015e14173..dd878a9a2 100644 --- a/packages/style-types/package.json +++ b/packages/style-types/package.json @@ -24,7 +24,6 @@ "files": [ "dist/", "README.md", - "LICENSE.md", - "CHANGELOG.md" + "LICENSE.md" ] } diff --git a/packages/style-types/project.json b/packages/style-types/project.json index 17c5287b3..01a334a60 100644 --- a/packages/style-types/project.json +++ b/packages/style-types/project.json @@ -10,10 +10,7 @@ "outputs": ["{workspaceRoot}/packages/style-types/dist"], "options": { "cwd": "packages/style-types", - "commands": [ - "tsc --build tsconfig.lib.json --pretty", - "node ../../tools/copy-pkg-assets.mjs packages/style-types" - ], + "commands": ["tsc --build tsconfig.lib.json --pretty"], "parallel": false } }, diff --git a/packages/transform-shaker/package.json b/packages/transform-shaker/package.json index b0fe71a1a..a55e740da 100644 --- a/packages/transform-shaker/package.json +++ b/packages/transform-shaker/package.json @@ -27,7 +27,6 @@ "files": [ "dist/", "README.md", - "LICENSE.md", - "CHANGELOG.md" + "LICENSE.md" ] } diff --git a/packages/transform-shaker/project.json b/packages/transform-shaker/project.json index 3c8b6159e..49eda110b 100644 --- a/packages/transform-shaker/project.json +++ b/packages/transform-shaker/project.json @@ -21,10 +21,7 @@ "outputs": ["{workspaceRoot}/packages/transform-shaker/dist"], "options": { "cwd": "packages/transform-shaker", - "commands": [ - "tsc --build tsconfig.lib.json --pretty", - "node ../../tools/copy-pkg-assets.mjs packages/transform-shaker" - ], + "commands": ["tsc --build tsconfig.lib.json --pretty"], "parallel": false } } diff --git a/packages/transform-shaker/vitest.config.mts b/packages/transform-shaker/vitest.config.mts index 52f6c094f..df1ef8359 100644 --- a/packages/transform-shaker/vitest.config.mts +++ b/packages/transform-shaker/vitest.config.mts @@ -1,12 +1,10 @@ import { defineConfig } from 'vitest/config'; -import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ resolve: { conditions: ['@griffel/source'] }, ssr: { resolve: { conditions: ['@griffel/source'] } }, root: __dirname, cacheDir: '../../node_modules/.vite/packages/transform-shaker', - plugins: [nxViteTsPaths()], test: { watch: false, passWithNoTests: true, diff --git a/packages/transform/package.json b/packages/transform/package.json index e386d458f..a6392d0ff 100644 --- a/packages/transform/package.json +++ b/packages/transform/package.json @@ -29,7 +29,6 @@ "files": [ "dist/", "README.md", - "LICENSE.md", - "CHANGELOG.md" + "LICENSE.md" ] } diff --git a/packages/transform/project.json b/packages/transform/project.json index eb8f9d406..9a74244d4 100644 --- a/packages/transform/project.json +++ b/packages/transform/project.json @@ -21,10 +21,7 @@ "outputs": ["{workspaceRoot}/packages/transform/dist"], "options": { "cwd": "packages/transform", - "commands": [ - "tsc --build tsconfig.lib.json --pretty", - "node ../../tools/copy-pkg-assets.mjs packages/transform" - ], + "commands": ["tsc --build tsconfig.lib.json --pretty"], "parallel": false } } diff --git a/packages/transform/vitest.config.mts b/packages/transform/vitest.config.mts index 5eaaf9b04..31851c11a 100644 --- a/packages/transform/vitest.config.mts +++ b/packages/transform/vitest.config.mts @@ -1,12 +1,10 @@ import { defineConfig } from 'vitest/config'; -import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ resolve: { conditions: ['@griffel/source'] }, ssr: { resolve: { conditions: ['@griffel/source'] } }, root: __dirname, cacheDir: '../../node_modules/.vite/packages/transform', - plugins: [nxViteTsPaths()], test: { watch: false, environment: 'node', diff --git a/packages/webpack-extraction-plugin/package.json b/packages/webpack-extraction-plugin/package.json index 1b4f3edba..65531f24f 100644 --- a/packages/webpack-extraction-plugin/package.json +++ b/packages/webpack-extraction-plugin/package.json @@ -32,7 +32,6 @@ "virtual-loader/", "dist/", "README.md", - "LICENSE.md", - "CHANGELOG.md" + "LICENSE.md" ] } diff --git a/packages/webpack-extraction-plugin/project.json b/packages/webpack-extraction-plugin/project.json index 5febe76ec..d9b1baa7e 100644 --- a/packages/webpack-extraction-plugin/project.json +++ b/packages/webpack-extraction-plugin/project.json @@ -21,10 +21,7 @@ "outputs": ["{workspaceRoot}/packages/webpack-extraction-plugin/dist"], "options": { "cwd": "packages/webpack-extraction-plugin", - "commands": [ - "tsc --build tsconfig.build.json --pretty", - "node ../../tools/copy-pkg-assets.mjs packages/webpack-extraction-plugin" - ], + "commands": ["tsc --build tsconfig.build.json --pretty"], "parallel": false } } diff --git a/packages/webpack-extraction-plugin/vitest.config.mts b/packages/webpack-extraction-plugin/vitest.config.mts index 2f0e51d6a..a6025a328 100644 --- a/packages/webpack-extraction-plugin/vitest.config.mts +++ b/packages/webpack-extraction-plugin/vitest.config.mts @@ -1,12 +1,10 @@ import { defineConfig } from 'vitest/config'; -import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ resolve: { conditions: ['@griffel/source'] }, ssr: { resolve: { conditions: ['@griffel/source'] } }, root: __dirname, cacheDir: '../../node_modules/.vite/packages/webpack-extraction-plugin', - plugins: [nxViteTsPaths()], test: { watch: false, // babel-plugin-tester reads describe/it from globalThis at call time diff --git a/packages/webpack-loader/package.json b/packages/webpack-loader/package.json index 7d032ea5e..634834696 100644 --- a/packages/webpack-loader/package.json +++ b/packages/webpack-loader/package.json @@ -29,7 +29,6 @@ "files": [ "dist/", "README.md", - "LICENSE.md", - "CHANGELOG.md" + "LICENSE.md" ] } diff --git a/packages/webpack-loader/project.json b/packages/webpack-loader/project.json index 3b80494ef..98c2525ef 100644 --- a/packages/webpack-loader/project.json +++ b/packages/webpack-loader/project.json @@ -21,10 +21,7 @@ "outputs": ["{workspaceRoot}/packages/webpack-loader/dist"], "options": { "cwd": "packages/webpack-loader", - "commands": [ - "tsc --build tsconfig.lib.json --pretty", - "node ../../tools/copy-pkg-assets.mjs packages/webpack-loader" - ], + "commands": ["tsc --build tsconfig.lib.json --pretty"], "parallel": false } } diff --git a/packages/webpack-loader/vitest.config.mts b/packages/webpack-loader/vitest.config.mts index 2a7e8c4dd..ac04bb2ac 100644 --- a/packages/webpack-loader/vitest.config.mts +++ b/packages/webpack-loader/vitest.config.mts @@ -1,12 +1,10 @@ import { defineConfig } from 'vitest/config'; -import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ resolve: { conditions: ['@griffel/source'] }, ssr: { resolve: { conditions: ['@griffel/source'] } }, root: __dirname, cacheDir: '../../node_modules/.vite/packages/webpack-loader', - plugins: [nxViteTsPaths()], test: { watch: false, environment: 'node', diff --git a/packages/webpack-plugin/package.json b/packages/webpack-plugin/package.json index 5c717ed01..8ea786c23 100644 --- a/packages/webpack-plugin/package.json +++ b/packages/webpack-plugin/package.json @@ -35,7 +35,6 @@ "files": [ "dist/", "README.md", - "LICENSE.md", - "CHANGELOG.md" + "LICENSE.md" ] } diff --git a/packages/webpack-plugin/project.json b/packages/webpack-plugin/project.json index d8a3f51e1..ec1eb0241 100644 --- a/packages/webpack-plugin/project.json +++ b/packages/webpack-plugin/project.json @@ -16,7 +16,6 @@ "cwd": "packages/webpack-plugin", "commands": [ "tsc --build tsconfig.lib.json --pretty", - "node ../../tools/copy-pkg-assets.mjs packages/webpack-plugin", "node -e \"require('node:fs').cpSync('src/virtual-loader', 'dist/virtual-loader', { recursive: true })\"" ], "parallel": false diff --git a/packages/webpack-plugin/vitest.config.mts b/packages/webpack-plugin/vitest.config.mts index fd385af1a..295c739d2 100644 --- a/packages/webpack-plugin/vitest.config.mts +++ b/packages/webpack-plugin/vitest.config.mts @@ -1,12 +1,10 @@ import { defineConfig } from 'vitest/config'; -import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ resolve: { conditions: ['@griffel/source'] }, ssr: { resolve: { conditions: ['@griffel/source'] } }, root: __dirname, cacheDir: '../../node_modules/.vite/packages/webpack-plugin', - plugins: [nxViteTsPaths()], test: { watch: false, environment: 'node', diff --git a/tools/copy-pkg-assets.mjs b/tools/copy-pkg-assets.mjs deleted file mode 100644 index 4f96ac6ca..000000000 --- a/tools/copy-pkg-assets.mjs +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copies package.json, README.md, LICENSE.md into the package's dist/. - * - * Usage: node tools/copy-pkg-assets.mjs - * - * Reads /{package.json,README.md} and copies them along with - * the workspace-root LICENSE.md into /dist/. - */ -import { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'; -import { dirname, join, resolve } from 'node:path'; -import { fileURLToPath } from 'node:url'; - -const [pkgDir] = process.argv.slice(2); -if (!pkgDir) { - console.error('Usage: node tools/copy-pkg-assets.mjs '); - process.exit(1); -} - -const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..'); -const absPkg = resolve(repoRoot, pkgDir); -const distDir = join(absPkg, 'dist'); - -mkdirSync(distDir, { recursive: true }); - -const pkgJson = JSON.parse(readFileSync(join(absPkg, 'package.json'), 'utf8')); -delete pkgJson.scripts; -delete pkgJson.devDependencies; -writeFileSync(join(distDir, 'package.json'), JSON.stringify(pkgJson, null, 2) + '\n'); - -for (const f of ['README.md', 'LICENSE.md']) { - const src = existsSync(join(absPkg, f)) ? join(absPkg, f) : join(repoRoot, f); - if (existsSync(src)) copyFileSync(src, join(distDir, f)); -} diff --git a/tools/deprecate-broken-release.mjs b/tools/deprecate-broken-release.mjs deleted file mode 100644 index b30bba7f0..000000000 --- a/tools/deprecate-broken-release.mjs +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Deprecates the broken versions published by commit ef0b28a1. - * - * Usage: - * node tools/deprecate-broken-release.mjs # dry-run, prints commands - * node tools/deprecate-broken-release.mjs --apply # actually run npm deprecate - * - * Requires being logged in to npm with publish rights for @griffel/*. - */ -import { spawnSync } from 'node:child_process'; - -const MESSAGE = - 'This version was published from a broken build artifact (commit ef0b28a1). ' + - 'Please upgrade to the next patch release.'; - -const VERSIONS = { - '@griffel/babel-preset': '1.8.5', - '@griffel/core': '1.21.1', - '@griffel/devtools': '0.3.11', - '@griffel/eslint-plugin': '3.0.1', - '@griffel/jest-serializer': '1.1.40', - '@griffel/postcss-syntax': '1.3.11', - '@griffel/react': '1.7.3', - '@griffel/shadow-dom': '0.2.16', - '@griffel/style-types': '1.4.1', - '@griffel/transform': '3.0.5', - '@griffel/transform-shaker': '1.0.6', - '@griffel/webpack-extraction-plugin': '0.5.18', - '@griffel/webpack-loader': '2.2.27', - '@griffel/webpack-plugin': '4.0.5', -}; - -const apply = process.argv.includes('--apply'); - -if (!apply) { - console.log('Dry-run. Pass --apply to actually deprecate.\n'); -} - -let failed = 0; -for (const [name, version] of Object.entries(VERSIONS)) { - const spec = `${name}@${version}`; - const args = ['deprecate', spec, MESSAGE]; - - console.log(`npm ${args.map(a => (a.includes(' ') ? JSON.stringify(a) : a)).join(' ')}`); - - if (!apply) continue; - - const result = spawnSync('npm', args, { stdio: 'inherit' }); - if (result.status !== 0) { - console.error(` failed (exit ${result.status})`); - failed++; - } -} - -if (apply) { - console.log(`\nDone. ${failed === 0 ? 'All deprecations succeeded.' : `${failed} failed.`}`); - process.exit(failed === 0 ? 0 : 1); -} diff --git a/tools/update-shorthands/vitest.config.ts b/tools/update-shorthands/vitest.config.ts index 37ff1d699..ec0599ac9 100644 --- a/tools/update-shorthands/vitest.config.ts +++ b/tools/update-shorthands/vitest.config.ts @@ -1,12 +1,10 @@ import { defineConfig } from 'vitest/config'; -import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ resolve: { conditions: ['@griffel/source'] }, ssr: { resolve: { conditions: ['@griffel/source'] } }, root: __dirname, cacheDir: '../../node_modules/.vite/tools/update-shorthands', - plugins: [nxViteTsPaths()], test: { watch: false, environment: 'node', From bb5404d9217baf2854542a5974f923e06e49cbab Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Thu, 21 May 2026 19:09:23 +0200 Subject: [PATCH 09/26] chore(website): re-enable composite + add to project references graph MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Drop noEmit and switch composite back to true so apps/website participates in the workspace's tsc -b graph again. Reference it from the root tsconfig.json so the @nx/js/typescript plugin can infer a type-check target. The Playground code/templates/* JS files are loaded as raw strings via webpack require.context (not compiled), so exclude them from the tsconfig include — they were tripping TS2742 ("inferred default type not portable") when composite emit walked into @griffel/core's source. Co-Authored-By: Claude Opus 4.7 (1M context) --- apps/website/tsconfig.json | 4 ++-- tsconfig.json | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/website/tsconfig.json b/apps/website/tsconfig.json index 4db04bcb7..1e96c6bef 100644 --- a/apps/website/tsconfig.json +++ b/apps/website/tsconfig.json @@ -5,7 +5,6 @@ "allowSyntheticDefaultImports": true, "checkJs": true, "jsx": "react", - "noEmit": true, "outDir": "./out-tsc", "types": [ "../../node_modules/@docusaurus/module-type-aliases", @@ -14,9 +13,10 @@ "static-assets", "webpack-env" ], - "composite": false + "composite": true }, "include": ["./src/**/*.ts", "./src/**/*.tsx", "./src/**/*.js"], + "exclude": ["./src/components/Playground/code/templates/**"], "references": [ { "path": "../../packages/core" diff --git a/tsconfig.json b/tsconfig.json index 180eacece..50cfe075c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -58,6 +58,9 @@ }, { "path": "./tools/update-shorthands" + }, + { + "path": "./apps/website" } ] } From edd6f1b42caa869439b268b0ee672bfb4036b8c7 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Thu, 21 May 2026 19:10:22 +0200 Subject: [PATCH 10/26] chore(website): emit to per-package dist/ Match the per-package dist/ layout the rest of the workspace is moving to. Docusaurus now builds into apps/website/dist instead of /dist/apps/website. .github/workflows/deploy.yml: point the Pages artifact upload at the new path. Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/deploy.yml | 2 +- apps/website/project.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index fcacffab0..46d826245 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -33,7 +33,7 @@ jobs: - name: Upload artifacts uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0 with: - path: './dist/apps/website' + path: './apps/website/dist' deploy: needs: build diff --git a/apps/website/project.json b/apps/website/project.json index 83b1ff447..2e31bceb1 100644 --- a/apps/website/project.json +++ b/apps/website/project.json @@ -10,11 +10,11 @@ "cwd": "apps/website", "commands": [ { - "command": "docusaurus build --out-dir ../../dist/apps/website" + "command": "docusaurus build --out-dir ./dist" } ] }, - "outputs": ["{workspaceRoot}/dist/apps/website"] + "outputs": ["{workspaceRoot}/apps/website/dist"] }, "serve": { "executor": "nx:run-commands", From a37f118c976b2850bf2abe9c999bf58e9b32c3da Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Thu, 21 May 2026 19:11:07 +0200 Subject: [PATCH 11/26] chore(e2e-eslint): pin internal deps to exact versions Switch the @griffel/* devDependencies from workspace:* to the exact published versions (matching what's published on npm + the workspace's @griffel/e2e-utils at "*" since it's a private workspace package). Co-Authored-By: Claude Opus 4.7 (1M context) --- e2e/eslint/package.json | 6 +++--- yarn.lock | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/e2e/eslint/package.json b/e2e/eslint/package.json index 65c2d105d..b3cc92edf 100644 --- a/e2e/eslint/package.json +++ b/e2e/eslint/package.json @@ -4,8 +4,8 @@ "private": true, "type": "module", "devDependencies": { - "@griffel/e2e-utils": "workspace:*", - "@griffel/eslint-plugin": "workspace:*", - "@griffel/react": "workspace:*" + "@griffel/e2e-utils": "*", + "@griffel/eslint-plugin": "3.0.2", + "@griffel/react": "1.7.4" } } diff --git a/yarn.lock b/yarn.lock index 03068825a..90b1eaa31 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3772,9 +3772,9 @@ __metadata: version: 0.0.0-use.local resolution: "@griffel/e2e-eslint@workspace:e2e/eslint" dependencies: - "@griffel/e2e-utils": "workspace:*" - "@griffel/eslint-plugin": "workspace:*" - "@griffel/react": "workspace:*" + "@griffel/e2e-utils": "npm:*" + "@griffel/eslint-plugin": "npm:3.0.2" + "@griffel/react": "npm:1.7.4" languageName: unknown linkType: soft @@ -3805,7 +3805,7 @@ __metadata: languageName: unknown linkType: soft -"@griffel/eslint-plugin@workspace:*, @griffel/eslint-plugin@workspace:packages/eslint-plugin": +"@griffel/eslint-plugin@npm:3.0.2, @griffel/eslint-plugin@workspace:packages/eslint-plugin": version: 0.0.0-use.local resolution: "@griffel/eslint-plugin@workspace:packages/eslint-plugin" dependencies: @@ -3837,7 +3837,7 @@ __metadata: languageName: unknown linkType: soft -"@griffel/react@npm:^1.7.4, @griffel/react@workspace:*, @griffel/react@workspace:packages/react": +"@griffel/react@npm:1.7.4, @griffel/react@npm:^1.7.4, @griffel/react@workspace:packages/react": version: 0.0.0-use.local resolution: "@griffel/react@workspace:packages/react" dependencies: From e46529625948c5ef04878af8efa39ba8e0fcc427 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Thu, 21 May 2026 19:14:05 +0200 Subject: [PATCH 12/26] chore(syncpack): enforce caret range on internal @griffel/* deps Add a semverGroups rule so any semver-pinned @griffel/* internal dep must use a caret. The "*" workspace marker (used by private packages like @griffel/e2e-utils) is excluded via the specifierTypes filter. Restore the carets on e2e/eslint's published @griffel/* devDeps (@griffel/eslint-plugin, @griffel/react) which the rule now enforces. Co-Authored-By: Claude Opus 4.7 (1M context) --- .syncpackrc.json | 8 ++++++++ e2e/eslint/package.json | 4 ++-- yarn.lock | 8 ++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.syncpackrc.json b/.syncpackrc.json index 784eacb0a..9bfd85357 100644 --- a/.syncpackrc.json +++ b/.syncpackrc.json @@ -1,6 +1,14 @@ { "$schema": "./node_modules/syncpack/schema.json", "strict": true, + "semverGroups": [ + { + "label": "Internal @griffel/* deps must use a caret range when semver-pinned", + "dependencies": ["@griffel/*"], + "specifierTypes": ["exact", "range-major", "range-minor", "range"], + "range": "^" + } + ], "versionGroups": [ { "label": "Local @griffel/* cross-package deps must use the same caret range everywhere", diff --git a/e2e/eslint/package.json b/e2e/eslint/package.json index b3cc92edf..7f938aa98 100644 --- a/e2e/eslint/package.json +++ b/e2e/eslint/package.json @@ -5,7 +5,7 @@ "type": "module", "devDependencies": { "@griffel/e2e-utils": "*", - "@griffel/eslint-plugin": "3.0.2", - "@griffel/react": "1.7.4" + "@griffel/eslint-plugin": "^3.0.2", + "@griffel/react": "^1.7.4" } } diff --git a/yarn.lock b/yarn.lock index 90b1eaa31..424783e35 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3773,8 +3773,8 @@ __metadata: resolution: "@griffel/e2e-eslint@workspace:e2e/eslint" dependencies: "@griffel/e2e-utils": "npm:*" - "@griffel/eslint-plugin": "npm:3.0.2" - "@griffel/react": "npm:1.7.4" + "@griffel/eslint-plugin": "npm:^3.0.2" + "@griffel/react": "npm:^1.7.4" languageName: unknown linkType: soft @@ -3805,7 +3805,7 @@ __metadata: languageName: unknown linkType: soft -"@griffel/eslint-plugin@npm:3.0.2, @griffel/eslint-plugin@workspace:packages/eslint-plugin": +"@griffel/eslint-plugin@npm:^3.0.2, @griffel/eslint-plugin@workspace:packages/eslint-plugin": version: 0.0.0-use.local resolution: "@griffel/eslint-plugin@workspace:packages/eslint-plugin" dependencies: @@ -3837,7 +3837,7 @@ __metadata: languageName: unknown linkType: soft -"@griffel/react@npm:1.7.4, @griffel/react@npm:^1.7.4, @griffel/react@workspace:packages/react": +"@griffel/react@npm:^1.7.4, @griffel/react@workspace:packages/react": version: 0.0.0-use.local resolution: "@griffel/react@workspace:packages/react" dependencies: From cb361e9744c353b37b06d1c2e879b797a8cfc299 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Thu, 21 May 2026 19:18:05 +0200 Subject: [PATCH 13/26] chore(style-types): drop explicit build target, rely on @nx/js/typescript MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Configure the @nx/js/typescript plugin to also infer a `build` target (in addition to type-check) from each package's tsconfig.lib.json. Drop the redundant nx:run-commands "build" from style-types/project.json — the inferred target runs the same `tsc --build tsconfig.lib.json`. The other published packages keep their explicit build targets for now (build-cjs chains, asset copies, etc.); they migrate package by package as the workspace migration progresses. Co-Authored-By: Claude Opus 4.7 (1M context) --- nx.json | 4 ++++ packages/style-types/project.json | 9 --------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/nx.json b/nx.json index b0c3c2d2f..c3ae715f7 100644 --- a/nx.json +++ b/nx.json @@ -35,6 +35,10 @@ "options": { "typecheck": { "targetName": "type-check" + }, + "build": { + "targetName": "build", + "configName": "tsconfig.lib.json" } } } diff --git a/packages/style-types/project.json b/packages/style-types/project.json index 01a334a60..4ab68f63d 100644 --- a/packages/style-types/project.json +++ b/packages/style-types/project.json @@ -5,15 +5,6 @@ "projectType": "library", "tags": [], "targets": { - "build": { - "executor": "nx:run-commands", - "outputs": ["{workspaceRoot}/packages/style-types/dist"], - "options": { - "cwd": "packages/style-types", - "commands": ["tsc --build tsconfig.lib.json --pretty"], - "parallel": false - } - }, "lint": { "executor": "@nx/eslint:lint", "outputs": ["{options.outputFile}"] From 38497ce2843012ddedbfc7b29bb8cf9ae6ab2fe1 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Thu, 21 May 2026 19:21:58 +0200 Subject: [PATCH 14/26] chore: simplify project.json/exports for transform + e2e-utils MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - packages/transform: drop explicit build target — @nx/js/typescript infers it from tsconfig.lib.json, identical to the explicit one. - e2e/utils: collapse the single-target exports map to the short form ("./src/index.ts"). e2e-utils is a private workspace package; no consumer benefits from the explicit conditions. Co-Authored-By: Claude Opus 4.7 (1M context) --- e2e/utils/package.json | 7 +------ packages/transform/project.json | 9 --------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/e2e/utils/package.json b/e2e/utils/package.json index 99b33930f..38ee26cdf 100644 --- a/e2e/utils/package.json +++ b/e2e/utils/package.json @@ -4,11 +4,6 @@ "private": true, "type": "module", "exports": { - ".": { - "@griffel/source": "./src/index.ts", - "types": "./src/index.ts", - "default": "./src/index.ts" - }, - "./package.json": "./package.json" + ".": "./src/index.ts" } } diff --git a/packages/transform/project.json b/packages/transform/project.json index 9a74244d4..61f190608 100644 --- a/packages/transform/project.json +++ b/packages/transform/project.json @@ -15,15 +15,6 @@ "options": { "reportsDirectory": "{projectRoot}/../../coverage/packages/transform" } - }, - "build": { - "executor": "nx:run-commands", - "outputs": ["{workspaceRoot}/packages/transform/dist"], - "options": { - "cwd": "packages/transform", - "commands": ["tsc --build tsconfig.lib.json --pretty"], - "parallel": false - } } } } From 2515080092f7608d22f14136f50ca1141d99e618 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Fri, 22 May 2026 12:16:38 +0200 Subject: [PATCH 15/26] chore(babel-preset): collapse tsconfig.build.json into tsconfig.lib.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Drop the explicit build target — @nx/js/typescript can now infer it. Merge the two-config setup into one: - Move the CJS build settings (module: node16, declaration: true, customConditions: [], outDir: ./dist) into tsconfig.lib.json itself. - Delete tsconfig.build.json. The customConditions: [] override (preserved from the old build config) keeps the @griffel/source resolution disabled here so typecheck resolves @griffel/core via its require condition → .d.cts, avoiding the CJS-importing-ESM-source TS1479 error. Co-Authored-By: Claude Opus 4.7 (1M context) --- packages/babel-preset/project.json | 9 --------- packages/babel-preset/tsconfig.build.json | 20 -------------------- packages/babel-preset/tsconfig.lib.json | 7 +++++-- 3 files changed, 5 insertions(+), 31 deletions(-) delete mode 100644 packages/babel-preset/tsconfig.build.json diff --git a/packages/babel-preset/project.json b/packages/babel-preset/project.json index c5a4f47a9..9e577b8cc 100644 --- a/packages/babel-preset/project.json +++ b/packages/babel-preset/project.json @@ -15,15 +15,6 @@ "options": { "reportsDirectory": "{projectRoot}/../../coverage/packages/babel-preset" } - }, - "build": { - "executor": "nx:run-commands", - "outputs": ["{workspaceRoot}/packages/babel-preset/dist"], - "options": { - "cwd": "packages/babel-preset", - "commands": ["tsc --build tsconfig.build.json --pretty"], - "parallel": false - } } } } diff --git a/packages/babel-preset/tsconfig.build.json b/packages/babel-preset/tsconfig.build.json deleted file mode 100644 index 77ee22186..000000000 --- a/packages/babel-preset/tsconfig.build.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "extends": "./tsconfig.lib.json", - "compilerOptions": { - "composite": false, - "module": "node16", - "moduleResolution": "node16", - "customConditions": [], - "emitDeclarationOnly": false, - "declaration": true, - "outDir": "./dist" - }, - "references": [ - { - "path": "../core/tsconfig.lib.json" - }, - { - "path": "../react/tsconfig.lib.json" - } - ] -} diff --git a/packages/babel-preset/tsconfig.lib.json b/packages/babel-preset/tsconfig.lib.json index 322399716..5818d020d 100644 --- a/packages/babel-preset/tsconfig.lib.json +++ b/packages/babel-preset/tsconfig.lib.json @@ -1,9 +1,12 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "./out-tsc/lib", + "module": "node16", + "moduleResolution": "node16", + "customConditions": [], + "declaration": true, + "outDir": "./dist", "rootDir": "./src", - "emitDeclarationOnly": true, "types": ["node", "environment"] }, "include": ["src/**/*.ts", "src/**/*.tsx"], From c4dc996ca6893494e568345c31fec780c244eaca Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Fri, 22 May 2026 12:23:40 +0200 Subject: [PATCH 16/26] chore(e2e): drop allowImportingTsExtensions where unused MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only e2e/utils uses .ts extensions in its imports; the other three e2e packages just import bare module specifiers like @griffel/e2e-utils. Drop the flag from their tsconfig.lib.json — it doesn't do anything useful there. Co-Authored-By: Claude Opus 4.7 (1M context) --- e2e/eslint/tsconfig.lib.json | 1 - e2e/rspack/tsconfig.lib.json | 1 - e2e/typescript/tsconfig.lib.json | 1 - 3 files changed, 3 deletions(-) diff --git a/e2e/eslint/tsconfig.lib.json b/e2e/eslint/tsconfig.lib.json index c00c175e7..c926f8ca4 100644 --- a/e2e/eslint/tsconfig.lib.json +++ b/e2e/eslint/tsconfig.lib.json @@ -3,7 +3,6 @@ "compilerOptions": { "module": "nodenext", "moduleResolution": "nodenext", - "allowImportingTsExtensions": true, "emitDeclarationOnly": true, "outDir": "./dist", "types": ["node", "environment"] diff --git a/e2e/rspack/tsconfig.lib.json b/e2e/rspack/tsconfig.lib.json index a7985d35a..e8bb5417c 100644 --- a/e2e/rspack/tsconfig.lib.json +++ b/e2e/rspack/tsconfig.lib.json @@ -3,7 +3,6 @@ "compilerOptions": { "module": "nodenext", "moduleResolution": "nodenext", - "allowImportingTsExtensions": true, "emitDeclarationOnly": true, "outDir": "./dist", "types": ["node", "environment", "static-assets"] diff --git a/e2e/typescript/tsconfig.lib.json b/e2e/typescript/tsconfig.lib.json index 9bfdd7d09..9683f4fbf 100644 --- a/e2e/typescript/tsconfig.lib.json +++ b/e2e/typescript/tsconfig.lib.json @@ -3,7 +3,6 @@ "compilerOptions": { "module": "nodenext", "moduleResolution": "nodenext", - "allowImportingTsExtensions": true, "emitDeclarationOnly": true, "outDir": "./dist", "types": ["node", "environment"] From 73ae3484b7a4a0a0aa29e377e209685fe7bc0f0a Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Fri, 22 May 2026 12:30:34 +0200 Subject: [PATCH 17/26] chore(spec configs): drop dead "out-tsc/**" + "dist/**" exclude Leftover from an earlier iteration that had **/*.d.ts in the include patterns (which picked up emitted declarations from out-tsc and dist). That include is long gone; the exclude was guarding against nothing. Co-Authored-By: Claude Opus 4.7 (1M context) --- packages/babel-preset/tsconfig.spec.json | 3 +-- packages/core/tsconfig.spec.json | 3 +-- packages/devtools/tsconfig.spec.json | 3 +-- packages/eslint-plugin/tsconfig.spec.json | 3 +-- packages/jest-serializer/tsconfig.spec.json | 3 +-- packages/postcss-syntax/tsconfig.spec.json | 3 +-- packages/react/tsconfig.spec.json | 3 +-- packages/shadow-dom/tsconfig.spec.json | 3 +-- packages/style-types/tsconfig.spec.json | 3 +-- packages/transform-shaker/tsconfig.spec.json | 3 +-- packages/transform/tsconfig.spec.json | 3 +-- packages/webpack-extraction-plugin/tsconfig.spec.json | 3 +-- packages/webpack-loader/tsconfig.spec.json | 3 +-- packages/webpack-plugin/tsconfig.spec.json | 3 +-- 14 files changed, 14 insertions(+), 28 deletions(-) diff --git a/packages/babel-preset/tsconfig.spec.json b/packages/babel-preset/tsconfig.spec.json index 103a0cd43..24817554a 100644 --- a/packages/babel-preset/tsconfig.spec.json +++ b/packages/babel-preset/tsconfig.spec.json @@ -20,6 +20,5 @@ { "path": "./tsconfig.lib.json" } - ], - "exclude": ["out-tsc/**", "dist/**"] + ] } diff --git a/packages/core/tsconfig.spec.json b/packages/core/tsconfig.spec.json index 57c1db01b..2da67144c 100644 --- a/packages/core/tsconfig.spec.json +++ b/packages/core/tsconfig.spec.json @@ -17,6 +17,5 @@ { "path": "./tsconfig.lib.json" } - ], - "exclude": ["out-tsc/**", "dist/**"] + ] } diff --git a/packages/devtools/tsconfig.spec.json b/packages/devtools/tsconfig.spec.json index bb317f1fb..1e1a72e59 100644 --- a/packages/devtools/tsconfig.spec.json +++ b/packages/devtools/tsconfig.spec.json @@ -19,6 +19,5 @@ { "path": "./tsconfig.lib.json" } - ], - "exclude": ["out-tsc/**", "dist/**"] + ] } diff --git a/packages/eslint-plugin/tsconfig.spec.json b/packages/eslint-plugin/tsconfig.spec.json index 57c1db01b..2da67144c 100644 --- a/packages/eslint-plugin/tsconfig.spec.json +++ b/packages/eslint-plugin/tsconfig.spec.json @@ -17,6 +17,5 @@ { "path": "./tsconfig.lib.json" } - ], - "exclude": ["out-tsc/**", "dist/**"] + ] } diff --git a/packages/jest-serializer/tsconfig.spec.json b/packages/jest-serializer/tsconfig.spec.json index 3ce360d52..14c1b35f8 100644 --- a/packages/jest-serializer/tsconfig.spec.json +++ b/packages/jest-serializer/tsconfig.spec.json @@ -19,6 +19,5 @@ { "path": "./tsconfig.lib.json" } - ], - "exclude": ["out-tsc/**", "dist/**"] + ] } diff --git a/packages/postcss-syntax/tsconfig.spec.json b/packages/postcss-syntax/tsconfig.spec.json index 57c1db01b..2da67144c 100644 --- a/packages/postcss-syntax/tsconfig.spec.json +++ b/packages/postcss-syntax/tsconfig.spec.json @@ -17,6 +17,5 @@ { "path": "./tsconfig.lib.json" } - ], - "exclude": ["out-tsc/**", "dist/**"] + ] } diff --git a/packages/react/tsconfig.spec.json b/packages/react/tsconfig.spec.json index 13bb8116d..87aeecf83 100644 --- a/packages/react/tsconfig.spec.json +++ b/packages/react/tsconfig.spec.json @@ -18,6 +18,5 @@ { "path": "./tsconfig.lib.json" } - ], - "exclude": ["out-tsc/**", "dist/**"] + ] } diff --git a/packages/shadow-dom/tsconfig.spec.json b/packages/shadow-dom/tsconfig.spec.json index 13bb8116d..87aeecf83 100644 --- a/packages/shadow-dom/tsconfig.spec.json +++ b/packages/shadow-dom/tsconfig.spec.json @@ -18,6 +18,5 @@ { "path": "./tsconfig.lib.json" } - ], - "exclude": ["out-tsc/**", "dist/**"] + ] } diff --git a/packages/style-types/tsconfig.spec.json b/packages/style-types/tsconfig.spec.json index 57c1db01b..2da67144c 100644 --- a/packages/style-types/tsconfig.spec.json +++ b/packages/style-types/tsconfig.spec.json @@ -17,6 +17,5 @@ { "path": "./tsconfig.lib.json" } - ], - "exclude": ["out-tsc/**", "dist/**"] + ] } diff --git a/packages/transform-shaker/tsconfig.spec.json b/packages/transform-shaker/tsconfig.spec.json index 57c1db01b..2da67144c 100644 --- a/packages/transform-shaker/tsconfig.spec.json +++ b/packages/transform-shaker/tsconfig.spec.json @@ -17,6 +17,5 @@ { "path": "./tsconfig.lib.json" } - ], - "exclude": ["out-tsc/**", "dist/**"] + ] } diff --git a/packages/transform/tsconfig.spec.json b/packages/transform/tsconfig.spec.json index 57c1db01b..2da67144c 100644 --- a/packages/transform/tsconfig.spec.json +++ b/packages/transform/tsconfig.spec.json @@ -17,6 +17,5 @@ { "path": "./tsconfig.lib.json" } - ], - "exclude": ["out-tsc/**", "dist/**"] + ] } diff --git a/packages/webpack-extraction-plugin/tsconfig.spec.json b/packages/webpack-extraction-plugin/tsconfig.spec.json index 57c1db01b..2da67144c 100644 --- a/packages/webpack-extraction-plugin/tsconfig.spec.json +++ b/packages/webpack-extraction-plugin/tsconfig.spec.json @@ -17,6 +17,5 @@ { "path": "./tsconfig.lib.json" } - ], - "exclude": ["out-tsc/**", "dist/**"] + ] } diff --git a/packages/webpack-loader/tsconfig.spec.json b/packages/webpack-loader/tsconfig.spec.json index 57c1db01b..2da67144c 100644 --- a/packages/webpack-loader/tsconfig.spec.json +++ b/packages/webpack-loader/tsconfig.spec.json @@ -17,6 +17,5 @@ { "path": "./tsconfig.lib.json" } - ], - "exclude": ["out-tsc/**", "dist/**"] + ] } diff --git a/packages/webpack-plugin/tsconfig.spec.json b/packages/webpack-plugin/tsconfig.spec.json index 769a13f50..30ef5393b 100644 --- a/packages/webpack-plugin/tsconfig.spec.json +++ b/packages/webpack-plugin/tsconfig.spec.json @@ -20,6 +20,5 @@ { "path": "./tsconfig.lib.json" } - ], - "exclude": ["out-tsc/**", "dist/**"] + ] } From 66fc192ab86aaea150ec2359d81ee8c0be78bdc2 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Fri, 22 May 2026 12:33:09 +0200 Subject: [PATCH 18/26] chore(transform-shaker): drop explicit build target, rely on @nx/js/typescript MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Same as transform / style-types — the inferred build runs the same \`tsc --build tsconfig.lib.json\`. Co-Authored-By: Claude Opus 4.7 (1M context) --- packages/transform-shaker/project.json | 9 --------- 1 file changed, 9 deletions(-) diff --git a/packages/transform-shaker/project.json b/packages/transform-shaker/project.json index 49eda110b..6522b78f3 100644 --- a/packages/transform-shaker/project.json +++ b/packages/transform-shaker/project.json @@ -15,15 +15,6 @@ "options": { "reportsDirectory": "{projectRoot}/../../coverage/packages/transform-shaker" } - }, - "build": { - "executor": "nx:run-commands", - "outputs": ["{workspaceRoot}/packages/transform-shaker/dist"], - "options": { - "cwd": "packages/transform-shaker", - "commands": ["tsc --build tsconfig.lib.json --pretty"], - "parallel": false - } } } } From b5d23f0e6adbbb8ef53bbce511240a38e42005f3 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Fri, 22 May 2026 12:36:14 +0200 Subject: [PATCH 19/26] chore(webpack-extraction-plugin): collapse build config + reorder package.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Same simplification as babel-preset: merge the dual tsconfig.lib.json + tsconfig.build.json into a single tsconfig.lib.json (module: node16, customConditions: [], outDir ./dist). Delete tsconfig.build.json. Drop the explicit build target from project.json — @nx/js/typescript infers it now. - Reorder package.json: metadata first, then entry points (main/types/ exports), then files, then deps. Matches the order in core/react/ shadow-dom. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../webpack-extraction-plugin/package.json | 26 +++++++++---------- .../webpack-extraction-plugin/project.json | 9 ------- .../tsconfig.build.json | 20 -------------- .../tsconfig.lib.json | 7 +++-- 4 files changed, 18 insertions(+), 44 deletions(-) delete mode 100644 packages/webpack-extraction-plugin/tsconfig.build.json diff --git a/packages/webpack-extraction-plugin/package.json b/packages/webpack-extraction-plugin/package.json index 65531f24f..361012bc3 100644 --- a/packages/webpack-extraction-plugin/package.json +++ b/packages/webpack-extraction-plugin/package.json @@ -7,19 +7,8 @@ "type": "git", "url": "https://github.com/microsoft/griffel" }, - "dependencies": { - "@babel/core": "^7.29.0", - "@babel/helper-module-imports": "^7.22.15", - "@babel/helper-plugin-utils": "^7.28.6", - "@griffel/core": "^1.21.2", - "stylis": "^4.4.0", - "tslib": "^2.1.0" - }, - "peerDependencies": { - "webpack": "^5" - }, - "types": "./dist/index.d.ts", "main": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { ".": { "@griffel/source": "./src/index.ts", @@ -33,5 +22,16 @@ "dist/", "README.md", "LICENSE.md" - ] + ], + "dependencies": { + "@babel/core": "^7.29.0", + "@babel/helper-module-imports": "^7.22.15", + "@babel/helper-plugin-utils": "^7.28.6", + "@griffel/core": "^1.21.2", + "stylis": "^4.4.0", + "tslib": "^2.1.0" + }, + "peerDependencies": { + "webpack": "^5" + } } diff --git a/packages/webpack-extraction-plugin/project.json b/packages/webpack-extraction-plugin/project.json index d9b1baa7e..8abe05a3a 100644 --- a/packages/webpack-extraction-plugin/project.json +++ b/packages/webpack-extraction-plugin/project.json @@ -15,15 +15,6 @@ "options": { "reportsDirectory": "{projectRoot}/../../coverage/packages/webpack-extraction-plugin" } - }, - "build": { - "executor": "nx:run-commands", - "outputs": ["{workspaceRoot}/packages/webpack-extraction-plugin/dist"], - "options": { - "cwd": "packages/webpack-extraction-plugin", - "commands": ["tsc --build tsconfig.build.json --pretty"], - "parallel": false - } } } } diff --git a/packages/webpack-extraction-plugin/tsconfig.build.json b/packages/webpack-extraction-plugin/tsconfig.build.json deleted file mode 100644 index 77ee22186..000000000 --- a/packages/webpack-extraction-plugin/tsconfig.build.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "extends": "./tsconfig.lib.json", - "compilerOptions": { - "composite": false, - "module": "node16", - "moduleResolution": "node16", - "customConditions": [], - "emitDeclarationOnly": false, - "declaration": true, - "outDir": "./dist" - }, - "references": [ - { - "path": "../core/tsconfig.lib.json" - }, - { - "path": "../react/tsconfig.lib.json" - } - ] -} diff --git a/packages/webpack-extraction-plugin/tsconfig.lib.json b/packages/webpack-extraction-plugin/tsconfig.lib.json index 322399716..5818d020d 100644 --- a/packages/webpack-extraction-plugin/tsconfig.lib.json +++ b/packages/webpack-extraction-plugin/tsconfig.lib.json @@ -1,9 +1,12 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "./out-tsc/lib", + "module": "node16", + "moduleResolution": "node16", + "customConditions": [], + "declaration": true, + "outDir": "./dist", "rootDir": "./src", - "emitDeclarationOnly": true, "types": ["node", "environment"] }, "include": ["src/**/*.ts", "src/**/*.tsx"], From f48b03d3185a43cc6d05351ba66c33a0afc79bd8 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Fri, 22 May 2026 12:50:43 +0200 Subject: [PATCH 20/26] chore: simplify package configs across the board MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Build targets — drop now-redundant explicit build entries in eslint-plugin, jest-serializer, postcss-syntax, webpack-loader project.json files. The @nx/js/typescript plugin infers them from tsconfig.lib.json. jest-serializer: collapse tsconfig.build.json into tsconfig.lib.json (same pattern as babel-preset / webpack-extraction-plugin — CJS with internal ESM imports, customConditions: [] sidesteps TS1479). Storybook configs (devtools, react, shadow-dom): restore composite + emit, drop noEmit, and reference them from the per-package tsconfig.json so they participate in the tsc -b graph. Drop unused emitDecoratorMetadata (would have required experimentalDecorators). Add jsx: react-jsx to react's storybook config so .tsx stories type-check. Package.json ordering (webpack-loader, eslint-plugin): metadata → entry points → files → deps, matching webpack-extraction-plugin / core / react. webpack-plugin: drop the lib override on `lib` (defaults from target: es2020 already include es2020 + dom). Drop the spec config's target/lib override entirely — spec reaches lib code via project reference, no need to restate. Co-Authored-By: Claude Opus 4.7 (1M context) --- packages/devtools/tsconfig.json | 3 +++ packages/devtools/tsconfig.storybook.json | 5 +---- packages/eslint-plugin/package.json | 20 +++++++++--------- packages/eslint-plugin/project.json | 9 -------- packages/jest-serializer/project.json | 9 -------- packages/jest-serializer/tsconfig.build.json | 20 ------------------ packages/jest-serializer/tsconfig.lib.json | 7 +++++-- packages/postcss-syntax/project.json | 9 -------- packages/react/tsconfig.json | 3 +++ packages/react/tsconfig.storybook.json | 6 ++---- packages/shadow-dom/tsconfig.json | 3 +++ packages/shadow-dom/tsconfig.storybook.json | 5 +---- packages/webpack-loader/package.json | 22 ++++++++++---------- packages/webpack-loader/project.json | 9 -------- packages/webpack-plugin/tsconfig.lib.json | 3 +-- packages/webpack-plugin/tsconfig.spec.json | 4 +--- 16 files changed, 41 insertions(+), 96 deletions(-) delete mode 100644 packages/jest-serializer/tsconfig.build.json diff --git a/packages/devtools/tsconfig.json b/packages/devtools/tsconfig.json index 37ab84bcd..1fa5f8e7c 100644 --- a/packages/devtools/tsconfig.json +++ b/packages/devtools/tsconfig.json @@ -14,6 +14,9 @@ }, { "path": "./tsconfig.spec.json" + }, + { + "path": "./tsconfig.storybook.json" } ] } diff --git a/packages/devtools/tsconfig.storybook.json b/packages/devtools/tsconfig.storybook.json index a567768bc..014a67a79 100644 --- a/packages/devtools/tsconfig.storybook.json +++ b/packages/devtools/tsconfig.storybook.json @@ -1,11 +1,8 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "emitDecoratorMetadata": true, "moduleResolution": "bundler", - "noEmit": true, - "outDir": "./out-tsc/storybook", - "composite": false + "outDir": "./out-tsc/storybook" }, "files": [ "../../node_modules/@nx/react/typings/styled-jsx.d.ts", diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index dc12c963f..25aa59dc5 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -8,16 +8,8 @@ "type": "git", "url": "https://github.com/microsoft/griffel" }, - "dependencies": { - "@typescript-eslint/utils": "^8.59.3", - "csstype": "^3.2.3", - "tslib": "^2.1.0" - }, - "peerDependencies": { - "eslint": "^9.0.0 || ^10.0.0" - }, - "types": "./dist/index.d.ts", "main": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { ".": { "@griffel/source": "./src/index.ts", @@ -30,5 +22,13 @@ "dist/", "README.md", "LICENSE.md" - ] + ], + "dependencies": { + "@typescript-eslint/utils": "^8.59.3", + "csstype": "^3.2.3", + "tslib": "^2.1.0" + }, + "peerDependencies": { + "eslint": "^9.0.0 || ^10.0.0" + } } diff --git a/packages/eslint-plugin/project.json b/packages/eslint-plugin/project.json index efb3abc9d..d3d087b5c 100644 --- a/packages/eslint-plugin/project.json +++ b/packages/eslint-plugin/project.json @@ -12,15 +12,6 @@ "test": { "executor": "@nx/vitest:test", "outputs": ["{workspaceRoot}/coverage/packages/eslint-plugin"] - }, - "build": { - "executor": "nx:run-commands", - "outputs": ["{workspaceRoot}/packages/eslint-plugin/dist"], - "options": { - "cwd": "packages/eslint-plugin", - "commands": ["tsc --build tsconfig.lib.json --pretty"], - "parallel": false - } } } } diff --git a/packages/jest-serializer/project.json b/packages/jest-serializer/project.json index 30ec2a92a..f3304be2f 100644 --- a/packages/jest-serializer/project.json +++ b/packages/jest-serializer/project.json @@ -15,15 +15,6 @@ "options": { "reportsDirectory": "{projectRoot}/../../coverage/packages/jest-serializer" } - }, - "build": { - "executor": "nx:run-commands", - "outputs": ["{workspaceRoot}/packages/jest-serializer/dist"], - "options": { - "cwd": "packages/jest-serializer", - "commands": ["tsc --build tsconfig.build.json --pretty"], - "parallel": false - } } } } diff --git a/packages/jest-serializer/tsconfig.build.json b/packages/jest-serializer/tsconfig.build.json deleted file mode 100644 index a8f13e64e..000000000 --- a/packages/jest-serializer/tsconfig.build.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "extends": "./tsconfig.lib.json", - "compilerOptions": { - "composite": false, - "module": "node16", - "moduleResolution": "node16", - "customConditions": [], - "emitDeclarationOnly": false, - "declaration": true, - "outDir": "./dist" - }, - "references": [ - { - "path": "../react/tsconfig.lib.json" - }, - { - "path": "../core/tsconfig.lib.json" - } - ] -} diff --git a/packages/jest-serializer/tsconfig.lib.json b/packages/jest-serializer/tsconfig.lib.json index c48a037ea..edad876e0 100644 --- a/packages/jest-serializer/tsconfig.lib.json +++ b/packages/jest-serializer/tsconfig.lib.json @@ -1,9 +1,12 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "./out-tsc/lib", + "module": "node16", + "moduleResolution": "node16", + "customConditions": [], + "declaration": true, + "outDir": "./dist", "rootDir": "./src", - "emitDeclarationOnly": true, "types": ["node", "environment"] }, "include": ["src/**/*.ts", "src/**/*.tsx"], diff --git a/packages/postcss-syntax/project.json b/packages/postcss-syntax/project.json index 4a2e96ae0..5d4de6bc5 100644 --- a/packages/postcss-syntax/project.json +++ b/packages/postcss-syntax/project.json @@ -15,15 +15,6 @@ "options": { "reportsDirectory": "{projectRoot}/../../coverage/packages/postcss-syntax" } - }, - "build": { - "executor": "nx:run-commands", - "outputs": ["{workspaceRoot}/packages/postcss-syntax/dist"], - "options": { - "cwd": "packages/postcss-syntax", - "commands": ["tsc --build tsconfig.lib.json --pretty"], - "parallel": false - } } } } diff --git a/packages/react/tsconfig.json b/packages/react/tsconfig.json index 62ebbd946..ed3e4588d 100644 --- a/packages/react/tsconfig.json +++ b/packages/react/tsconfig.json @@ -8,6 +8,9 @@ }, { "path": "./tsconfig.spec.json" + }, + { + "path": "./tsconfig.storybook.json" } ] } diff --git a/packages/react/tsconfig.storybook.json b/packages/react/tsconfig.storybook.json index 625584196..ce5d40d0b 100644 --- a/packages/react/tsconfig.storybook.json +++ b/packages/react/tsconfig.storybook.json @@ -1,12 +1,10 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "emitDecoratorMetadata": true, + "jsx": "react-jsx", "moduleResolution": "bundler", "allowSyntheticDefaultImports": true, - "noEmit": true, - "outDir": "./out-tsc/storybook", - "composite": false + "outDir": "./out-tsc/storybook" }, "exclude": ["src/**/*.spec.ts", "src/**/*.spec.js", "src/**/*.spec.tsx", "src/**/*.spec.jsx", "jest.config.ts"], "include": ["src/**/*", ".storybook/*.js"] diff --git a/packages/shadow-dom/tsconfig.json b/packages/shadow-dom/tsconfig.json index 62ebbd946..ed3e4588d 100644 --- a/packages/shadow-dom/tsconfig.json +++ b/packages/shadow-dom/tsconfig.json @@ -8,6 +8,9 @@ }, { "path": "./tsconfig.spec.json" + }, + { + "path": "./tsconfig.storybook.json" } ] } diff --git a/packages/shadow-dom/tsconfig.storybook.json b/packages/shadow-dom/tsconfig.storybook.json index 0c0e62d47..21ca79fea 100644 --- a/packages/shadow-dom/tsconfig.storybook.json +++ b/packages/shadow-dom/tsconfig.storybook.json @@ -2,11 +2,8 @@ "extends": "./tsconfig.json", "compilerOptions": { "jsx": "react-jsx", - "emitDecoratorMetadata": true, "noPropertyAccessFromIndexSignature": false, - "noEmit": true, - "outDir": "./out-tsc/storybook", - "composite": false + "outDir": "./out-tsc/storybook" }, "exclude": ["src/**/*.spec.ts", "src/**/*.spec.js", "src/**/*.spec.tsx", "src/**/*.spec.jsx", "jest.config.ts"], "include": ["src/**/*", ".storybook/*.js"] diff --git a/packages/webpack-loader/package.json b/packages/webpack-loader/package.json index 634834696..39b978bdb 100644 --- a/packages/webpack-loader/package.json +++ b/packages/webpack-loader/package.json @@ -7,17 +7,8 @@ "type": "git", "url": "https://github.com/microsoft/griffel" }, - "dependencies": { - "@babel/core": "^7.29.0", - "@griffel/babel-preset": "^1.8.6", - "enhanced-resolve": "^5.21.0", - "tslib": "^2.1.0" - }, - "peerDependencies": { - "webpack": "^5" - }, - "types": "./dist/index.d.ts", "main": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { ".": { "@griffel/source": "./src/index.ts", @@ -30,5 +21,14 @@ "dist/", "README.md", "LICENSE.md" - ] + ], + "dependencies": { + "@babel/core": "^7.29.0", + "@griffel/babel-preset": "^1.8.6", + "enhanced-resolve": "^5.21.0", + "tslib": "^2.1.0" + }, + "peerDependencies": { + "webpack": "^5" + } } diff --git a/packages/webpack-loader/project.json b/packages/webpack-loader/project.json index 98c2525ef..6db1b6bc4 100644 --- a/packages/webpack-loader/project.json +++ b/packages/webpack-loader/project.json @@ -15,15 +15,6 @@ "options": { "reportsDirectory": "{projectRoot}/../../coverage/packages/webpack-loader" } - }, - "build": { - "executor": "nx:run-commands", - "outputs": ["{workspaceRoot}/packages/webpack-loader/dist"], - "options": { - "cwd": "packages/webpack-loader", - "commands": ["tsc --build tsconfig.lib.json --pretty"], - "parallel": false - } } } } diff --git a/packages/webpack-plugin/tsconfig.lib.json b/packages/webpack-plugin/tsconfig.lib.json index ab08e75c5..9d5144cc3 100644 --- a/packages/webpack-plugin/tsconfig.lib.json +++ b/packages/webpack-plugin/tsconfig.lib.json @@ -3,9 +3,8 @@ "compilerOptions": { "outDir": "./dist", "rootDir": "./src", - "types": ["node", "environment"], "target": "es2020", - "lib": ["es2020", "dom", "DOM.Iterable"] + "types": ["node", "environment"] }, "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.mts"], "exclude": ["**/*.spec.ts", "**/*.test.ts", "**/*.spec.tsx", "**/*.test.tsx", "vitest.config.ts"], diff --git a/packages/webpack-plugin/tsconfig.spec.json b/packages/webpack-plugin/tsconfig.spec.json index 30ef5393b..87aeecf83 100644 --- a/packages/webpack-plugin/tsconfig.spec.json +++ b/packages/webpack-plugin/tsconfig.spec.json @@ -4,9 +4,7 @@ "outDir": "./out-tsc/spec", "typeRoots": ["../../node_modules", "../../node_modules/@types", "../../typings"], "types": ["vitest/importMeta", "vite/client", "node", "vitest", "environment"], - "jsx": "react-jsx", - "target": "es2020", - "lib": ["es2020", "dom", "DOM.Iterable"] + "jsx": "react-jsx" }, "include": [ "vitest.config.ts", From 64b209fa4322e1656d57264e1af88172e1ac7137 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Fri, 22 May 2026 12:55:31 +0200 Subject: [PATCH 21/26] chore(webpack-plugin): target esnext, not pinned es2020 The override exists for BigInt literal support (used in GriffelPlugin's build-time stats). \`esnext\` reads more clearly as "newer than the base default", versus picking a specific year. Co-Authored-By: Claude Opus 4.7 (1M context) --- packages/webpack-plugin/tsconfig.lib.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/webpack-plugin/tsconfig.lib.json b/packages/webpack-plugin/tsconfig.lib.json index 9d5144cc3..e51db2f8e 100644 --- a/packages/webpack-plugin/tsconfig.lib.json +++ b/packages/webpack-plugin/tsconfig.lib.json @@ -3,7 +3,7 @@ "compilerOptions": { "outDir": "./dist", "rootDir": "./src", - "target": "es2020", + "target": "esnext", "types": ["node", "environment"] }, "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.mts"], From b1dab990b98d9cbed16b2f2da8809f3270c4bb69 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Fri, 22 May 2026 13:00:39 +0200 Subject: [PATCH 22/26] chore(webpack-plugin): move virtual-loader to package root MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Drop the build-time copy of src/virtual-loader/ into dist/virtual-loader/. Move the source to packages/webpack-plugin/virtual-loader/ (one dir up from src/) and have `npm pack` ship it via the `files` field, matching how webpack-extraction-plugin already handles its virtual-loader. - Move src/virtual-loader/index.cjs → virtual-loader/index.cjs. - webpackLoader.mts: resolve virtualLoaderPath via ../virtual-loader/ (the compiled .mjs in dist/ is one level below virtual-loader/). - package.json files: add "virtual-loader/". - project.json: drop the explicit build target entirely — the @nx/js/typescript-inferred build does the right thing now that there's no copy step to chain. - Update 15 __fixtures__//output.ts snapshots to reflect the new relative path from each fixture to the loader. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../__fixtures__/assets-flip/output.ts | 2 +- .../__fixtures__/assets-multiple/output.ts | 2 +- .../webpack-plugin/__fixtures__/assets/output.ts | 2 +- .../__fixtures__/basic-rules/output.ts | 2 +- .../config-classname-hash-salt/output.ts | 2 +- .../webpack-plugin/__fixtures__/mixed-vm/output.ts | 2 +- .../webpack-plugin/__fixtures__/mixed/output.ts | 2 +- .../webpack-plugin/__fixtures__/multiple/output.ts | 2 +- .../__fixtures__/reset-assets/output.ts | 2 +- .../__fixtures__/reset-media/output.ts | 2 +- .../webpack-plugin/__fixtures__/reset/output.ts | 2 +- .../__fixtures__/rules-deduplication/output.ts | 2 +- .../__fixtures__/style-buckets-scope/output.ts | 2 +- .../__fixtures__/style-buckets/output.ts | 2 +- .../__fixtures__/unstable-attach-to-main/output.ts | 2 +- packages/webpack-plugin/package.json | 13 +++++++------ packages/webpack-plugin/project.json | 12 ------------ packages/webpack-plugin/src/webpackLoader.mts | 5 +++-- .../{src => }/virtual-loader/index.cjs | 0 19 files changed, 25 insertions(+), 35 deletions(-) rename packages/webpack-plugin/{src => }/virtual-loader/index.cjs (100%) diff --git a/packages/webpack-plugin/__fixtures__/assets-flip/output.ts b/packages/webpack-plugin/__fixtures__/assets-flip/output.ts index bffef3d7a..6eaa365e0 100644 --- a/packages/webpack-plugin/__fixtures__/assets-flip/output.ts +++ b/packages/webpack-plugin/__fixtures__/assets-flip/output.ts @@ -5,4 +5,4 @@ import _asset2 from './right.jpg'; export const useStyles = __css({ root: { Bcmaq0h: ['f___0', 'f___1'] } }); -import './code.griffel.css!=!../../src/virtual-loader/index.cjs!./code.ts'; +import './code.griffel.css!=!../../virtual-loader/index.cjs!./code.ts'; diff --git a/packages/webpack-plugin/__fixtures__/assets-multiple/output.ts b/packages/webpack-plugin/__fixtures__/assets-multiple/output.ts index 829e8899d..d0fb58dd3 100644 --- a/packages/webpack-plugin/__fixtures__/assets-multiple/output.ts +++ b/packages/webpack-plugin/__fixtures__/assets-multiple/output.ts @@ -4,4 +4,4 @@ import _asset2 from './empty.jpg'; export const useStyles = __css({ root: { Bcmaq0h: 'f___0' } }); -import './code.griffel.css!=!../../src/virtual-loader/index.cjs!./code.ts'; +import './code.griffel.css!=!../../virtual-loader/index.cjs!./code.ts'; diff --git a/packages/webpack-plugin/__fixtures__/assets/output.ts b/packages/webpack-plugin/__fixtures__/assets/output.ts index f11e8ecea..05325bd2b 100644 --- a/packages/webpack-plugin/__fixtures__/assets/output.ts +++ b/packages/webpack-plugin/__fixtures__/assets/output.ts @@ -3,4 +3,4 @@ import _asset from './blank.jpg'; export const useStyles = __css({ root: { Bcmaq0h: 'f___0' } }); -import './code.griffel.css!=!../../src/virtual-loader/index.cjs!./code.ts'; +import './code.griffel.css!=!../../virtual-loader/index.cjs!./code.ts'; diff --git a/packages/webpack-plugin/__fixtures__/basic-rules/output.ts b/packages/webpack-plugin/__fixtures__/basic-rules/output.ts index c1f4fe5ec..4e9a6782f 100644 --- a/packages/webpack-plugin/__fixtures__/basic-rules/output.ts +++ b/packages/webpack-plugin/__fixtures__/basic-rules/output.ts @@ -35,4 +35,4 @@ export const useStyles = __css({ icon: { De3pzq: 'fcnqdeg', mc9l5x: 'f22iagw' }, }); -import './code.griffel.css!=!../../src/virtual-loader/index.cjs!./code.ts'; +import './code.griffel.css!=!../../virtual-loader/index.cjs!./code.ts'; diff --git a/packages/webpack-plugin/__fixtures__/config-classname-hash-salt/output.ts b/packages/webpack-plugin/__fixtures__/config-classname-hash-salt/output.ts index 535df6e3b..fc45ec41c 100644 --- a/packages/webpack-plugin/__fixtures__/config-classname-hash-salt/output.ts +++ b/packages/webpack-plugin/__fixtures__/config-classname-hash-salt/output.ts @@ -2,4 +2,4 @@ import { __css } from '@griffel/react'; export const useStyles = __css({ root: { sj55zd: 'feohi3x', uwmqm3: ['f1rwgqon', 'f1tyzn0d'] } }); -import './code.griffel.css!=!../../src/virtual-loader/index.cjs!./code.ts'; +import './code.griffel.css!=!../../virtual-loader/index.cjs!./code.ts'; diff --git a/packages/webpack-plugin/__fixtures__/mixed-vm/output.ts b/packages/webpack-plugin/__fixtures__/mixed-vm/output.ts index 1eb0be250..9532a7af9 100644 --- a/packages/webpack-plugin/__fixtures__/mixed-vm/output.ts +++ b/packages/webpack-plugin/__fixtures__/mixed-vm/output.ts @@ -13,4 +13,4 @@ export const useTextStyles = __css({ afterAlignToPrimary: { Br312pm: 'fwu52yu' }, }); -import './code.griffel.css!=!../../src/virtual-loader/index.cjs!./code.ts'; +import './code.griffel.css!=!../../virtual-loader/index.cjs!./code.ts'; diff --git a/packages/webpack-plugin/__fixtures__/mixed/output.ts b/packages/webpack-plugin/__fixtures__/mixed/output.ts index 98c41fadf..dce708d7d 100644 --- a/packages/webpack-plugin/__fixtures__/mixed/output.ts +++ b/packages/webpack-plugin/__fixtures__/mixed/output.ts @@ -4,4 +4,4 @@ export const useClasses = __css({ root: { sj55zd: 'fe3e8s9' } }); export const useClassName = __resetCSS('rjefjbm', 'r7z97ji'); -import './code.griffel.css!=!../../src/virtual-loader/index.cjs!./code.ts'; +import './code.griffel.css!=!../../virtual-loader/index.cjs!./code.ts'; diff --git a/packages/webpack-plugin/__fixtures__/multiple/output.ts b/packages/webpack-plugin/__fixtures__/multiple/output.ts index dac931eb6..a080aecdf 100644 --- a/packages/webpack-plugin/__fixtures__/multiple/output.ts +++ b/packages/webpack-plugin/__fixtures__/multiple/output.ts @@ -36,4 +36,4 @@ export const useStylesB = __css({ }, }); -import './code.griffel.css!=!../../src/virtual-loader/index.cjs!./code.ts'; +import './code.griffel.css!=!../../virtual-loader/index.cjs!./code.ts'; diff --git a/packages/webpack-plugin/__fixtures__/reset-assets/output.ts b/packages/webpack-plugin/__fixtures__/reset-assets/output.ts index 8cebb0403..a77b60b02 100644 --- a/packages/webpack-plugin/__fixtures__/reset-assets/output.ts +++ b/packages/webpack-plugin/__fixtures__/reset-assets/output.ts @@ -3,4 +3,4 @@ import _asset from './blank.jpg'; export const useClassName = __resetCSS('r___0', null); -import './code.griffel.css!=!../../src/virtual-loader/index.cjs!./code.ts'; +import './code.griffel.css!=!../../virtual-loader/index.cjs!./code.ts'; diff --git a/packages/webpack-plugin/__fixtures__/reset-media/output.ts b/packages/webpack-plugin/__fixtures__/reset-media/output.ts index 0c50b0266..e7f792057 100644 --- a/packages/webpack-plugin/__fixtures__/reset-media/output.ts +++ b/packages/webpack-plugin/__fixtures__/reset-media/output.ts @@ -2,4 +2,4 @@ import { __resetCSS } from '@griffel/react'; export const useClassName = __resetCSS('rjrhw4c', null); -import './code.griffel.css!=!../../src/virtual-loader/index.cjs!./code.ts'; +import './code.griffel.css!=!../../virtual-loader/index.cjs!./code.ts'; diff --git a/packages/webpack-plugin/__fixtures__/reset/output.ts b/packages/webpack-plugin/__fixtures__/reset/output.ts index aa514047f..2ec4d63c4 100644 --- a/packages/webpack-plugin/__fixtures__/reset/output.ts +++ b/packages/webpack-plugin/__fixtures__/reset/output.ts @@ -2,4 +2,4 @@ import { __resetCSS } from '@griffel/react'; export const useClassName = __resetCSS('rjefjbm', 'r7z97ji'); -import './code.griffel.css!=!../../src/virtual-loader/index.cjs!./code.ts'; +import './code.griffel.css!=!../../virtual-loader/index.cjs!./code.ts'; diff --git a/packages/webpack-plugin/__fixtures__/rules-deduplication/output.ts b/packages/webpack-plugin/__fixtures__/rules-deduplication/output.ts index df693579b..2f068cbf9 100644 --- a/packages/webpack-plugin/__fixtures__/rules-deduplication/output.ts +++ b/packages/webpack-plugin/__fixtures__/rules-deduplication/output.ts @@ -4,4 +4,4 @@ export const useStylesA = __css({ root: { sj55zd: 'fe3e8s9', De3pzq: 'fcnqdeg' } export const useStylesB = __css({ root: { sj55zd: 'fe3e8s9', De3pzq: 'fcnqdeg' } }); -import './code.griffel.css!=!../../src/virtual-loader/index.cjs!./code.ts'; +import './code.griffel.css!=!../../virtual-loader/index.cjs!./code.ts'; diff --git a/packages/webpack-plugin/__fixtures__/style-buckets-scope/output.ts b/packages/webpack-plugin/__fixtures__/style-buckets-scope/output.ts index 7d7189ea1..9ac768067 100644 --- a/packages/webpack-plugin/__fixtures__/style-buckets-scope/output.ts +++ b/packages/webpack-plugin/__fixtures__/style-buckets-scope/output.ts @@ -2,4 +2,4 @@ import { __css } from '@griffel/react'; export const useStyles = __css({ root: { sj55zd: 'fe3e8s9', J2wb9c: 'f1sje2gt', hth0cq: 'f7t33c5' } }); -import './code.griffel.css!=!../../src/virtual-loader/index.cjs!./code.ts'; +import './code.griffel.css!=!../../virtual-loader/index.cjs!./code.ts'; diff --git a/packages/webpack-plugin/__fixtures__/style-buckets/output.ts b/packages/webpack-plugin/__fixtures__/style-buckets/output.ts index f6de9b922..465873094 100644 --- a/packages/webpack-plugin/__fixtures__/style-buckets/output.ts +++ b/packages/webpack-plugin/__fixtures__/style-buckets/output.ts @@ -15,4 +15,4 @@ export const useStyles = __css({ atRules: { Bv12yb3: ['f1g6ul6r', 'f1fp4ujf'], C7niov: 'fraqsfm', B7iucu3: 'fqoinyl' }, }); -import './code.griffel.css!=!../../src/virtual-loader/index.cjs!./code.ts'; +import './code.griffel.css!=!../../virtual-loader/index.cjs!./code.ts'; diff --git a/packages/webpack-plugin/__fixtures__/unstable-attach-to-main/output.ts b/packages/webpack-plugin/__fixtures__/unstable-attach-to-main/output.ts index af36653e4..5dd140ce3 100644 --- a/packages/webpack-plugin/__fixtures__/unstable-attach-to-main/output.ts +++ b/packages/webpack-plugin/__fixtures__/unstable-attach-to-main/output.ts @@ -2,4 +2,4 @@ import { __css } from '@griffel/react'; export const useClasses = __css({ root: { sj55zd: 'fe3e8s9' } }); -import './code.griffel.css!=!../../src/virtual-loader/index.cjs!./code.ts'; +import './code.griffel.css!=!../../virtual-loader/index.cjs!./code.ts'; diff --git a/packages/webpack-plugin/package.json b/packages/webpack-plugin/package.json index 8ea786c23..2c3bb02e6 100644 --- a/packages/webpack-plugin/package.json +++ b/packages/webpack-plugin/package.json @@ -23,6 +23,12 @@ }, "./package.json": "./package.json" }, + "files": [ + "virtual-loader/", + "dist/", + "README.md", + "LICENSE.md" + ], "dependencies": { "@griffel/core": "^1.21.2", "@griffel/transform": "^3.0.6", @@ -31,10 +37,5 @@ }, "peerDependencies": { "webpack": "^5" - }, - "files": [ - "dist/", - "README.md", - "LICENSE.md" - ] + } } diff --git a/packages/webpack-plugin/project.json b/packages/webpack-plugin/project.json index ec1eb0241..39321900d 100644 --- a/packages/webpack-plugin/project.json +++ b/packages/webpack-plugin/project.json @@ -9,18 +9,6 @@ "executor": "@nx/eslint:lint", "outputs": ["{options.outputFile}"] }, - "build": { - "executor": "nx:run-commands", - "outputs": ["{workspaceRoot}/packages/webpack-plugin/dist"], - "options": { - "cwd": "packages/webpack-plugin", - "commands": [ - "tsc --build tsconfig.lib.json --pretty", - "node -e \"require('node:fs').cpSync('src/virtual-loader', 'dist/virtual-loader', { recursive: true })\"" - ], - "parallel": false - } - }, "test": { "executor": "@nx/vitest:test", "outputs": ["{options.reportsDirectory}"], diff --git a/packages/webpack-plugin/src/webpackLoader.mts b/packages/webpack-plugin/src/webpackLoader.mts index 1424b040e..6272293ea 100644 --- a/packages/webpack-plugin/src/webpackLoader.mts +++ b/packages/webpack-plugin/src/webpackLoader.mts @@ -12,8 +12,9 @@ export type WebpackLoaderOptions = Omit>; const __dirname = path.dirname(fileURLToPath(import.meta.url)); -// TODO: do something better, define via exports? -const virtualLoaderPath = path.resolve(__dirname, 'virtual-loader', 'index.cjs'); +// virtual-loader/ sits one dir above the compiled .mjs (in dist/) at the package +// root, so `npm pack` ships it via the `files` field without a build-time copy. +const virtualLoaderPath = path.resolve(__dirname, '..', 'virtual-loader', 'index.cjs'); function webpackLoader( this: SupplementedLoaderContext, diff --git a/packages/webpack-plugin/src/virtual-loader/index.cjs b/packages/webpack-plugin/virtual-loader/index.cjs similarity index 100% rename from packages/webpack-plugin/src/virtual-loader/index.cjs rename to packages/webpack-plugin/virtual-loader/index.cjs From 74a201a30dff0a9401a0e7f8ce8485aa58d2c68b Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Fri, 22 May 2026 13:04:44 +0200 Subject: [PATCH 23/26] chore(webpack-extraction-plugin): inline GriffelCssLoaderContextKey in virtual-loader Match the simpler pattern used by webpack-plugin's virtual-loader: compute the global symbol inline via Symbol.for() instead of pulling it in from ../dist/constants. Drops the cross-file dependency and the awkward pre-build IDE state (where ../dist didn't exist yet). The JSDoc still references ../src/constants for the SupplementedLoaderContext type, which exists in workspace dev (source TS) for tooling. Co-Authored-By: Claude Opus 4.7 (1M context) --- packages/webpack-extraction-plugin/virtual-loader/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/webpack-extraction-plugin/virtual-loader/index.js b/packages/webpack-extraction-plugin/virtual-loader/index.js index f50c9db8b..4b000a5e2 100644 --- a/packages/webpack-extraction-plugin/virtual-loader/index.js +++ b/packages/webpack-extraction-plugin/virtual-loader/index.js @@ -1,7 +1,7 @@ -const { GriffelCssLoaderContextKey } = require('../dist/constants.js'); +const GriffelCssLoaderContextKey = Symbol.for(`GriffelExtractPlugin/GriffelCssLoaderContextKey`); /** - * @this {import("../dist/constants").SupplementedLoaderContext} + * @this {import("../src/constants").SupplementedLoaderContext} * @return {String} */ function virtualLoader() { From 1ff686676f191a4c1a70bd543fc8d65365f6e607 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Fri, 22 May 2026 13:11:20 +0200 Subject: [PATCH 24/26] chore(core/react/shadow-dom): refactor build pipeline to build + build-cjs Drop the `_build_tsc` placeholder target. Rename the previous nx:run-commands "build" (which only invoked tools/build-cjs.mjs) to "build-cjs". Add a plain "build" target that runs tsc directly. The @nx/js/typescript plugin can't infer "build" for these three packages because their nested exports.require.default points outside the lib config's outDir; the explicit target keeps things simple. nx.json: targetDefaults wire the chain: - build dependsOn ^build, ^build-cjs - build-cjs dependsOn build, ^build-cjs That way `nx run X:build-cjs` builds tsc first then the CJS step, and any consumer's "build" waits for its deps' tsc + cjs outputs. Co-Authored-By: Claude Opus 4.7 (1M context) --- nx.json | 6 +++++- packages/core/package.json | 2 +- packages/core/project.json | 20 +++++++++----------- packages/react/package.json | 2 +- packages/react/project.json | 20 +++++++++----------- packages/shadow-dom/package.json | 2 +- packages/shadow-dom/project.json | 20 +++++++++----------- 7 files changed, 35 insertions(+), 37 deletions(-) diff --git a/nx.json b/nx.json index c3ae715f7..fb3529cb1 100644 --- a/nx.json +++ b/nx.json @@ -3,7 +3,7 @@ "extends": "nx/presets/core.json", "targetDefaults": { "build": { - "dependsOn": ["^build"], + "dependsOn": ["^build", "^build-cjs"], "cache": true }, "test": { @@ -27,6 +27,10 @@ "@nx/vitest:test": { "cache": true, "inputs": ["default", "^default"] + }, + "build-cjs": { + "dependsOn": ["build", "^build-cjs"], + "cache": true } }, "plugins": [ diff --git a/packages/core/package.json b/packages/core/package.json index b79306d61..e30c11170 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -9,7 +9,7 @@ }, "sideEffects": false, "type": "module", - "main": "./dist/cjs/index.cjs", + "main": "./dist/index.js", "module": "./dist/index.js", "exports": { ".": { diff --git a/packages/core/project.json b/packages/core/project.json index 8bc926733..b1f153ef4 100644 --- a/packages/core/project.json +++ b/packages/core/project.json @@ -5,14 +5,6 @@ "projectType": "library", "tags": [], "targets": { - "build": { - "executor": "nx:run-commands", - "dependsOn": ["_build_tsc"], - "outputs": ["{workspaceRoot}/packages/core/dist/cjs"], - "options": { - "command": "node tools/build-cjs.mjs packages/core/dist packages/core/dist/cjs" - } - }, "lint": { "executor": "@nx/eslint:lint", "outputs": ["{options.outputFile}"] @@ -36,13 +28,19 @@ ] } }, - "_build_tsc": { + "build-cjs": { + "executor": "nx:run-commands", + "outputs": ["{workspaceRoot}/packages/core/dist/cjs"], + "options": { + "command": "node tools/build-cjs.mjs packages/core/dist packages/core/dist/cjs" + } + }, + "build": { "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/packages/core/dist"], "options": { "cwd": "packages/core", - "commands": ["tsc --build tsconfig.lib.json --pretty"], - "parallel": false + "command": "tsc --build tsconfig.lib.json --pretty" } } } diff --git a/packages/react/package.json b/packages/react/package.json index 6cb74539f..663245f68 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -9,7 +9,7 @@ }, "sideEffects": false, "type": "module", - "main": "./dist/cjs/index.cjs", + "main": "./dist/index.js", "module": "./dist/index.js", "exports": { ".": { diff --git a/packages/react/project.json b/packages/react/project.json index 705f0598a..199620a29 100644 --- a/packages/react/project.json +++ b/packages/react/project.json @@ -5,14 +5,6 @@ "projectType": "library", "tags": [], "targets": { - "build": { - "executor": "nx:run-commands", - "dependsOn": ["_build_tsc"], - "outputs": ["{workspaceRoot}/packages/react/dist/cjs"], - "options": { - "command": "node tools/build-cjs.mjs packages/react/dist packages/react/dist/cjs" - } - }, "lint": { "executor": "@nx/eslint:lint", "outputs": ["{options.outputFile}"] @@ -61,13 +53,19 @@ } } }, - "_build_tsc": { + "build-cjs": { + "executor": "nx:run-commands", + "outputs": ["{workspaceRoot}/packages/react/dist/cjs"], + "options": { + "command": "node tools/build-cjs.mjs packages/react/dist packages/react/dist/cjs" + } + }, + "build": { "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/packages/react/dist"], "options": { "cwd": "packages/react", - "commands": ["tsc --build tsconfig.lib.json --pretty"], - "parallel": false + "command": "tsc --build tsconfig.lib.json --pretty" } } } diff --git a/packages/shadow-dom/package.json b/packages/shadow-dom/package.json index c3eefaf15..f91dfefae 100644 --- a/packages/shadow-dom/package.json +++ b/packages/shadow-dom/package.json @@ -9,7 +9,7 @@ }, "sideEffects": false, "type": "module", - "main": "./dist/cjs/index.cjs", + "main": "./dist/index.js", "module": "./dist/index.js", "exports": { ".": { diff --git a/packages/shadow-dom/project.json b/packages/shadow-dom/project.json index f9312ca55..8e7ae0630 100644 --- a/packages/shadow-dom/project.json +++ b/packages/shadow-dom/project.json @@ -5,14 +5,6 @@ "projectType": "library", "tags": [], "targets": { - "build": { - "executor": "nx:run-commands", - "dependsOn": ["_build_tsc"], - "outputs": ["{workspaceRoot}/packages/shadow-dom/dist/cjs"], - "options": { - "command": "node tools/build-cjs.mjs packages/shadow-dom/dist packages/shadow-dom/dist/cjs" - } - }, "lint": { "executor": "@nx/eslint:lint", "outputs": ["{options.outputFile}"] @@ -61,13 +53,19 @@ } } }, - "_build_tsc": { + "build-cjs": { + "executor": "nx:run-commands", + "outputs": ["{workspaceRoot}/packages/shadow-dom/dist/cjs"], + "options": { + "command": "node tools/build-cjs.mjs packages/shadow-dom/dist packages/shadow-dom/dist/cjs" + } + }, + "build": { "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/packages/shadow-dom/dist"], "options": { "cwd": "packages/shadow-dom", - "commands": ["tsc --build tsconfig.lib.json --pretty"], - "parallel": false + "command": "tsc --build tsconfig.lib.json --pretty" } } } From ec9f54b20dc911759e03af1b951a5135fd471778 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Fri, 22 May 2026 13:15:06 +0200 Subject: [PATCH 25/26] chore(core/react/shadow-dom): restore main pointing at CJS entry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `main` is the fallback for bare `require('@griffel/core')` calls in older tooling that doesn't honor the exports map. With type: module + main: ./dist/index.js, require() would resolve to the ESM build — fine on Node 22+ via require(esm), but breaks any consumer still on an older Node or build tool. Restore the CJS path so the fallback matches the require condition in exports. Co-Authored-By: Claude Opus 4.7 (1M context) --- packages/core/package.json | 2 +- packages/react/package.json | 2 +- packages/shadow-dom/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core/package.json b/packages/core/package.json index e30c11170..b79306d61 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -9,7 +9,7 @@ }, "sideEffects": false, "type": "module", - "main": "./dist/index.js", + "main": "./dist/cjs/index.cjs", "module": "./dist/index.js", "exports": { ".": { diff --git a/packages/react/package.json b/packages/react/package.json index 663245f68..6cb74539f 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -9,7 +9,7 @@ }, "sideEffects": false, "type": "module", - "main": "./dist/index.js", + "main": "./dist/cjs/index.cjs", "module": "./dist/index.js", "exports": { ".": { diff --git a/packages/shadow-dom/package.json b/packages/shadow-dom/package.json index f91dfefae..c3eefaf15 100644 --- a/packages/shadow-dom/package.json +++ b/packages/shadow-dom/package.json @@ -9,7 +9,7 @@ }, "sideEffects": false, "type": "module", - "main": "./dist/index.js", + "main": "./dist/cjs/index.cjs", "module": "./dist/index.js", "exports": { ".": { From 15e81b4e51f40b56c142beb7a73ed27c5e5aef2a Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Fri, 22 May 2026 13:23:16 +0200 Subject: [PATCH 26/26] chore: rewrite tools/build-cjs.mjs in TypeScript and clean up MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Convert tools/build-cjs.mjs → tools/build-cjs.ts. Node 24+ runs .ts natively (same approach the e2e packages use). Drops the awkward \`@type {const}\` JSDoc in favor of real types — SWC_OPTIONS is now typed as \`Options\` from @swc/core, and every helper has proper parameter/return types. - Drop the redundant \`!absInput.endsWith('.d.cts')\` guard. A filename ending in .d.cts can't also end in .d.ts (the suffixes are literally different), so the check was dead. - Update build-cjs commands in core/react/shadow-dom project.json to reference tools/build-cjs.ts. Co-Authored-By: Claude Opus 4.7 (1M context) --- packages/core/project.json | 2 +- packages/react/project.json | 2 +- packages/shadow-dom/project.json | 2 +- tools/build-cjs.mjs | 73 ------------------------ tools/build-cjs.ts | 95 ++++++++++++++++++++++++++++++++ 5 files changed, 98 insertions(+), 76 deletions(-) delete mode 100644 tools/build-cjs.mjs create mode 100644 tools/build-cjs.ts diff --git a/packages/core/project.json b/packages/core/project.json index b1f153ef4..378ecaaf7 100644 --- a/packages/core/project.json +++ b/packages/core/project.json @@ -32,7 +32,7 @@ "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/packages/core/dist/cjs"], "options": { - "command": "node tools/build-cjs.mjs packages/core/dist packages/core/dist/cjs" + "command": "node tools/build-cjs.ts packages/core/dist packages/core/dist/cjs" } }, "build": { diff --git a/packages/react/project.json b/packages/react/project.json index 199620a29..9708dc00b 100644 --- a/packages/react/project.json +++ b/packages/react/project.json @@ -57,7 +57,7 @@ "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/packages/react/dist/cjs"], "options": { - "command": "node tools/build-cjs.mjs packages/react/dist packages/react/dist/cjs" + "command": "node tools/build-cjs.ts packages/react/dist packages/react/dist/cjs" } }, "build": { diff --git a/packages/shadow-dom/project.json b/packages/shadow-dom/project.json index 8e7ae0630..e805239fd 100644 --- a/packages/shadow-dom/project.json +++ b/packages/shadow-dom/project.json @@ -57,7 +57,7 @@ "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/packages/shadow-dom/dist/cjs"], "options": { - "command": "node tools/build-cjs.mjs packages/shadow-dom/dist packages/shadow-dom/dist/cjs" + "command": "node tools/build-cjs.ts packages/shadow-dom/dist packages/shadow-dom/dist/cjs" } }, "build": { diff --git a/tools/build-cjs.mjs b/tools/build-cjs.mjs deleted file mode 100644 index ff18813d1..000000000 --- a/tools/build-cjs.mjs +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Converts ESM .js files to CJS .cjs files using SWC. - * Also copies .d.ts files alongside as .d.cts so consumers using the - * `require` exports condition under moduleResolution: node16/nodenext - * see CJS-context type declarations. - * - * Usage: node tools/build-cjs.mjs - */ -import { transformFileSync } from '@swc/core'; -import { mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs'; -import { dirname, join, resolve, relative } from 'node:path'; - -const [esmDir, cjsDir] = process.argv.slice(2); - -if (!esmDir || !cjsDir) { - console.error('Usage: node tools/build-cjs.mjs '); - process.exit(1); -} - -const absEsmDir = resolve(esmDir); -const absCjsDir = resolve(cjsDir); - -function collectFiles(dir, predicate) { - const results = []; - for (const entry of readdirSync(dir, { withFileTypes: true })) { - if (entry.name === 'cjs') continue; // skip output sub-directory - const fullPath = join(dir, entry.name); - if (entry.isDirectory()) { - results.push(...collectFiles(fullPath, predicate)); - } else if (predicate(entry.name)) { - results.push(fullPath); - } - } - return results; -} - -const jsFiles = collectFiles(absEsmDir, name => name.endsWith('.js')); - -for (const absInput of jsFiles) { - const rel = relative(absEsmDir, absInput); - const absOutput = join(absCjsDir, rel.replace(/\.js$/, '.cjs')); - - const result = transformFileSync(absInput, { - module: { type: 'commonjs' }, - jsc: { - parser: { syntax: 'ecmascript' }, - target: 'es2022', - }, - sourceMaps: false, - }); - - // Rewrite .js requires to .cjs - const cjsCode = result.code.replace(/(require\(["']\.\.?\/[^"']+)\.js(["']\))/g, '$1.cjs$2'); - - mkdirSync(dirname(absOutput), { recursive: true }); - writeFileSync(absOutput, cjsCode); -} - -const dtsFiles = collectFiles(absEsmDir, name => name.endsWith('.d.ts') && !name.endsWith('.d.cts')); - -for (const absInput of dtsFiles) { - const rel = relative(absEsmDir, absInput); - const absOutput = join(absCjsDir, rel.replace(/\.d\.ts$/, '.d.cts')); - // Rewrite relative .js extensions in import/export specifiers to .cjs - const dtsCode = readFileSync(absInput, 'utf8').replace( - /(from\s+["']\.\.?\/[^"']+)\.js(["'])/g, - '$1.cjs$2', - ); - mkdirSync(dirname(absOutput), { recursive: true }); - writeFileSync(absOutput, dtsCode); -} - -console.log(`Converted ${jsFiles.length} ESM → CJS files and ${dtsFiles.length} .d.ts → .d.cts into ${cjsDir}`); diff --git a/tools/build-cjs.ts b/tools/build-cjs.ts new file mode 100644 index 000000000..46ff1bb7d --- /dev/null +++ b/tools/build-cjs.ts @@ -0,0 +1,95 @@ +/** + * Converts a package's ESM build into a sibling CJS build: + * - /foo/bar.js → /foo/bar.cjs (transpiled by SWC) + * - /foo/bar.d.ts → /foo/bar.d.cts (text-renamed) + * + * Relative `.js` specifiers inside both .js and .d.ts files are rewritten + * to `.cjs` so the CJS package keeps an internally consistent graph. + * + * The .d.cts companions exist so consumers using the `require` exports + * condition under moduleResolution: node16/nodenext see CJS-context type + * declarations. + * + * Usage: node tools/build-cjs.ts + */ +import { transformFileSync, type Options } from '@swc/core'; +import { mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs'; +import { dirname, join, relative, resolve } from 'node:path'; + +const SWC_OPTIONS: Options = { + module: { type: 'commonjs' }, + jsc: { parser: { syntax: 'ecmascript' }, target: 'es2022' }, + sourceMaps: false, +}; + +// `require("./foo.js")` → `require("./foo.cjs")` in compiled CJS sources +const REWRITE_REQUIRE = /(require\(["']\.\.?\/[^"']+)\.js(["']\))/g; +// `from "./foo.js"` → `from "./foo.cjs"` in .d.ts → .d.cts conversions +const REWRITE_IMPORT = /(from\s+["']\.\.?\/[^"']+)\.js(["'])/g; + +const OUTPUT_SUBDIR_TO_SKIP = 'cjs'; + +function* walkFiles(dir: string): Generator { + for (const entry of readdirSync(dir, { withFileTypes: true })) { + // Skip the output subdirectory if it lives under the input dir (re-runs). + if (entry.name === OUTPUT_SUBDIR_TO_SKIP) { + continue; + } + + const fullPath = join(dir, entry.name); + if (entry.isDirectory()) { + yield* walkFiles(fullPath); + continue; + } + + yield fullPath; + } +} + +function writeOutput(absPath: string, content: string): void { + mkdirSync(dirname(absPath), { recursive: true }); + writeFileSync(absPath, content); +} + +function transpileJsToCjs(absSource: string, absTarget: string): void { + const { code } = transformFileSync(absSource, SWC_OPTIONS); + + writeOutput(absTarget, code.replace(REWRITE_REQUIRE, '$1.cjs$2')); +} + +function copyDtsToDcts(absSource: string, absTarget: string): void { + const source = readFileSync(absSource, 'utf8'); + + writeOutput(absTarget, source.replace(REWRITE_IMPORT, '$1.cjs$2')); +} + +function main(): void { + const [esmDir, cjsDir] = process.argv.slice(2); + + if (!esmDir || !cjsDir) { + console.error('Usage: node tools/build-cjs.ts '); + process.exit(1); + } + + const absEsmDir = resolve(esmDir); + const absCjsDir = resolve(cjsDir); + + let jsCount = 0; + let dtsCount = 0; + + for (const absInput of walkFiles(absEsmDir)) { + const relativePath = relative(absEsmDir, absInput); + + if (absInput.endsWith('.d.ts')) { + copyDtsToDcts(absInput, join(absCjsDir, relativePath.replace(/\.d\.ts$/, '.d.cts'))); + dtsCount++; + } else if (absInput.endsWith('.js')) { + transpileJsToCjs(absInput, join(absCjsDir, relativePath.replace(/\.js$/, '.cjs'))); + jsCount++; + } + } + + console.log(`Converted ${jsCount} ESM → CJS files and ${dtsCount} .d.ts → .d.cts into ${cjsDir}`); +} + +main();