From b9462e35b499f6a5bfaddc16b338e111a4c1dc1b Mon Sep 17 00:00:00 2001 From: jn Date: Sat, 16 Nov 2024 15:25:53 +0900 Subject: [PATCH] build: config setting --- .gitignore | 3 ++- package.json | 21 ++++++++++++++++++--- tsconfig.cjs.json | 10 ++++++++++ tsconfig.esm.json | 11 +++++++++++ tsconfig.json | 10 ++-------- 5 files changed, 43 insertions(+), 12 deletions(-) create mode 100644 tsconfig.cjs.json create mode 100644 tsconfig.esm.json diff --git a/.gitignore b/.gitignore index b512c09..76add87 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules \ No newline at end of file +node_modules +dist \ No newline at end of file diff --git a/package.json b/package.json index 96cf7f3..d548071 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,24 @@ { "name": "tailwind-box", "version": "1.0.0", - "main": "index.js", - "license": "MIT", + "main": "dist/cjs/index.js", + "module": "dist/esm/index.js", + "exports": { + ".": { + "import": "./dist/esm/index.js", + "require": "./dist/cjs/index.js" + } + }, + "scripts": { + "build": "yarn build:cjs && yarn build:esm", + "build:cjs": "tsc --p ./tsconfig.cjs.json", + "build:esm": "tsc --p ./tsconfig.esm.json" + }, + "author": { + "name": "jnoncode" + }, "devDependencies": { "typescript": "^5.6.3" - } + }, + "license": "MIT" } diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json new file mode 100644 index 0000000..1c0ac2e --- /dev/null +++ b/tsconfig.cjs.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "CommonJS", + "outDir": "./dist/cjs", + "declaration": true, + "declarationDir": "./dist/cjs" + }, + "include": ["src/**/*"] +} diff --git a/tsconfig.esm.json b/tsconfig.esm.json new file mode 100644 index 0000000..1b8d95f --- /dev/null +++ b/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "esnext", + "moduleResolution": "node", + "outDir": "./dist/esm", + "declaration": true, + "declarationDir": "./dist/esm" + }, + "include": ["src/**/*"] +} diff --git a/tsconfig.json b/tsconfig.json index 13e8ad9..5ca2b6d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,12 +1,6 @@ { "compilerOptions": { - "module": "esnext", - "moduleResolution": "node", "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "./dist", - "declaration": true, - "declarationDir": "./dist" - }, - "include": ["src/**/*"] + "allowSyntheticDefaultImports": true + } }