From f6eeb4a04a10d13e79fad3a339dff1ba368d2087 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Wed, 12 Nov 2025 15:44:11 +0100 Subject: [PATCH 1/2] Revert "fix: cjs declaration (#334)" This reverts commit 622afe8fb071ac9c1376824c5aee51216ebc686f. --- commonjs.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/commonjs.js b/commonjs.js index 73fd6b72..7bf5e61a 100644 --- a/commonjs.js +++ b/commonjs.js @@ -12,17 +12,6 @@ function convertToCommonJs(filePath) { fs.renameSync(filePath, commonJsPath); } -function convertToCommonJsDeclaration(filePath) { - // update imports - const content = fs.readFileSync(filePath, 'utf-8'); - const updatedContent = content.replace(/(from ['"])(.*)(\.js)(['"];?)/g, '$1$2.cjs$4'); - fs.writeFileSync(filePath, updatedContent, 'utf-8'); - - // update file extension - const commonJsDeclPath = filePath.replace(/\.d\.ts$/, '.d.cts'); - fs.renameSync(filePath, commonJsDeclPath); -} - function walk(dir) { fs.readdirSync(dir).forEach(file => { const fullPath = path.join(dir, file); @@ -30,8 +19,6 @@ function walk(dir) { walk(fullPath); } else if (file.endsWith('.js')) { convertToCommonJs(fullPath); - } else if (file.endsWith('.d.ts')) { - convertToCommonJsDeclaration(fullPath); } }); } From b45a886e5aa54b4b10cc16744c1d6110d28859e2 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Wed, 12 Nov 2025 15:47:40 +0100 Subject: [PATCH 2/2] Revert "fix: support cjs (#301)" This reverts commit a2b7cc5de87749db44c77c1fecefb9b4dd8ad9fa. --- .gitignore | 1 - commonjs.js | 26 -------------------------- package.json | 12 ++++-------- tsconfig.cjs.json | 7 ------- 4 files changed, 4 insertions(+), 42 deletions(-) delete mode 100644 commonjs.js delete mode 100644 tsconfig.cjs.json diff --git a/.gitignore b/.gitignore index a2f9a256..0e75fe55 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ node_modules dist -dist-cjs coverage diff --git a/commonjs.js b/commonjs.js deleted file mode 100644 index 7bf5e61a..00000000 --- a/commonjs.js +++ /dev/null @@ -1,26 +0,0 @@ -import fs from 'fs'; -import path from 'path'; - -function convertToCommonJs(filePath) { - // update imports - const content = fs.readFileSync(filePath, 'utf-8'); - const updatedContent = content.replace(/(require\(['"])(.*)(\.js)(['"]\))/g, '$1$2.cjs$4'); - fs.writeFileSync(filePath, updatedContent, 'utf-8'); - - // update file extension - const commonJsPath = filePath.replace(/\.js$/, '.cjs'); - fs.renameSync(filePath, commonJsPath); -} - -function walk(dir) { - fs.readdirSync(dir).forEach(file => { - const fullPath = path.join(dir, file); - if (fs.lstatSync(fullPath).isDirectory()) { - walk(fullPath); - } else if (file.endsWith('.js')) { - convertToCommonJs(fullPath); - } - }); -} - -walk('./dist-cjs'); diff --git a/package.json b/package.json index 349f0d56..890df89f 100644 --- a/package.json +++ b/package.json @@ -2,23 +2,19 @@ "version": "2.2.5", "license": "MIT", "type": "module", - "typings": "dist/index.d.cts", + "typings": "dist/index.d.ts", "main": "./dist/index.js", "exports": { - "import": "./dist/index.js", - "require": "./dist-cjs/index.cjs" + ".": "./dist/index.js" }, "files": [ - "dist", - "dist-cjs" + "dist" ], "engines": { "node": ">=16" }, "scripts": { - "build": "yarn run build:esm && yarn run build:cjs", - "build:esm": "tsc -p tsconfig.json", - "build:cjs": "tsc -p tsconfig.cjs.json && node commonjs.js", + "build": "tsc", "test": "vitest run", "lint": "tsdx lint", "prepack": "yarn build", diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json deleted file mode 100644 index 67774dfa..00000000 --- a/tsconfig.cjs.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "module": "CommonJS", - "outDir": "dist-cjs" - } -}