From 020772ba3814549f2d9fc73fa670b5caee6b7155 Mon Sep 17 00:00:00 2001 From: David Epely <65737+iamdey@users.noreply.github.com> Date: Wed, 7 Oct 2026 15:01:12 +0200 Subject: [PATCH 1/4] fix: export module as esm closes https://github.com/reshaped-ui/reshaped/issues/672 - change package type for module in every packages - apply tsc-alias configuration: resolveFullPaths: true where it's necessary - change ts configuration module to esnext instead of nodenext - change ts configuration moduleResolution to bundler instead of nodenext Thanks to this configuration, the code source doesn't need to be strictly esm valid but the emited code will be. --- packages/reshaped/package.json | 1 + packages/reshaped/tsconfig.esm.json | 5 ++++- packages/reshaped/tsconfig.stories.json | 4 ++-- packages/theming/package.json | 5 +++-- packages/theming/tsconfig.json | 5 ++++- packages/utilities/package.json | 1 + packages/utilities/tsconfig.json | 5 ++++- 7 files changed, 19 insertions(+), 7 deletions(-) diff --git a/packages/reshaped/package.json b/packages/reshaped/package.json index c69ad96f..a72b7f2f 100644 --- a/packages/reshaped/package.json +++ b/packages/reshaped/package.json @@ -41,6 +41,7 @@ "sideEffects": [ "*.css" ], + "type": "module", "types": "./dist/index.d.ts", "exports": { ".": { diff --git a/packages/reshaped/tsconfig.esm.json b/packages/reshaped/tsconfig.esm.json index dab6bcf9..824b2968 100644 --- a/packages/reshaped/tsconfig.esm.json +++ b/packages/reshaped/tsconfig.esm.json @@ -17,5 +17,8 @@ "./src/**/*.test.tsx", "./src/**/*.test.ts", "./src/**/*.stories.tsx" - ] + ], + "tsc-alias": { + "resolveFullPaths": true + } } diff --git a/packages/reshaped/tsconfig.stories.json b/packages/reshaped/tsconfig.stories.json index 110467ff..f1096c67 100644 --- a/packages/reshaped/tsconfig.stories.json +++ b/packages/reshaped/tsconfig.stories.json @@ -5,8 +5,8 @@ "outDir": "./dist", "rootDir": "./src", "paths": { "@/*": ["./src/*"] }, - "module": "NodeNext", - "moduleResolution": "NodeNext" + "module": "esnext", + "moduleResolution": "bundler" }, "include": ["./src/**/tests/*.stories.tsx", "./src/**/*.d.ts", "./storybook/**.*.tsx"], "exclude": ["node_modules", "dist", "tools"] diff --git a/packages/theming/package.json b/packages/theming/package.json index b8a812b2..1c54ef66 100644 --- a/packages/theming/package.json +++ b/packages/theming/package.json @@ -26,6 +26,7 @@ "sideEffects": [ "*.css" ], + "type": "module", "types": "./dist/index.d.ts", "exports": { ".": { @@ -50,8 +51,8 @@ }, "scripts": { "clean": "rm -rf dist", - "dev": "tsc-watch --onSuccess \"tsc-alias --resolve-full-paths\"", - "build": "tsc && tsc-alias --resolve-full-paths" + "dev": "tsc-watch --onSuccess \"tsc-alias", + "build": "tsc && tsc-alias" }, "dependencies": { "@types/culori": "4.0.1", diff --git a/packages/theming/tsconfig.json b/packages/theming/tsconfig.json index 2abd9111..a23597d8 100644 --- a/packages/theming/tsconfig.json +++ b/packages/theming/tsconfig.json @@ -11,5 +11,8 @@ } }, "include": ["src/**/*"], - "exclude": ["node_modules", "dist", "./src/**/*.test.tsx", "./src/**/*.test.ts"] + "exclude": ["node_modules", "dist", "./src/**/*.test.tsx", "./src/**/*.test.ts"], + "tsc-alias": { + "resolveFullPaths": true + } } diff --git a/packages/utilities/package.json b/packages/utilities/package.json index ffc73a0d..c3796931 100644 --- a/packages/utilities/package.json +++ b/packages/utilities/package.json @@ -20,6 +20,7 @@ "files": [ "dist/**/*" ], + "type": "module", "types": "./dist/index.d.ts", "exports": { ".": { diff --git a/packages/utilities/tsconfig.json b/packages/utilities/tsconfig.json index ff567495..8e17503b 100644 --- a/packages/utilities/tsconfig.json +++ b/packages/utilities/tsconfig.json @@ -9,5 +9,8 @@ "paths": { "@/*": ["./src/*"] } }, "include": ["src/**/*"], - "exclude": ["node_modules", "dist"] + "exclude": ["node_modules", "dist"], + "tsc-alias": { + "resolveFullPaths": true + } } From a175575ead0c3c9426678ec282bc884aa6cccc1a Mon Sep 17 00:00:00 2001 From: David Epely <65737+iamdey@users.noreply.github.com> Date: Fri, 16 Oct 2026 15:29:43 +0200 Subject: [PATCH 2/4] review: fix cli, use recent ecmascript instead of cjs --- packages/reshaped/bin/cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/reshaped/bin/cli.js b/packages/reshaped/bin/cli.js index 3864ad1e..7df48d38 100644 --- a/packages/reshaped/bin/cli.js +++ b/packages/reshaped/bin/cli.js @@ -1,2 +1,2 @@ #!/usr/bin/env node -require("@reshaped/theming/cli/run"); +import "@reshaped/theming/cli/run"; From 0f7c0dfecf3ae1c84c264fe82a1013875790ec96 Mon Sep 17 00:00:00 2001 From: David Epely <65737+iamdey@users.noreply.github.com> Date: Fri, 16 Oct 2026 15:38:45 +0200 Subject: [PATCH 3/4] review: fix typo in theming dev script --- packages/theming/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/theming/package.json b/packages/theming/package.json index 1c54ef66..da807b69 100644 --- a/packages/theming/package.json +++ b/packages/theming/package.json @@ -51,7 +51,7 @@ }, "scripts": { "clean": "rm -rf dist", - "dev": "tsc-watch --onSuccess \"tsc-alias", + "dev": "tsc-watch --onSuccess \"tsc-alias\"", "build": "tsc && tsc-alias" }, "dependencies": { From 5250e1b7ee00e5f66c543361b8abf5deedc09fd8 Mon Sep 17 00:00:00 2001 From: David Epely <65737+iamdey@users.noreply.github.com> Date: Fri, 16 Oct 2026 16:22:20 +0200 Subject: [PATCH 4/4] review: fix extension of bundle file to match umd requirements --- .gitignore | 6 +++--- package.json | 2 +- packages/reshaped/bin/clean.sh | 2 +- packages/reshaped/package.json | 8 ++++---- packages/reshaped/vite.config.mjs | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 8fb83015..e16fa188 100644 --- a/.gitignore +++ b/.gitignore @@ -20,9 +20,9 @@ dist /cli /index.js /index.d.ts -/bundle.js -/bundle.js.map +/bundle.cjs +/bundle.cjs.map /bundle.css /bundle.css.map -/bundle.d.ts +/bundle.d.cts *.log diff --git a/package.json b/package.json index e26c2ecd..c64a62a8 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "size-limit": [ { "name": "Library / JS", - "path": "packages/reshaped/dist/bundle.js", + "path": "packages/reshaped/dist/bundle.cjs", "webpack": false }, { diff --git a/packages/reshaped/bin/clean.sh b/packages/reshaped/bin/clean.sh index 0e30ed2f..9d7b7b43 100644 --- a/packages/reshaped/bin/clean.sh +++ b/packages/reshaped/bin/clean.sh @@ -2,4 +2,4 @@ find ./src -type d -mindepth 1 -maxdepth 1 | xargs -L1 basename | xargs -L1 rm -rf rm -rf dist -rm -f index.js index.d.ts bundle.js bundle.js.map bundle.css bundle.css.map bundle.d.ts +rm -f index.js index.d.ts bundle.cjs bundle.cjs.map bundle.css bundle.css.map bundle.d.cts diff --git a/packages/reshaped/package.json b/packages/reshaped/package.json index a72b7f2f..0407fa7e 100644 --- a/packages/reshaped/package.json +++ b/packages/reshaped/package.json @@ -64,9 +64,9 @@ "default": "./dist/config/postcss.cjs" }, "./bundle": { - "types": "./dist/bundle.d.ts", - "import": "./dist/bundle.js", - "default": "./dist/bundle.js" + "types": "./dist/bundle.d.cts", + "import": "./dist/bundle.cjs", + "default": "./dist/bundle.cjs" }, "./themes/slate/*": "./dist/themes/slate/*", "./themes/figma/*": "./dist/themes/figma/*", @@ -82,7 +82,7 @@ "build:esm": "tsc -p tsconfig.esm.json && tsc-alias -p tsconfig.esm.json", "build:css": "postcss \"src/**/*.css\" --dir dist --base src --config tools/build", "build:stories": "tsc -p tsconfig.stories.json && tsc-alias -p tsconfig.stories.json", - "build:bundle": "vite build && shx cp dist/index.d.ts dist/bundle.d.ts", + "build:bundle": "vite build && shx cp dist/index.d.ts dist/bundle.d.cts", "build:size": "pnpm clean && pnpm build:esm && pnpm build:bundle", "test:browser": "vitest run --project=storybook", "test:unit": "vitest run --project=unit", diff --git a/packages/reshaped/vite.config.mjs b/packages/reshaped/vite.config.mjs index 4d58372c..f815e8d8 100644 --- a/packages/reshaped/vite.config.mjs +++ b/packages/reshaped/vite.config.mjs @@ -25,8 +25,8 @@ export default defineConfig({ logLevel: "silent", external: ["react", "react/jsx-runtime", "react-dom"], output: { - entryFileNames: "bundle.js", - chunkFileNames: "[name].js", + entryFileNames: "bundle.cjs", + chunkFileNames: "[name].cjs", globals: { react: "React", "react-dom": "ReactDOM",