From e2d51ac41251cdb01cdd94318a8871b13496245d Mon Sep 17 00:00:00 2001 From: Addon Stack Date: Tue, 14 Oct 2025 17:41:43 +0300 Subject: [PATCH 1/4] chore: update .prettierignore to include CHANGELOG.md --- .prettierignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 From e9ada451902850c6ab31e322954bf6a42eb7540b Mon Sep 17 00:00:00 2001 From: Addon Stack Date: Tue, 14 Oct 2025 22:48:06 +0300 Subject: [PATCH 2/4] perf: enhance type declaration support and refactor build process - Updated `types` field in `package.json` to point to generated type declarations. - Modified `exports` to include type declarations for components (`config`, `plugin`, etc.). - Added `tsconfig.build.json` to generate declaration files in the `dist-types` directory. - Added `prepublishOnly` script to automate type generation during publishing. - Updated `.gitignore` and ESLint configuration to include `dist-types`. - Introduced type definitions for `odometer` and `addon-ui-config` modules. --- .gitignore | 1 + eslint.config.js | 1 + package.json | 50 ++++++++++++++++------------ src/types/shims/addon-ui-config.d.ts | 5 +++ src/types/vendors/odometer.d.ts | 17 ++++++++++ tsconfig.build.json | 21 ++++++++++++ 6 files changed, 73 insertions(+), 22 deletions(-) create mode 100644 src/types/shims/addon-ui-config.d.ts create mode 100644 src/types/vendors/odometer.d.ts create mode 100644 tsconfig.build.json 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/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..94f7319 100644 --- a/package.json +++ b/package.json @@ -27,41 +27,47 @@ "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/**/*.ts", + "src/**/*.tsx", + "src/**/*.scss", + "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": { "autosize": "^6.0.1", @@ -70,7 +76,9 @@ "radix-ui": "^1.1.3", "react-highlight-words": "^0.21.0", "sass": "^1.85.1", - "ts-deepmerge": "^7.0.3" + "ts-deepmerge": "^7.0.3", + "@types/autosize": "^4.0.3", + "@types/react-highlight-words": "^0.20.0" }, "devDependencies": { "@commitlint/cli": "^20.0.0", @@ -81,11 +89,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" + ] +} From d902232d91eb716420f1ed249b798755258db5c2 Mon Sep 17 00:00:00 2001 From: Addon Stack Date: Tue, 14 Oct 2025 22:57:09 +0300 Subject: [PATCH 3/4] chore: remove `.npmignore` and update `package.json` file patterns --- .npmignore | 66 ---------------------------------------------------- package.json | 18 +++++++++----- 2 files changed, 12 insertions(+), 72 deletions(-) delete mode 100644 .npmignore 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/package.json b/package.json index 94f7319..2406cf1 100644 --- a/package.json +++ b/package.json @@ -48,9 +48,15 @@ "*.scss" ], "files": [ - "src/**/*.ts", - "src/**/*.tsx", - "src/**/*.scss", + "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" @@ -70,15 +76,15 @@ "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", "radix-ui": "^1.1.3", "react-highlight-words": "^0.21.0", "sass": "^1.85.1", - "ts-deepmerge": "^7.0.3", - "@types/autosize": "^4.0.3", - "@types/react-highlight-words": "^0.20.0" + "ts-deepmerge": "^7.0.3" }, "devDependencies": { "@commitlint/cli": "^20.0.0", From 186eab3b97430cc6ca979ec5585fef63f8bcf682 Mon Sep 17 00:00:00 2001 From: Addon Stack Date: Tue, 14 Oct 2025 23:00:10 +0300 Subject: [PATCH 4/4] ci: update build and CI scripts to include type generation - Updated `.husky/pre-push` to replace commented-out commands with `npm run build:types`. - Modified GitHub Actions workflow to add a step for running `npm run build:types` during CI. --- .github/workflows/ci.yml | 3 +++ .husky/pre-push | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) 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/.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