Skip to content

Commit

Permalink
feat: replace esmodules with esnext verson
Browse files Browse the repository at this point in the history
BREAKING CHANGE: remove esnext version, now esmodules serves es esnext
version.
  • Loading branch information
xobotyi committed Oct 23, 2022
1 parent ee8c352 commit 57d51f5
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 27 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module.exports = {
'storybook-build',
'cjs',
'esm',
'esnext',
'.github/workflows',
'.husky',
'CHANGELOG.md',
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ node_modules
/storybook-build
/cjs
/esm
/esnext
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
*
!/cjs
!/esm
!/esnext
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -773,13 +773,13 @@ SSR remains untouched, but requires implicit setting of

### Features

* package now has /cjs, /esm, /esnext distibuted versions ([4911c9d](https://github.com/react-hookz/web/commit/4911c9d3c0813bff5e52ae98cfc4dfc542996a0b))
* package now has /cjs, /esm distibuted versions ([4911c9d](https://github.com/react-hookz/web/commit/4911c9d3c0813bff5e52ae98cfc4dfc542996a0b))

# [1.7.0](https://github.com/react-hookz/web/compare/v1.6.2...v1.7.0) (2021-04-23)

### Features

* package now has /cjs, /esm, /esnext distibuted versions ([4911c9d](https://github.com/react-hookz/web/commit/4911c9d3c0813bff5e52ae98cfc4dfc542996a0b))
* package now has /cjs, /esm distibuted versions ([4911c9d](https://github.com/react-hookz/web/commit/4911c9d3c0813bff5e52ae98cfc4dfc542996a0b))

## [1.6.2](https://github.com/react-hookz/web/compare/v1.6.1...v1.6.2) (2021-04-22)

Expand Down
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,21 @@ transpile your `node-modules` in order to run in IE.

## Usage

This package provides three levels of compilation:
This package provides two levels of compilation:

1. **Main**, the `/cjs` folder — CommonJS modules, with ES6 lang level.
2. **ESM**, the `/esm` folder — it is ES modules (browser compatible), with ES6 lang level.
3. **ESNext**, the `/esnext` folder — it is ES modules (browser compatible), with ESNext lang level.
2. **ESM**, the `/esm` folder — it is ES modules (browser compatible), with ESNext lang level.

So, if you need the `useMountEffect` hook, depending on your needs, you can import in three ways
(there are actually more, but these are the three most common):
So, if you need the `useMountEffect` hook, depending on your needs, you can import in two ways
(there are actually more, but these are the two most common).
But keep in mid that in case you using latest versions of webpack, vite, etc., most likely, you'll
have to transpile your `node_modules`.

```ts
// in case you need cjs modules
import { useMountEffect } from '@react-hookz/web';
// in case you need esm modules
import { useMountEffect } from '@react-hookz/web/esm';
// in case you want all the recent ES features
import { useMountEffect } from '@react-hookz/web/esnext';
import { useMountEffect } from '@react-hookz/web/esm';
```

## Migrating from react-use
Expand Down
11 changes: 4 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,19 @@
},
"files": [
"cjs",
"esm",
"esnext"
"esm"
],
"main": "cjs/index.js",
"esnext": "esnext/index.js",
"types": "cjs/index.d.ts",
"module": "esm/index.js",
"sideEffects": false,
"scripts": {
"prepare": "husky install",
"commit": "git-cz",
"build": "yarn build:cleanup && concurrently yarn:build:cjs yarn:build:esm yarn:build:esnext --kill-others-on-fail",
"build:cleanup": "rimraf ./cjs ./esm ./esnext ./types",
"build": "yarn build:cleanup && concurrently yarn:build:cjs yarn:build:esm --kill-others-on-fail",
"build:cleanup": "rimraf ./cjs ./esm ./types",
"build:cjs": "ttsc -p ./tsconfig.build.json --module CommonJS --target ES6 --outDir ./cjs",
"build:esm": "ttsc -p ./tsconfig.build.json --module ES6 --target ES6 --outDir ./esm",
"build:esnext": "ttsc -p ./tsconfig.build.json --module ESNext --target ESNext --outDir ./esnext",
"build:esm": "ttsc -p ./tsconfig.build.json --module ESNext --target ESNext --outDir ./esm",
"new-hook": "node ./utility/add-new-hook.js",
"test": "jest --selectProjects dom ssr",
"test:coverage": "yarn test --coverage",
Expand Down
1 change: 0 additions & 1 deletion src/__docs__/ImportPath.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const ImportPath: FC = () => {
const path = `
import { ${componentName} } from '@react-hookz/web'; // cjs
import { ${componentName} } from '@react-hookz/web/esm'; // esm
import { ${componentName} } from '@react-hookz/web/esnext' // esnext
`;

return <Source language="js" code={path} />;
Expand Down
5 changes: 1 addition & 4 deletions src/__docs__/Introduction.story.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,13 @@ This package provides three levels of compilation:

1. **Main**, the `/cjs` folder — CommonJS modules, with ES6 lang level.
2. **ESM**, the `/esm` folder — it is ES modules (browser compatible), with ES6 lang level.
3. **ESNext**, the `/esnext` folder — it is ES modules (browser compatible), with ESNext lang level.

So, if you need the `useMountEffect` hook, depending on your needs, you can import in three ways
(there are actually more, but these are the three most common):

```ts
// in case you need cjs modules
import { useMountEffect } from '@react-hookz/web';
// in case you need esm modules
// in case you need esm modules and latest ES features
import { useMountEffect } from '@react-hookz/web/esm';
// in case you want all the recent ES features
import { useMountEffect } from '@react-hookz/web/esnext';
```
1 change: 0 additions & 1 deletion src/useCookieValue/__docs__/story.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export function useCookieValue(key: string, options: UseCookieOptions = {}): Use
code={`
import { useCookieValue } from '@react-hookz/web/cjs/useCookieValue/useCookieValue'; // cjs
import { useCookieValue } from '@react-hookz/web/esm/useCookieValue/useCookieValue'; // esm
import { useCookieValue } from '@react-hookz/web/esnext/useCookieValue/useCookieValue' // esnext
`}
/>

Expand Down
1 change: 0 additions & 1 deletion tsconfig.eslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"./cjs",
"./coverage",
"./esm",
"./esnext",
"./node_modules"
],
"include": [
Expand Down

0 comments on commit 57d51f5

Please sign in to comment.