diff --git a/package.json b/package.json index 7d6b5d3..d5dd291 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,10 @@ { "version": "1.1.1", "license": "MIT", - "main": "dist/index.js", + "main": "dist/antd-weekly-calendar.umd.js", + "module": "dist/antd-weekly-calendar.es.js", + "typings": "dist/types/index.d.ts", "description": "weekly calendar for antd", - "typings": "dist/index.d.ts", "files": [ "dist/**/*" ], @@ -39,7 +40,6 @@ }, "name": "antd-weekly-calendar", "author": "yoavweber", - "module": "dist/antd-weekly-calendar.esm.js", "size-limit": [ { "path": "dist/antd-weekly-calendar.cjs.production.min.js", diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..ee1562b --- /dev/null +++ b/src/index.ts @@ -0,0 +1 @@ +export { WeeklyCalendar } from './WeeklyCalendar'; diff --git a/src/index.tsx b/src/index.tsx deleted file mode 100644 index 68f88e2..0000000 --- a/src/index.tsx +++ /dev/null @@ -1,2 +0,0 @@ - -export * from './WeeklyCalendar' \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 2c85b2d..2bd9e1c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,35 +1,22 @@ { - // see https://www.typescriptlang.org/tsconfig to better understand tsconfigs - "include": ["src", "types"], "compilerOptions": { - "module": "esnext", - "lib": ["dom", "esnext"], - "importHelpers": true, - // output .d.ts declaration files for consumers "declaration": true, - // output .js.map sourcemap files for consumers - "sourceMap": true, - // match output dir to input dir. e.g. dist/index instead of dist/src/index - "rootDir": "./src", - // stricter type-checking for stronger correctness. Recommended by TS - "strict": true, - // linter checks for common issues - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - // noUnused* overlap with @typescript-eslint/no-unused-vars, can disable if duplicative - "noUnusedLocals": true, - "noUnusedParameters": true, - // use Node's module resolution algorithm, instead of the legacy TS one - "moduleResolution": "node", - // transpile JSX to React.createElement + "declarationDir": "./dist/types", + "emitDeclarationOnly": true, + "outDir": "./dist", + "module": "ESNext", + "target": "ESNext", "jsx": "react", - // interop between ESM and CJS modules. Recommended by TS "esModuleInterop": true, - // significant perf increase by skipping checking .d.ts files, particularly those in node_modules. Recommended by TS + "moduleResolution": "Node", "skipLibCheck": true, - // error out if import and file system have a casing mismatch. Recommended by TS - "forceConsistentCasingInFileNames": true, - // `tsdx build` ignores this option, but it is commonly used when type-checking separately with `tsc` - "noEmit": true, - } + "strict": true, + "sourceMap": true, + "baseUrl": ".", + "paths": { + "antd-weekly-calendar": ["./dist"] + } + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "dist"] } diff --git a/vite.config.ts b/vite.config.ts index f928789..9a91f7e 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,22 +1,25 @@ import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; +import path from 'path'; export default defineConfig({ plugins: [react()], build: { lib: { - entry: 'src/index.tsx', + entry: path.resolve(__dirname, 'src/index.ts'), // This is correct name: 'AntdWeeklyCalendar', - fileName: (format) => `antd-weekly-calendar.${format}.js` + fileName: (format) => `antd-weekly-calendar.${format}.js`, + formats: ['es', 'umd'], // Library output formats }, rollupOptions: { - external: ['react', 'react-dom'], + external: ['react', 'react-dom'], // Peer dependencies output: { globals: { react: 'React', - 'react-dom': 'ReactDOM' - } - } - } - } + 'react-dom': 'ReactDOM', + }, + }, + }, + emptyOutDir: false, // Prevent Vite from clearing the output directory + }, });