From bf2f76964b7ae46e39599aa742888fa85d65990c Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Fri, 6 Mar 2026 14:58:54 +0100 Subject: [PATCH] refactor(core,react,shadow-dom,style-types): replace rollup with tsc for builds Replace @nx/rollup:rollup executor with dual tsc builds (ESM + CJS) for the four browser packages. Uses composite project references to handle cross-package dependencies. Co-Authored-By: Claude Opus 4.6 --- packages/core/package.json | 3 ++ packages/core/project.json | 38 +++++++--------------- packages/core/tsconfig.lib.cjs.json | 11 +++++++ packages/core/tsconfig.lib.json | 11 +++++-- packages/react/package.json | 3 ++ packages/react/project.json | 38 +++++++--------------- packages/react/tsconfig.lib.cjs.json | 11 +++++++ packages/react/tsconfig.lib.json | 11 +++++-- packages/shadow-dom/package.json | 3 ++ packages/shadow-dom/project.json | 38 +++++++--------------- packages/shadow-dom/tsconfig.lib.cjs.json | 11 +++++++ packages/shadow-dom/tsconfig.lib.json | 11 +++++-- packages/style-types/package.json | 14 ++++---- packages/style-types/project.json | 37 +++++++-------------- packages/style-types/tsconfig.lib.cjs.json | 10 ++++++ packages/style-types/tsconfig.lib.json | 10 ++++-- 16 files changed, 143 insertions(+), 117 deletions(-) create mode 100644 packages/core/tsconfig.lib.cjs.json create mode 100644 packages/react/tsconfig.lib.cjs.json create mode 100644 packages/shadow-dom/tsconfig.lib.cjs.json create mode 100644 packages/style-types/tsconfig.lib.cjs.json diff --git a/packages/core/package.json b/packages/core/package.json index 5068eecb4..f1252f5c0 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -8,6 +8,9 @@ "url": "https://github.com/microsoft/griffel" }, "sideEffects": false, + "main": "./cjs/index.js", + "module": "./index.js", + "types": "./index.d.ts", "dependencies": { "@emotion/hash": "^0.9.0", "@griffel/style-types": "^1.3.0", diff --git a/packages/core/project.json b/packages/core/project.json index 7a4c0cdb7..48ae31985 100644 --- a/packages/core/project.json +++ b/packages/core/project.json @@ -6,33 +6,19 @@ "tags": [], "targets": { "build": { - "executor": "@nx/rollup:rollup", - "outputs": ["{options.outputPath}"], + "dependsOn": ["^build"], + "executor": "nx:run-commands", + "outputs": ["{workspaceRoot}/dist/packages/core"], "options": { - "outputPath": "dist/packages/core", - "tsConfig": "packages/core/tsconfig.lib.json", - "skipTypeField": true, - "skipTypeCheck": true, - "project": "packages/core/package.json", - "entryFile": "packages/core/src/index.ts", - "useLegacyTypescriptPlugin": true, - "rollupConfig": "tools/getRollupOptions.js", - "compiler": "babel", - "sourceMap": true, - "external": ["tslib"], - "format": ["esm", "cjs"], - "assets": [ - { - "glob": "packages/core/README.md", - "input": ".", - "output": "." - }, - { - "glob": "LICENSE.md", - "input": ".", - "output": "." - } - ] + "cwd": "packages/core", + "commands": [ + "tsc -b tsconfig.lib.json --pretty", + "tsc -b tsconfig.lib.cjs.json --pretty", + "cp package.json ../../dist/packages/core/package.json", + "cp README.md ../../dist/packages/core/README.md", + "cp ../../LICENSE.md ../../dist/packages/core/LICENSE.md" + ], + "parallel": false } }, "lint": { diff --git a/packages/core/tsconfig.lib.cjs.json b/packages/core/tsconfig.lib.cjs.json new file mode 100644 index 000000000..eeec9de7a --- /dev/null +++ b/packages/core/tsconfig.lib.cjs.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.lib.json", + "compilerOptions": { + "module": "node16", + "moduleResolution": "node16", + "outDir": "../../dist/packages/core/cjs", + "tsBuildInfoFile": "../../dist/packages/core/cjs/tsconfig.lib.cjs.tsbuildinfo", + "sourceMap": false + }, + "references": [{ "path": "../style-types/tsconfig.lib.cjs.json" }] +} diff --git a/packages/core/tsconfig.lib.json b/packages/core/tsconfig.lib.json index d22b5ad70..8e7102d78 100644 --- a/packages/core/tsconfig.lib.json +++ b/packages/core/tsconfig.lib.json @@ -1,10 +1,16 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "composite": true, + "outDir": "../../dist/packages/core", + "tsBuildInfoFile": "../../dist/packages/core/tsconfig.lib.tsbuildinfo", + "rootDir": "./src", + "declaration": true, + "declarationMap": true, "types": ["node", "environment"] }, "exclude": [ + "dist", "**/*.spec.ts", "**/*.test.ts", "**/*.spec.tsx", @@ -15,5 +21,6 @@ "**/*.test.jsx", "jest.config.ts" ], - "include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"] + "include": ["src/**/*.ts", "src/**/*.tsx"], + "references": [{ "path": "../style-types/tsconfig.lib.json" }] } diff --git a/packages/react/package.json b/packages/react/package.json index 956f654a7..f25c85ce3 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -8,6 +8,9 @@ "url": "https://github.com/microsoft/griffel" }, "sideEffects": false, + "main": "./cjs/index.js", + "module": "./index.js", + "types": "./index.d.ts", "wyw-in-js": { "tags": { "makeStyles": "@griffel/tag-processor/make-styles", diff --git a/packages/react/project.json b/packages/react/project.json index eb3267aaf..fda42db5f 100644 --- a/packages/react/project.json +++ b/packages/react/project.json @@ -6,33 +6,19 @@ "tags": [], "targets": { "build": { - "executor": "@nx/rollup:rollup", - "outputs": ["{options.outputPath}"], + "dependsOn": ["^build"], + "executor": "nx:run-commands", + "outputs": ["{workspaceRoot}/dist/packages/react"], "options": { - "outputPath": "dist/packages/react", - "tsConfig": "packages/react/tsconfig.lib.json", - "skipTypeField": true, - "skipTypeCheck": true, - "project": "packages/react/package.json", - "entryFile": "packages/react/src/index.ts", - "compiler": "babel", - "sourceMap": true, - "useLegacyTypescriptPlugin": true, - "rollupConfig": ["@nx/react/plugins/bundle-rollup", "tools/getRollupOptions.js"], - "external": ["tslib"], - "format": ["esm", "cjs"], - "assets": [ - { - "glob": "packages/react/README.md", - "input": ".", - "output": "." - }, - { - "glob": "LICENSE.md", - "input": ".", - "output": "." - } - ] + "cwd": "packages/react", + "commands": [ + "tsc -b tsconfig.lib.json --pretty", + "tsc -b tsconfig.lib.cjs.json --pretty", + "cp package.json ../../dist/packages/react/package.json", + "cp README.md ../../dist/packages/react/README.md", + "cp ../../LICENSE.md ../../dist/packages/react/LICENSE.md" + ], + "parallel": false } }, "lint": { diff --git a/packages/react/tsconfig.lib.cjs.json b/packages/react/tsconfig.lib.cjs.json new file mode 100644 index 000000000..1bfda4a79 --- /dev/null +++ b/packages/react/tsconfig.lib.cjs.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.lib.json", + "compilerOptions": { + "module": "node16", + "moduleResolution": "node16", + "outDir": "../../dist/packages/react/cjs", + "tsBuildInfoFile": "../../dist/packages/react/cjs/tsconfig.lib.cjs.tsbuildinfo", + "sourceMap": false + }, + "references": [{ "path": "../core/tsconfig.lib.cjs.json" }] +} diff --git a/packages/react/tsconfig.lib.json b/packages/react/tsconfig.lib.json index acec26066..07412cc74 100644 --- a/packages/react/tsconfig.lib.json +++ b/packages/react/tsconfig.lib.json @@ -1,10 +1,16 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "composite": true, + "outDir": "../../dist/packages/react", + "tsBuildInfoFile": "../../dist/packages/react/tsconfig.lib.tsbuildinfo", + "rootDir": "./src", + "declaration": true, + "declarationMap": true, "types": ["node", "environment"] }, "exclude": [ + "dist", "**/*.spec.ts", "**/*.test.ts", "**/*.spec.tsx", @@ -19,5 +25,6 @@ "**/*.stories.tsx", "jest.config.ts" ], - "include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"] + "include": ["src/**/*.ts", "src/**/*.tsx"], + "references": [{ "path": "../core/tsconfig.lib.json" }] } diff --git a/packages/shadow-dom/package.json b/packages/shadow-dom/package.json index c8b11f726..de9204646 100644 --- a/packages/shadow-dom/package.json +++ b/packages/shadow-dom/package.json @@ -8,6 +8,9 @@ "url": "https://github.com/microsoft/griffel" }, "sideEffects": false, + "main": "./cjs/index.js", + "module": "./index.js", + "types": "./index.d.ts", "dependencies": { "@griffel/core": "^1.19.2", "tslib": "^2.1.0" diff --git a/packages/shadow-dom/project.json b/packages/shadow-dom/project.json index 6795854a8..2149143cb 100644 --- a/packages/shadow-dom/project.json +++ b/packages/shadow-dom/project.json @@ -6,33 +6,19 @@ "tags": [], "targets": { "build": { - "executor": "@nx/rollup:rollup", - "outputs": ["{options.outputPath}"], + "dependsOn": ["^build"], + "executor": "nx:run-commands", + "outputs": ["{workspaceRoot}/dist/packages/shadow-dom"], "options": { - "outputPath": "dist/packages/shadow-dom", - "tsConfig": "packages/shadow-dom/tsconfig.lib.json", - "skipTypeField": true, - "skipTypeCheck": true, - "project": "packages/shadow-dom/package.json", - "entryFile": "packages/shadow-dom/src/index.ts", - "compiler": "babel", - "sourceMap": true, - "useLegacyTypescriptPlugin": true, - "rollupConfig": ["@nx/react/plugins/bundle-rollup", "tools/getRollupOptions.js"], - "external": ["tslib"], - "format": ["esm", "cjs"], - "assets": [ - { - "glob": "packages/shadow-dom/README.md", - "input": ".", - "output": "." - }, - { - "glob": "LICENSE.md", - "input": ".", - "output": "." - } - ] + "cwd": "packages/shadow-dom", + "commands": [ + "tsc -b tsconfig.lib.json --pretty", + "tsc -b tsconfig.lib.cjs.json --pretty", + "cp package.json ../../dist/packages/shadow-dom/package.json", + "cp README.md ../../dist/packages/shadow-dom/README.md", + "cp ../../LICENSE.md ../../dist/packages/shadow-dom/LICENSE.md" + ], + "parallel": false } }, "lint": { diff --git a/packages/shadow-dom/tsconfig.lib.cjs.json b/packages/shadow-dom/tsconfig.lib.cjs.json new file mode 100644 index 000000000..475859058 --- /dev/null +++ b/packages/shadow-dom/tsconfig.lib.cjs.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.lib.json", + "compilerOptions": { + "module": "node16", + "moduleResolution": "node16", + "outDir": "../../dist/packages/shadow-dom/cjs", + "tsBuildInfoFile": "../../dist/packages/shadow-dom/cjs/tsconfig.lib.cjs.tsbuildinfo", + "sourceMap": false + }, + "references": [{ "path": "../core/tsconfig.lib.cjs.json" }] +} diff --git a/packages/shadow-dom/tsconfig.lib.json b/packages/shadow-dom/tsconfig.lib.json index acec26066..68a3365a2 100644 --- a/packages/shadow-dom/tsconfig.lib.json +++ b/packages/shadow-dom/tsconfig.lib.json @@ -1,10 +1,16 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "composite": true, + "outDir": "../../dist/packages/shadow-dom", + "tsBuildInfoFile": "../../dist/packages/shadow-dom/tsconfig.lib.tsbuildinfo", + "rootDir": "./src", + "declaration": true, + "declarationMap": true, "types": ["node", "environment"] }, "exclude": [ + "dist", "**/*.spec.ts", "**/*.test.ts", "**/*.spec.tsx", @@ -19,5 +25,6 @@ "**/*.stories.tsx", "jest.config.ts" ], - "include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"] + "include": ["src/**/*.ts", "src/**/*.tsx"], + "references": [{ "path": "../core/tsconfig.lib.json" }] } diff --git a/packages/style-types/package.json b/packages/style-types/package.json index a76fa244c..bf28ae1b1 100644 --- a/packages/style-types/package.json +++ b/packages/style-types/package.json @@ -8,15 +8,17 @@ "url": "https://github.com/microsoft/griffel" }, "sideEffects": false, - "dependencies": { - "csstype": "^3.1.3" - }, - "types": "src/index.d.ts", + "main": "./cjs/index.js", + "module": "./index.js", + "types": "./index.d.ts", "typesVersions": { "<4.4": { - "src/index.d.ts": [ - "src/legacy/index.d.ts" + "index.d.ts": [ + "legacy/index.d.ts" ] } + }, + "dependencies": { + "csstype": "^3.1.3" } } diff --git a/packages/style-types/project.json b/packages/style-types/project.json index a0f778d2f..8e5996d55 100644 --- a/packages/style-types/project.json +++ b/packages/style-types/project.json @@ -6,32 +6,19 @@ "tags": [], "targets": { "build": { - "executor": "@nx/rollup:rollup", - "outputs": ["{options.outputPath}"], + "dependsOn": ["^build"], + "executor": "nx:run-commands", + "outputs": ["{workspaceRoot}/dist/packages/style-types"], "options": { - "outputPath": "dist/packages/style-types", - "tsConfig": "packages/style-types/tsconfig.lib.json", - "skipTypeCheck": true, - "project": "packages/style-types/package.json", - "entryFile": "packages/style-types/src/index.ts", - "useLegacyTypescriptPlugin": true, - "rollupConfig": "tools/getRollupOptions.js", - "sourceMap": true, - "compiler": "babel", - "external": ["tslib"], - "format": ["esm", "cjs"], - "assets": [ - { - "glob": "packages/style-types/README.md", - "input": ".", - "output": "." - }, - { - "glob": "LICENSE.md", - "input": ".", - "output": "." - } - ] + "cwd": "packages/style-types", + "commands": [ + "tsc -b tsconfig.lib.json --pretty", + "tsc -b tsconfig.lib.cjs.json --pretty", + "cp package.json ../../dist/packages/style-types/package.json", + "cp README.md ../../dist/packages/style-types/README.md", + "cp ../../LICENSE.md ../../dist/packages/style-types/LICENSE.md" + ], + "parallel": false } }, "lint": { diff --git a/packages/style-types/tsconfig.lib.cjs.json b/packages/style-types/tsconfig.lib.cjs.json new file mode 100644 index 000000000..d0f34a179 --- /dev/null +++ b/packages/style-types/tsconfig.lib.cjs.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.lib.json", + "compilerOptions": { + "module": "node16", + "moduleResolution": "node16", + "outDir": "../../dist/packages/style-types/cjs", + "tsBuildInfoFile": "../../dist/packages/style-types/cjs/tsconfig.lib.cjs.tsbuildinfo", + "sourceMap": false + } +} diff --git a/packages/style-types/tsconfig.lib.json b/packages/style-types/tsconfig.lib.json index d22b5ad70..3cf360183 100644 --- a/packages/style-types/tsconfig.lib.json +++ b/packages/style-types/tsconfig.lib.json @@ -1,10 +1,16 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "composite": true, + "outDir": "../../dist/packages/style-types", + "tsBuildInfoFile": "../../dist/packages/style-types/tsconfig.lib.tsbuildinfo", + "rootDir": "./src", + "declaration": true, + "declarationMap": true, "types": ["node", "environment"] }, "exclude": [ + "dist", "**/*.spec.ts", "**/*.test.ts", "**/*.spec.tsx", @@ -15,5 +21,5 @@ "**/*.test.jsx", "jest.config.ts" ], - "include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"] + "include": ["src/**/*.js", "src/**/*.ts"] }