Skip to content

Commit

Permalink
updating index.ts and package.json for easy import when using as package
Browse files Browse the repository at this point in the history
  • Loading branch information
yoavweber committed Sep 6, 2024
1 parent 1728cb7 commit 829940d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 41 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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/**/*"
],
Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { WeeklyCalendar } from './WeeklyCalendar';
2 changes: 0 additions & 2 deletions src/index.tsx

This file was deleted.

43 changes: 15 additions & 28 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"]
}
19 changes: 11 additions & 8 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -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
},
});

0 comments on commit 829940d

Please sign in to comment.