diff --git a/package-lock.json b/package-lock.json index 9685907..3e0c256 100644 --- a/package-lock.json +++ b/package-lock.json @@ -51,12 +51,12 @@ "jsdom": "24.0.0", "lodash": "4.17.21", "mapbox-gl": "^3.5.2", - "moment": "^2.30.1", "postcss": "8.4.38", "prettier": "3.2.5", "react-map-gl": "^7.1.7", "storybook": "^8.1.11", "vite": "5.2.9", + "vite-plugin-commonjs": "^0.10.1", "vite-plugin-dts": "3.8.3", "vite-plugin-eslint": "^1.8.1", "vite-tsconfig-paths": "4.3.2", @@ -68,6 +68,7 @@ "peerDependencies": { "clsx": "2.1.0", "lazysizes": "^5.3.2", + "moment": "^2.30.1", "react": "^18.2.0", "react-dom": "^18.2.0", "tailwindcss": "3.4.4", @@ -10843,7 +10844,7 @@ "version": "2.30.1", "resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz", "integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==", - "dev": true, + "peer": true, "engines": { "node": "*" } @@ -14563,6 +14564,30 @@ "url": "https://opencollective.com/vitest" } }, + "node_modules/vite-plugin-commonjs": { + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/vite-plugin-commonjs/-/vite-plugin-commonjs-0.10.1.tgz", + "integrity": "sha512-taP8R9kYGlCW5OzkVR0UIWRCnG6rSxeWWuA7tnU5b9t5MniibOnDY219NhisTeDhJAeGT8cEnrhVWZ9A5yD+vg==", + "dev": true, + "dependencies": { + "acorn": "^8.8.2", + "fast-glob": "^3.2.12", + "magic-string": "^0.30.1", + "vite-plugin-dynamic-import": "^1.5.0" + } + }, + "node_modules/vite-plugin-commonjs/node_modules/acorn": { + "version": "8.12.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", + "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/vite-plugin-dts": { "version": "3.8.3", "dev": true, @@ -14589,6 +14614,36 @@ } } }, + "node_modules/vite-plugin-dynamic-import": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/vite-plugin-dynamic-import/-/vite-plugin-dynamic-import-1.5.0.tgz", + "integrity": "sha512-Qp85c+AVJmLa8MLni74U4BDiWpUeFNx7NJqbGZyR2XJOU7mgW0cb7nwlAMucFyM4arEd92Nfxp4j44xPi6Fu7g==", + "dev": true, + "dependencies": { + "acorn": "^8.8.2", + "es-module-lexer": "^1.2.1", + "fast-glob": "^3.2.12", + "magic-string": "^0.30.1" + } + }, + "node_modules/vite-plugin-dynamic-import/node_modules/acorn": { + "version": "8.12.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", + "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/vite-plugin-dynamic-import/node_modules/es-module-lexer": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.5.4.tgz", + "integrity": "sha512-MVNK56NiMrOwitFB7cqDwq0CQutbw+0BvLshJSse0MUNU+y1FC3bUS/AQg7oUng+/wKrrki7JfmwtVHkVfPLlw==", + "dev": true + }, "node_modules/vite-plugin-eslint": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/vite-plugin-eslint/-/vite-plugin-eslint-1.8.1.tgz", diff --git a/package.json b/package.json index a6757c4..a906159 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,8 @@ "version": "0.0.1", "description": "DreamPip's Design System Component Library.", "type": "module", - "main": "dist/index.cjs.js", - "module": "dist/index.es.js", + "main": "dist/cjs/index.cjs", + "module": "dist/esm/index.es.js", "types": "dist/index.d.ts", "repository": "https://github.com/dreampipcom/oneiros", "files": [ @@ -15,8 +15,8 @@ "lint:icons": "eslint . --ext .ts,.tsx --ignore-path .gitignore --fix", "format": "prettier --write --parser typescript '**/*.{ts,tsx}' --ignore-path .ignoreicons", "lint": "eslint . --ext .ts,.tsx --ignore-path .ignoreicons --fix", - "build": "tsc -p tsconfig.json && cp ./tailwind.config.ts ./public/ && tsc -p tsconfig-dist.json && vite build", - "build:watch": "tsc -p tsconfig.json && cp ./tailwind.config.ts ./public/ && tsc -p tsconfig-dist.json && vite build --watch", + "build": "tsc -p tsconfig-cjs.json && cp ./tailwind.config.ts ./public/ && tsc -p tsconfig-dist.json && vite build --mode cjs && tsc -p tsconfig.json && vite build --emptyOutDir=false --mode es", + "build:watch": "tsc -p tsconfig.json && cp ./tailwind.config.ts ./public/ && tsc -p tsconfig-dist.json && vite build --watch --mode es", "test": "vitest run", "test-watch": "vitest", "test:ui": "vitest --ui", @@ -81,12 +81,12 @@ "jsdom": "24.0.0", "lodash": "4.17.21", "mapbox-gl": "^3.5.2", - "moment": "^2.30.1", "postcss": "8.4.38", "prettier": "3.2.5", "react-map-gl": "^7.1.7", "storybook": "^8.1.11", "vite": "5.2.9", + "vite-plugin-commonjs": "^0.10.1", "vite-plugin-dts": "3.8.3", "vite-plugin-eslint": "^1.8.1", "vite-tsconfig-paths": "4.3.2", @@ -95,6 +95,7 @@ "peerDependencies": { "clsx": "2.1.0", "lazysizes": "^5.3.2", + "moment": "^2.30.1", "react": "^18.2.0", "react-dom": "^18.2.0", "tailwindcss": "3.4.4", diff --git a/postcss.config.js b/postcss.config.mjs similarity index 100% rename from postcss.config.js rename to postcss.config.mjs diff --git a/src/atoms/12_DateRange/DateRange.tsx b/src/atoms/12_DateRange/DateRange.tsx index ee927a7..143bdab 100644 --- a/src/atoms/12_DateRange/DateRange.tsx +++ b/src/atoms/12_DateRange/DateRange.tsx @@ -70,18 +70,18 @@ export const HDateRange = function ({ md:[&_.base-Popper-root]:!top-a5 md:[&_.base-Popper-root]:!mt-0 - [&_.MuiPickersToolbarText-root.Mui-selected]:text-soft-light + [&_.MuiPickersToolbarText-root.Mui-selected]:text-primary-light dark:[&_.MuiPickersToolbarText-root.Mui-selected]:text-soft-light dark:!text-body-dark - [&_.MuiDateRangePickerDay-day.Mui-selected]:bg-soft-light - hover:[&_.MuiDateRangePickerDay-day.Mui-selected]:bg-soft-light - focus:[&_.MuiDateRangePickerDay-day.Mui-selected]:bg-soft-light + [&_.MuiDateRangePickerDay-day.Mui-selected]:bg-primary-light + hover:[&_.MuiDateRangePickerDay-day.Mui-selected]:bg-primary-light + focus:[&_.MuiDateRangePickerDay-day.Mui-selected]:bg-primary-light [&_.MuiButton-colorPrimary]:!text-secondary-light - [&_.MuiDateRangePickerDay-rangeIntervalDayHighlight]:!bg-soft-bg - hover:[&_.MuiDateRangePickerDay-day]:!bg-soft-light + [&_.MuiDateRangePickerDay-rangeIntervalDayHighlight]:!bg-secondary-light + hover:[&_.MuiDateRangePickerDay-day]:!bg-primary-light `]: true, }, ]; diff --git a/tsconfig-cjs.json b/tsconfig-cjs.json new file mode 100644 index 0000000..b4c0808 --- /dev/null +++ b/tsconfig-cjs.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "target": "ES5", + "useDefineForClassFields": true, + "lib": ["DOM", "DOM.Iterable"], + "module": "commonjs", + "skipLibCheck": true, + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "noEmit": true, + "esModuleInterop": true, + "jsx": "react-jsx", + "noUnusedLocals": false, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "declaration": true, + "outDir": "dist/cjs" + }, + "include": ["src"], + "exclude": [ + "src/**/__docs__","src/**/__test__", + ] +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 6241c35..1c34050 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,6 +16,7 @@ "noUnusedParameters": true, "noFallthroughCasesInSwitch": true, "declaration": true, + "outDir": "dist/esm" }, "include": ["src"], "exclude": [ diff --git a/vite.config.ts b/vite.config.ts index 9f7820e..70b461f 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,37 +1,92 @@ /// +import commonjs from 'vite-plugin-commonjs'; import eslint from 'vite-plugin-eslint'; import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; import dts from 'vite-plugin-dts'; import { peerDependencies } from './package.json'; -export default defineConfig((env) => ({ - build: { - lib: { - entry: './src/index.ts', - name: 'vite-react-ts-button', - fileName: (format) => `index.${format}.js`, - formats: ['cjs', 'es'], - }, - rollupOptions: { - external: [...Object.keys(peerDependencies), 'react/jsx-runtime'], - }, - sourcemap: true, - emptyOutDir: true, - }, - plugins: [ - dts({ - insertTypesEntry: true, - }), - react({ fastRefresh: false }), - env.mode !== 'test' && - eslint({ - exclude: ['/virtual:/**', 'node_modules/**', '/sb-preview/**'], - }), - ], - test: { - globals: true, - environment: 'jsdom', - setupFiles: './setupTests.ts', - }, -})); +export default defineConfig((env) => { + return env.mode != 'cjs' + ? { + // es-module + build: { + outDir: './dist/esm', + lib: { + entry: './src/index.ts', + name: 'oneiros-esm', + fileName: (format) => `index.es.js`, + formats: ['es'], + }, + rollupOptions: { + external: [ + ...Object.keys(peerDependencies), + 'react/jsx-runtime', + 'moment', + ], + }, + sourcemap: true, + emptyOutDir: false, + }, + plugins: [ + dts({ + insertTypesEntry: true, + tsconfigPath: './tsconfig.json', + }), + react({ fastRefresh: false }), + env.mode !== 'test' && + eslint({ + exclude: ['/virtual:/**', 'node_modules/**', '/sb-preview/**'], + }), + ], + test: { + globals: true, + environment: 'jsdom', + setupFiles: './setupTests.ts', + }, + } + : { + build: { + // cjs + outDir: './dist/cjs', + lib: { + entry: './src/index.ts', + name: 'oneiros-cjs', + fileName: (format) => `index.cjs`, + formats: ['cjs'], + }, + rollupOptions: { + external: [ + ...Object.keys(peerDependencies), + 'react/jsx-runtime', + 'moment', + ], + onwarn(warning, defaultHandler) { + if (warning.code === 'MODULE_LEVEL_DIRECTIVE') { + return; + } + defaultHandler(warning); + }, + }, + sourcemap: true, + emptyOutDir: false, + }, + plugins: [ + dts({ + insertTypesEntry: true, + tsconfigPath: './tsconfig-cjs.json', + }), + commonjs(), + // react({ fastRefresh: false }), + env.mode !== 'test' && + eslint({ + exclude: ['/virtual:/**', 'node_modules/**', '/sb-preview/**'], + }), + ], + test: { + globals: true, + environment: 'jsdom', + setupFiles: './setupTests.ts', + }, + }; +});