diff --git a/eslint.config.js b/eslint.config.js index be79bcf..7052092 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -29,6 +29,6 @@ export default tseslint.config( "AudioWorkletGlobalScope": false } }, - ignores: ["node_modules", "dist"], + ignores: [ "dist/"], } ) diff --git a/package.json b/package.json index af286bb..2d04d84 100644 --- a/package.json +++ b/package.json @@ -35,32 +35,64 @@ }, "exports": { ".": { - "types": "./dist/index.d.ts", - "require": "./dist/bundle/wretch.min.cjs", - "import": "./dist/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.cjs" + }, + "import": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + } }, "./all": { - "types": "./dist/index.all.d.ts", - "require": "./dist/bundle/wretch.all.min.cjs", - "import": "./dist/index.all.js" + "require": { + "types": "./dist/cjs/index.all.d.ts", + "default": "./dist/cjs/index.all.js" + }, + "import": { + "types": "./dist/index.all.d.ts", + "default:": "./dist/index.all.js" + } }, "./addons": { - "types": "./dist/addons/index.d.ts", - "import": "./dist/addons/index.js" + "require": { + "types": "./dist/cjs/addons/index.d.ts", + "default": "./dist/cjs/addons/index.js" + }, + "import": { + "types": "./dist/addons/index.d.ts", + "default": "./dist/addons/index.js" + } }, "./addons/*": { - "types": "./dist/addons/*.d.ts", - "require": "./dist/bundle/addons/*.min.cjs", - "import": "./dist/addons/*.js" + "require": { + "types": "./dist/cjs/addons/*.d.ts", + "default": "./dist/cjs/addons/*.js" + }, + "import": { + "types": "./dist/addons/*.d.ts", + "default": "./dist/addons/*.js" + } }, "./middlewares": { - "types": "./dist/middlewares/index.d.ts", - "import": "./dist/middlewares/index.js" + "require": { + "types": "./dist/cjs/middlewares/index.d.ts", + "default": "./dist/cjs/middlewares/index.js" + }, + "import": { + "types": "./dist/middlewares/index.d.ts", + "default": "./dist/middlewares/index.js" + } }, "./middlewares/*": { - "types": "./dist/middlewares/*.d.ts", - "require": "./dist/bundle/middlewares/*.min.cjs", - "import": "./dist/middlewares/*.js" + "require": { + "types": "./dist/cjs/middlewares/*.d.ts", + "default": "./dist/cjs/middlewares/*.js" + }, + "import": { + "types": "./dist/middlewares/*.d.ts", + "default": "./dist/middlewares/*.js" + } }, "./package.json": "./package.json", "./*.mjs": { @@ -82,7 +114,7 @@ "lint": "eslint '{src,test}/**/*.{js,ts}'", "lint:fix": "eslint '{src,test}/**/*.{js,ts}' --fix", "prebuild": "rimraf dist && rimraf coverage && npm run lint", - "build": "tsc -p . && rollup -c", + "build": "tsc && tsc --project tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > ./dist/cjs/package.json && rollup -c", "mock": "node scripts/mockServer.js", "mock:wait": "wait-on -t 10000 http://localhost:9876/ping", "test": "concurrently --success first -k 'npm run mock:wait && jest' 'npm run mock'", diff --git a/src/index.cts b/src/index.cts new file mode 100644 index 0000000..b76d642 --- /dev/null +++ b/src/index.cts @@ -0,0 +1,3 @@ +import factory from "./index.js"; + +module.exports = factory.default; diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json new file mode 100644 index 0000000..d0cbcd3 --- /dev/null +++ b/tsconfig.cjs.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "CommonJS", + "outDir": "dist/cjs", + "declarationDir": "dist/cjs" + }, + "exclude": [] +} diff --git a/tsconfig.json b/tsconfig.json index 8942c9c..5b9215f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,11 +1,7 @@ { "compilerOptions": { "target": "ES2018", - "lib": [ - "es2020", - "dom", - "dom.iterable" - ], + "lib": ["es2020", "dom", "dom.iterable"], "module": "es2015", "outDir": "dist", "declaration": true, @@ -16,7 +12,6 @@ "moduleResolution": "node", "isolatedModules": true }, - "include": [ - "src/**/*" - ] -} \ No newline at end of file + "include": ["src/**/*"], + "exclude": ["src/**/index.cts"] +}