Skip to content

Commit

Permalink
chore: 🤖 use tsc build
Browse files Browse the repository at this point in the history
  • Loading branch information
ianzone committed Nov 24, 2024
1 parent 74d3519 commit bd4dd4e
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 535 deletions.
8 changes: 4 additions & 4 deletions lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pre-commit:
glob: "*.{ts,tsx,js,jsx,json,jsonc,css}"
run: na biome check --fix {staged_files} --reporter summary
stage_fixed: true
# test:
# priority: 5
# glob: "*.{ts,tsx,js,jsx}"
# run: na vitest related --run {staged_files}
test:
priority: 5
glob: "*.{ts,tsx,js,jsx}"
run: na vitest related --run {staged_files}
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "antd-enhanced",
"version": "0.0.0",
"description": "Useful components for Ant Design",
"description": "Useful components based on Ant Design",
"type": "module",
"files": ["dist"],
"exports": "./dist/index.js",
Expand All @@ -13,9 +13,9 @@
},
"scripts": {
"lint": "biome check --fix src --reporter summary",
"build": "tsc && vite build",
"build": "tsc --project tsconfig.build.json",
"dev": "storybook dev -p 6006",
"clear": "rm ./node_modules/.cache -r",
"dev:cc": "rm ./node_modules/.cache -r && nr dev",
"build-storybook": "storybook build",
"postinstall": "lefthook install",
"commit": "git add -A && git-cz",
Expand Down Expand Up @@ -55,7 +55,6 @@
"storybook": "^8.4.5",
"typescript": "^5.7.2",
"vite": "^5.4.11",
"vite-plugin-dts": "^4.3.0",
"vite-plugin-svgr": "^4.3.0",
"vitest": "^2.1.5"
},
Expand Down
513 changes: 21 additions & 492 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Space } from 'antd';
import { CountryFlag } from 'src/components';
import { CountryFlag } from '../../../';
import { useInputIntlPhoneContext } from '../InputIntlPhoneContext';
import type { OptionRender } from './types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function CountrySelector() {
customRegions,
} = useInputIntlPhoneContext();

const onSelect: OnSelect = (value, option) => {
const onSelect: OnSelect = (value) => {
setPhone({ countryCode: value });
setIsCountrySelectorOpen(false);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CountryFlag } from 'src/components';
import { CountryFlag } from '../../../';
import { useInputIntlPhoneContext } from '../InputIntlPhoneContext';

export function FlagAddon() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { Meta, StoryObj } from '@storybook/react';
import { InputIntlPhone } from './InputIntlPhone';

const meta = {
const meta: Meta<typeof InputIntlPhone> = {
title: 'Inputs/InputIntlPhone',
component: InputIntlPhone,
parameters: {
layout: 'centered',
},
tags: ['autodocs'],
} satisfies Meta<typeof InputIntlPhone>;
};

export default meta;
type Story = StoryObj<typeof meta>;
Expand Down
4 changes: 2 additions & 2 deletions src/components/inputs/InputPhone/InputPhone.stories.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { Meta, StoryObj } from '@storybook/react';
import { InputPhone } from './InputPhone';

const meta = {
const meta: Meta<typeof InputPhone> = {
title: 'Inputs/InputPhone',
component: InputPhone,
parameters: {
layout: 'centered',
},
tags: ['autodocs'],
} satisfies Meta<typeof InputPhone>;
};

export default meta;
type Story = StoryObj<typeof meta>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Dropdown, type GetProp, type MenuProps } from 'antd';
import { AiFillMoon, AiFillSun, AiOutlineLaptop } from 'react-icons/ai';
import { LuSunMoon } from 'react-icons/lu';
import type { ThemeMode } from 'src/hooks';
import type { ThemeMode } from '../../../hooks';

type Props = {
onSelect: (themeMode: ThemeMode) => void;
Expand Down
33 changes: 33 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// https://github.com/vitejs/vite/blob/main/packages/create-vite/template-react-ts/tsconfig.app.json
{
"compilerOptions": {
/* 解析 */
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"module": "ESNext",
"moduleDetection": "force",
/* 输出 */
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"sourceMap": true,
"declaration": true, // 自动生成声明文件
"outDir": "dist", // 输出目录
"jsx": "react-jsx",
/* 检查 */
"skipLibCheck": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
/* Custom */
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": "."
},
"include": ["src"],
"exclude": ["**/*.test.*", "**/*.spec.*", "**/*.mdx", "**/*.stories.*"],
"tsc-alias": { "verbose": true }
}
48 changes: 21 additions & 27 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,28 @@
import { resolve } from 'node:path';
import react from '@vitejs/plugin-react-swc';
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts'; // https://github.com/qmhc/vite-plugin-dts/blob/main/README.zh-CN.md
import svgr from 'vite-plugin-svgr'; // https://github.com/pd4d10/vite-plugin-svgr

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), svgr(), dts({ rollupTypes: true, tsconfigPath: './tsconfig.app.json' })],
resolve: {
alias: {
src: resolve(__dirname, 'src'),
},
},
build: {
lib: {
// https://vite.dev/config/build-options.html#build-lib
entry: resolve(__dirname, 'src/index.ts'),
name: 'AntdEnhanced',
fileName: 'index',
formats: ['es'],
},
rollupOptions: {
external: ['react', 'react-dom', 'antd'],
output: {
globals: {
react: 'React',
'react-dom': 'react-dom',
antd: 'antd',
},
},
},
},
plugins: [react(), svgr()],
// NOTE: do not use alias https://github.com/microsoft/TypeScript/issues/30952
// build: { https://github.com/vitejs/vite/discussions/18744
// lib: {
// // https://vite.dev/config/build-options.html#build-lib
// entry: resolve(__dirname, 'src/index.ts'),
// name: 'AntdEnhanced',
// fileName: 'index',
// formats: ['es'],
// },
// rollupOptions: {
// external: ['react', 'react-dom', 'antd'],
// output: {
// globals: {
// react: 'React',
// 'react-dom': 'react-dom',
// antd: 'antd',
// },
// },
// },
// },
});

0 comments on commit bd4dd4e

Please sign in to comment.