diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 958f06c..748ee73 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,6 +72,9 @@ jobs: - name: Test run: npm run test:ci + - name: Build Types + run: npm run build:types + - name: Upload coverage artifact if: always() uses: actions/upload-artifact@v4 diff --git a/.gitignore b/.gitignore index 6175c50..e66e0ee 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ lerna-debug.log* node_modules dist +dist-types addon .adnbn dist-ssr diff --git a/.husky/pre-push b/.husky/pre-push index edf3235..5fbd476 100644 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -4,5 +4,4 @@ npm run typecheck || exit 1 npm run lint || exit 1 -#npm run test:ci || exit 1 -#npm run build || exit 1 +npm run build:types || exit 1 diff --git a/.npmignore b/.npmignore deleted file mode 100644 index f5dbbd6..0000000 --- a/.npmignore +++ /dev/null @@ -1,66 +0,0 @@ -# Storybook files -.storybook/ -storybook-static/ -**/*.stories.tsx -**/*.stories.mdx - -# Development files -tests/ -__tests__/ -test/ -**/*.test.js -**/*.spec.js -**/*.test.ts -**/*.spec.ts -**/*.test.tsx -**/*.spec.tsx - -# Configuration files -.eslintrc -.prettierrc -.prettierignore -.commitlintrc.json -.gitattributes -.release-it.cjs -.mailmap -.github/ -.vscode/ -.idea/ -.husky -eslint.config.js - -# Build tools -webpack.config.js -rollup.config.js -tsconfig.json - -# Documentation -docs/ -examples/ -*.md -!README.md - -# Other -.DS_Store -node_modules/ -coverage/ -.env - -# Logs -logs/ -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* -lerna-debug.log* -*storybook.log - -# Build -dist/ -dist-ssr/ -*.local - -# Project specific -addon/ -.adnbn/ diff --git a/.prettierignore b/.prettierignore index 272aca5..faedb36 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,4 +1,5 @@ node_modules/ dist/ build/ -.github/workflows/*.yml \ No newline at end of file +.github/workflows/*.yml +CHANGELOG.md \ No newline at end of file diff --git a/eslint.config.js b/eslint.config.js index 36e57aa..25dc6ec 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -10,6 +10,7 @@ export default tseslint.config( { ignores: [ "dist", + "dist-types", "addon", ".adnbn", "build", diff --git a/package.json b/package.json index 28256cb..2406cf1 100644 --- a/package.json +++ b/package.json @@ -27,43 +27,57 @@ "bugs": { "url": "https://github.com/addon-stack/addon-ui/issues" }, - "types": "./src/index.ts", - "typesVersions": { - "*": { - ".": [ - "./src/index.ts" - ], - "config": [ - "./src/config/index.ts" - ], - "plugin": [ - "./src/plugin/index.ts" - ] - } - }, + "types": "./dist-types/index.d.ts", "exports": { - ".": "./src/index.ts", - "./config": "./src/config/index.ts", - "./plugin": "./src/plugin/index.ts", + ".": { + "types": "./dist-types/index.d.ts", + "default": "./src/index.ts" + }, + "./config": { + "types": "./dist-types/config/index.d.ts", + "default": "./src/config/index.ts" + }, + "./plugin": { + "types": "./dist-types/plugin/index.d.ts", + "default": "./src/plugin/index.ts" + }, "./theme": "./src/styles/mixins.scss" }, "sideEffects": [ "*.css", "*.scss" ], + "files": [ + "src", + "!src/**/*.stories.*", + "!src/**/*.story.*", + "!src/**/*.mdx", + "!src/**/__stories__/**", + "!src/**/*.test.*", + "!src/**/*.spec.*", + "!src/**/__tests__/**", + "!src/**/__mocks__/**", + "dist-types/**/*.d.ts", + "README.md", + "LICENSE.md" + ], "scripts": { "lint": "eslint .", "format": "prettier --write .", "storybook": "storybook dev -p 6006", - "build-storybook": "storybook build", + "build:storybook": "storybook build", "test": "jest", "test:ci": "jest --ci --passWithNoTests --coverage", "test:related": "jest --bail --passWithNoTests", "typecheck": "tsc -p tsconfig.json --noEmit", + "build:types": "tsc -p tsconfig.build.json", "release": "release-it", - "release:preview": "release-it --no-github.release --no-npm.publish --no-git.tag --ci" + "release:preview": "release-it --no-github.release --no-npm.publish --no-git.tag --ci", + "prepublishOnly": "npm run build:types" }, "dependencies": { + "@types/autosize": "^4.0.3", + "@types/react-highlight-words": "^0.20.0", "autosize": "^6.0.1", "classnames": "^2.5.1", "odometer": "^0.4.8", @@ -81,11 +95,9 @@ "@eslint/js": "^9.21.0", "@rsbuild/plugin-sass": "^1.4.0", "@storybook/react": "^9.1.3", - "@types/autosize": "^4.0.3", "@types/node": "^22.13.10", "@types/react": "^19.0.10", "@types/react-dom": "^19.0.4", - "@types/react-highlight-words": "^0.20.0", "adnbn": "^0.4.2", "depcheck": "^1.4.7", "eslint": "^9.21.0", diff --git a/src/types/shims/addon-ui-config.d.ts b/src/types/shims/addon-ui-config.d.ts new file mode 100644 index 0000000..8ff3e62 --- /dev/null +++ b/src/types/shims/addon-ui-config.d.ts @@ -0,0 +1,5 @@ +declare module "addon-ui-config" { + import type {Config} from "../config"; + const config: Config; + export default config; +} diff --git a/src/types/vendors/odometer.d.ts b/src/types/vendors/odometer.d.ts new file mode 100644 index 0000000..22ed9b5 --- /dev/null +++ b/src/types/vendors/odometer.d.ts @@ -0,0 +1,17 @@ +declare module "odometer" { + interface OdometerOptions { + el: Element; + value?: number; + format?: string; + theme?: string; + duration?: number; + } + + export default class Odometer { + constructor(options: OdometerOptions); + + value: number; + + update(newValue: number): void; + } +} diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 0000000..3a05567 --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,21 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "declaration": true, + "declarationMap": true, + "emitDeclarationOnly": true, + "outDir": "dist-types", + "composite": false, + "noEmit": false, + "checkJs": false + }, + "include": ["src"], + "exclude": [ + "**/*.test.ts", + "**/*.test.tsx", + "**/*.stories.*", + "tests", + "dist", + "dist-types" + ] +}