diff --git a/.github/logo.png b/.github/logo.png index 0bec9a296..161f006b5 100644 Binary files a/.github/logo.png and b/.github/logo.png differ diff --git a/.gitignore b/.gitignore index 02e63c913..7634d7804 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ /.idea node_modules /coverage -/dist /storybook-build +/cjs +/esm +/esnext +/types diff --git a/.npmignore b/.npmignore index 5b2b93e1c..65b072740 100644 --- a/.npmignore +++ b/.npmignore @@ -1,2 +1,5 @@ * -!/dist +!/cjs +!/esm +!/esnext +!/types diff --git a/README.md b/README.md index d479aaf6a..30f83bf66 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,21 @@ -
+#  + +React hooks done right, for browser and SSR. + +[](https://www.npmjs.com/package/@react-hookz/web) +[](https://www.npmjs.com/package/@react-hookz/web) +[](https://www.npmjs.com/package/@react-hookz/web) +[](https://github.com/react-hookz/web/actions) +[](https://app.codecov.io/gh/react-hookz/web) + +`@react-hookz/web` is a library of general-purpose React hooks built with care and SSR compatibility +in mind. + +This package provides three levels of compilation: + +1. **Main**, the `/cjs` folder — CommonJS modules, with ES5 lang level. +2. **ESM**, the `/esm` folder — it is ES modules, with ES5 lang level. +3. **ESNext**, the `/esnext` folder — it is ES modules, with ESNext lang level. - #### Lifecycle hooks - [`useFirstMountState`](https://react-hookz.github.io/web/?path=/docs/lifecycle-usefirstmountstate) diff --git a/package.json b/package.json index d0610ec40..28cfd5c6d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,14 @@ { "name": "@react-hookz/web", "version": "1.6.2", + "description": "React hooks done right, for browser and SSR.", + "keywords": [ + "react", + "hook", + "react-hook", + "browser", + "ssr" + ], "license": "MIT", "repository": { "type": "git", @@ -13,14 +21,20 @@ "access": "public" }, "files": [ - "dist" + "cjs", + "esm", + "esnext", + "types" ], - "main": "dist/index.js", - "types": "dist/index.d.ts", + "main": "cjs/index.js", + "types": "types/index.d.ts", + "esnext": "esm/index.js", "scripts": { - "build": "yarn build:cleanup && yarn build:tsc", - "build:cleanup": "rimraf ./dist", - "build:tsc": "tsc -p ./tsconfig.build.json", + "build": "yarn build:cleanup && yarn build:cjs && yarn build:esm && yarn build:esnext", + "build:cleanup": "rimraf ./cjs ./esm ./esnext ./types", + "build:cjs": "tsc -p ./tsconfig.build.json --module CommonJS --target ES5 --outDir ./cjs", + "build:esm": "tsc -p ./tsconfig.build.json --module ES6 --target ES5 --outDir ./esm", + "build:esnext": "tsc -p ./tsconfig.build.json --module ESNext --target ESNext --outDir ./esnext --declaration --declarationDir ./types", "test": "jest", "test:coverage": "yarn test --coverage", "lint": "eslint ./ ./.storybook --ext ts,js,tsx,jsx,md,mdx", diff --git a/tsconfig.build.json b/tsconfig.build.json index b535b7693..7671bef7b 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -5,9 +5,7 @@ "src/**/*.ts" ], "compilerOptions": { - "outDir": "./dist", - "declaration": true, - "sourceMap": true, + "outDir": "./cjs", "target": "ES5", "module": "CommonJS", "moduleResolution": "Node"