From 187fd153fef8bbb7854d30762d90bc24487d9c9c Mon Sep 17 00:00:00 2001 From: Mahmoud Moravej Date: Fri, 26 Apr 2024 16:05:25 -0400 Subject: [PATCH] add build for esm module and commonsjs --- packages/material-tailwind-react/.es6.swcrc | 14 +++++++++++ packages/material-tailwind-react/package.json | 16 ++++++++---- .../material-tailwind-react/tsconfig.es6.json | 25 +++++++++++++++++++ .../material-tailwind-react/tsconfig.json | 2 +- 4 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 packages/material-tailwind-react/.es6.swcrc create mode 100644 packages/material-tailwind-react/tsconfig.es6.json diff --git a/packages/material-tailwind-react/.es6.swcrc b/packages/material-tailwind-react/.es6.swcrc new file mode 100644 index 000000000..1ee88e181 --- /dev/null +++ b/packages/material-tailwind-react/.es6.swcrc @@ -0,0 +1,14 @@ +{ + "minify": true, + "jsc": { + "parser": { + "syntax": "typescript", + "tsx": true + } + }, + + "isModule": true, + "module": { + "type": "es6" + } +} diff --git a/packages/material-tailwind-react/package.json b/packages/material-tailwind-react/package.json index c8265d794..295122f8b 100644 --- a/packages/material-tailwind-react/package.json +++ b/packages/material-tailwind-react/package.json @@ -5,16 +5,22 @@ "description": "@material-tailwind/react is an easy-to-use components library for ReactJS & Tailwind CSS inspired by Material Design.", "repository": "https://github.com/creativetimofficial/material-tailwind", "license": "MIT", - "main": "index.js", + "module": "dist/es6/index.js", "typings": "index.d.ts", "publishConfig": { "access": "public" }, + "type": "module", "scripts": { - "build:cjs": "swc ./src -d ./dist --only ./src/**/*.ts --config-file .swcrc", - "build:dts": "tsc --declaration --declarationMap --emitDeclarationOnly", - "copy": "cp ./package.json ./dist && cp ./README.md ./dist && cp ./LICENSE ./dist", - "build": "pnpm build:cjs && pnpm build:dts && pnpm copy", + "buildbase:commonjs": "swc ./src -d ./dist/commonjs --only ./src/**/*.ts --config-file .swcrc", + "buildbase:es6": "swc ./src -d ./dist/es6 --only ./src/**/*.ts --config-file .es6.swcrc --no-swcrc", + "buildbase:dts": "tsc --declaration --declarationMap --emitDeclarationOnly", + "buildbase:dts:es6": "pnpm buildbase:dts --project tsconfig.es6.json", + "copy:commonjs": "cp ./package.json ./dist/commonjs && cp ./README.md ./dist/commonjs && cp ./LICENSE ./dist/commonjs", + "copy:es6": "cp ./package.json ./dist/es6 && cp ./README.md ./dist/es6 && cp ./LICENSE ./dist/es6", + "build:commonjs": "pnpm buildbase:commonjs && pnpm buildbase:dts && pnpm copy:commonjs", + "build:es6": "pnpm buildbase:es6 && pnpm buildbase:dts:es6 && pnpm copy:es6", + "build": "pnpm build:commonjs && pnpm build:es6", "lint:check": "eslint . --ext js,jsx,ts,tsx --max-warnings=0 --config .eslintrc.json --no-eslintrc", "prettier:check": "prettier -c ." }, diff --git a/packages/material-tailwind-react/tsconfig.es6.json b/packages/material-tailwind-react/tsconfig.es6.json new file mode 100644 index 000000000..815430b9d --- /dev/null +++ b/packages/material-tailwind-react/tsconfig.es6.json @@ -0,0 +1,25 @@ +{ + "include": ["src"], + "compilerOptions": { + "lib": ["ES2021", "DOM", "DOM.Iterable"], + "incremental": false, + "isolatedModules": true, + "importsNotUsedAsValues": "error", + "allowJs": true, + "esModuleInterop": true, + "jsx": "react", + "moduleResolution": "node", + "module": "ES6", + "target": "ES6", + "strict": false, + "skipLibCheck": true, + "resolveJsonModule": true, + "noUncheckedIndexedAccess": true, + "declaration": true, + "emitDeclarationOnly": true, + "outDir": "dist/es6", + "declarationMap": true, + "baseUrl": ".", + "typeRoots": ["./node_modules/@types"] + } +} diff --git a/packages/material-tailwind-react/tsconfig.json b/packages/material-tailwind-react/tsconfig.json index ae118f67e..b72119a70 100644 --- a/packages/material-tailwind-react/tsconfig.json +++ b/packages/material-tailwind-react/tsconfig.json @@ -17,7 +17,7 @@ "noUncheckedIndexedAccess": true, "declaration": true, "emitDeclarationOnly": true, - "outDir": "dist", + "outDir": "dist/commonjs", "declarationMap": true, "baseUrl": ".", "typeRoots": ["./node_modules/@types"]