diff --git a/.npmignore b/.npmignore index 5a50141..0fd6622 100644 --- a/.npmignore +++ b/.npmignore @@ -1,6 +1,4 @@ -src -tests -.gitignore -.npmignore -tsconfig.json -rollup.config.js \ No newline at end of file +# Exclude unnecessary files +src/ +node_modules/ +test/ diff --git a/package-lock.json b/package-lock.json index 04955cf..dd96b98 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "zust", - "version": "0.2.0", + "version": "0.2.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "zust", - "version": "0.2.0", + "version": "0.2.1", "license": "MIT", "dependencies": { "zustand": "^4.5.5" @@ -14,6 +14,7 @@ "devDependencies": { "@jest/globals": "^29.7.0", "@rollup/plugin-commonjs": "^28.0.0", + "@rollup/plugin-json": "^6.1.0", "@rollup/plugin-node-resolve": "^15.3.0", "@testing-library/jest-dom": "^6.5.0", "@testing-library/react": "16.0.1", @@ -1111,6 +1112,27 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/@rollup/plugin-json": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-6.1.0.tgz", + "integrity": "sha512-EGI2te5ENk1coGeADSIwZ7G2Q8CJS2sF120T7jLw4xFw9n7wIOXHo+kIYRAoVpJAN+kmqZSoO3Fp4JtoNF4ReA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^5.1.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, "node_modules/@rollup/plugin-node-resolve": { "version": "15.3.0", "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.3.0.tgz", diff --git a/package.json b/package.json index e0d289d..c4a4018 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zust", - "version": "0.2.1", + "version": "0.2.2", "description": "A powerful state manager based on Zustand", "type": "module", "main": "dist/index.cjs.js", @@ -12,7 +12,6 @@ "LICENSE" ], "scripts": { - "dev": "rollup -c -w", "build": "rollup -c", "test": "jest", "prepublishOnly": "npm run build" @@ -30,6 +29,7 @@ "devDependencies": { "@jest/globals": "^29.7.0", "@rollup/plugin-commonjs": "^28.0.0", + "@rollup/plugin-json": "^6.1.0", "@rollup/plugin-node-resolve": "^15.3.0", "@testing-library/jest-dom": "^6.5.0", "@testing-library/react": "16.0.1", diff --git a/rollup.config.js b/rollup.config.js index 488aa16..c0ed63d 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,7 +1,9 @@ +// rollup.config.js import peerDepsExternal from "rollup-plugin-peer-deps-external"; import resolve from "@rollup/plugin-node-resolve"; import commonjs from "@rollup/plugin-commonjs"; import typescript from "rollup-plugin-typescript2"; +import json from "@rollup/plugin-json"; // Import the plugin export default { input: "src/index.ts", @@ -20,11 +22,9 @@ export default { external: ["react", "react-dom", "zustand"], plugins: [ peerDepsExternal(), - typescript({ - tsconfig: "tsconfig.build.json", - useTsconfigDeclarationDir: true, - }), resolve(), commonjs(), + typescript({ useTsconfigDeclarationDir: true }), + json(), // Add the plugin to the plugins array ], }; diff --git a/tests/integration.test.tsx b/tests/integration.test.tsx index 7bdf485..a146e7d 100644 --- a/tests/integration.test.tsx +++ b/tests/integration.test.tsx @@ -1,7 +1,6 @@ // test/integration.test.ts import { render, act } from "@testing-library/react"; import "@testing-library/jest-dom"; - import { createStore } from "../src/index"; describe("Zust Integration", () => { @@ -31,7 +30,6 @@ describe("Zust Integration", () => { test("state updates trigger re-renders", () => { const { useSelectors, setDeep } = createStore({ counter: 0 }); - let renderCount = 0; function TestComponent() { const { counter } = useSelectors("counter"); diff --git a/tsconfig.json b/tsconfig.json index c80320f..cf4fdd9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,23 +4,24 @@ "module": "ESNext", "lib": ["ES2020", "DOM"], "moduleResolution": "node", - "rootDir": ".", + "rootDir": "src", + "declaration": true, + "declarationDir": "dist/types", + "emitDeclarationOnly": false, "strict": true, "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true, + "sourceMap": true, "jsx": "react-jsx", + "resolveJsonModule": true, + "allowSyntheticDefaultImports": true, + "noImplicitAny": true, "noUnusedLocals": true, "noUnusedParameters": true, "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - "allowSyntheticDefaultImports": true, - "resolveJsonModule": true, - "types": ["jest", "node"], - "declaration": true, - "declarationMap": true, - "emitDeclarationOnly": false, + "noFallthroughCasesInSwitch": true }, - "include": ["src/**/*", "tests/**/*"], - "exclude": ["node_modules", "dist"] + "include": ["src/**/*"], + "exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.test.tsx"] }