Skip to content

Commit

Permalink
feat: package now has /cjs, /esm, /esnext distibuted versions
Browse files Browse the repository at this point in the history
  • Loading branch information
xobotyi committed Apr 23, 2021
1 parent 9c41dd1 commit 4911c9d
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 37 deletions.
Binary file modified .github/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/.idea
node_modules
/coverage
/dist
/storybook-build
/cjs
/esm
/esnext
/types
5 changes: 4 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
*
!/dist
!/cjs
!/esm
!/esnext
!/types
44 changes: 18 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
<div align="center">
<h1><img src=".github/logo.png" alt="@react-hookz/web"></h1>
<p>
<a href="https://www.npmjs.com/package/@react-hookz/web">
<img src="https://flat.badgen.net/npm/v/@react-hookz/web" alt="NPM Version">
</a>
<a href="https://www.npmjs.com/package/@react-hookz/web">
<img src="https://flat.badgen.net/npm/dm/@react-hookz/web" alt="NPM Downloads">
</a>
<a href="https://www.npmjs.com/package/@react-hookz/web">
<img src="https://flat.badgen.net/npm/dependents/@react-hookz/web" alt="NPM Dependents">
</a>
<a href="https://github.com/react-hookz/web/actions">
<img src="https://img.shields.io/github/workflow/status/react-hookz/web/CI?style=flat-square" alt="Build">
</a>
<a href="https://app.codecov.io/gh/react-hookz/web">
<img src="https://flat.badgen.net/codecov/c/github/react-hookz/web" alt="Coverage">
</a>
<a href="https://bundlephobia.com/result?p=@react-hookz/web">
<img src="https://flat.badgen.net/bundlephobia/minzip/@react-hookz/web" alt="Minified bundle size">
</a>
<a href="https://bundlephobia.com/result?p=@react-hookz/web">
<img src="https://flat.badgen.net/bundlephobia/tree-shaking/@react-hookz/web" alt="Tree shaking">
</a>
</p>
</div>
# ![@react-hookz/web](.github/logo.png)

React hooks done right, for browser and SSR.

[![NPM Version](https://flat.badgen.net/npm/v/@react-hookz/web)](https://www.npmjs.com/package/@react-hookz/web)
[![NPM Downloads](https://flat.badgen.net/npm/dm/@react-hookz/web)](https://www.npmjs.com/package/@react-hookz/web)
[![NPM Dependents](https://flat.badgen.net/npm/dependents/@react-hookz/web)](https://www.npmjs.com/package/@react-hookz/web)
[![Build](https://img.shields.io/github/workflow/status/react-hookz/web/CI?style=flat-square)](https://github.com/react-hookz/web/actions)
[![Coverage](https://flat.badgen.net/codecov/c/github/react-hookz/web)](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)
Expand Down
26 changes: 20 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand Down
4 changes: 1 addition & 3 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
"src/**/*.ts"
],
"compilerOptions": {
"outDir": "./dist",
"declaration": true,
"sourceMap": true,
"outDir": "./cjs",
"target": "ES5",
"module": "CommonJS",
"moduleResolution": "Node"
Expand Down

0 comments on commit 4911c9d

Please sign in to comment.