From 9116dc1c2143f3b8207294be41b24782c4822322 Mon Sep 17 00:00:00 2001 From: Alex Reardon Date: Fri, 24 May 2024 12:31:13 +1000 Subject: [PATCH] wip --- package.json | 13 ++++++++++--- tsconfig.cjs.json | 8 ++++++++ tsconfig.json | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 tsconfig.cjs.json diff --git a/package.json b/package.json index 20105bb..7965e22 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,15 @@ }, "sideEffects": false, "type": "module", - "types": "./dist/index.d.ts", - "exports": "./dist/index.js", + "exports": { + "import": { + ".": "./dist/esm/index.js" + }, + "require": { + ".": "./dist/cjs/index.cjs" + }, + "types": "./dist/esm/index.d.ts" + }, "config": { "prettier_target": "src/**/*.ts test/**/*.ts" }, @@ -44,7 +51,7 @@ "scripts": { "build": "yarn build:clean && yarn build:dist", "build:clean": "rimraf dist", - "build:dist": "tsc", + "build:dist": "tsc && tsc --project tsconfig.cjs.json", "check": "yarn check:typescript && yarn check:prettier", "check:prettier": "prettier --debug-check $npm_package_config_prettier_target", "check:typescript": "tsc --noEmit && tsc --noEmit --project ./test/tsconfig.json", diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json new file mode 100644 index 0000000..20ceb86 --- /dev/null +++ b/tsconfig.cjs.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "verbatimModuleSyntax": false, + "module": "CommonJS", + "outDir": "dist/cjs", + }, +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 2e5f58e..76b7d39 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,7 @@ "noImplicitOverride": true, /* If transpiling with TypeScript: */ "module": "es2022", - "outDir": "dist", + "outDir": "dist/esm", /* AND if you're building for a library: */ "declaration": true, /* If your code runs in the DOM: */