Skip to content

Commit 934b0be

Browse files
committed
docs (build): add docs about the alternative builds
1 parent e928a3d commit 934b0be

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- [Platform support](#platform-support)
1313
- [Performance](#performance)
1414
- [State management overview](#state-management-overview)
15+
- [Alternative builds](#alternative-builds)
1516
- [How does it work?](#how-does-it-work)
1617
- [Contributing](#contributing)
1718
- [The NX Framework](#the-nx-framework)
@@ -202,6 +203,15 @@ Application pages deserve a special mention. A typical app has several pages but
202203

203204
Page state usually has properties, which belong in the URL and browser history. In this case it is inherently global and it should be handled in a global store. These stores persist between page transitions, but this is perfectly fine. As a bonus you get a faster transition, because you don't always have to re-fetch all of the data. If you do not want data to linger around clean up the relevant parts in `componentWillUnmount`.
204205

206+
## Alternative builds
207+
208+
By default Easy State detects if you use ES6 or commonJS modules and serve the right format to you. The exposed libraries are transpiled to ES5 to support common tools - like UglifyJS minifying. If you would like a finer control over the provided build, you can specify them in your imports.
209+
210+
- `react-easy-state/dist/esm.es6` exposes an ES6 build with ES6 modules.
211+
- `react-easy-state/dist/esm.es5` exposes an ES5 build with ES6 modules.
212+
- `react-easy-state/dist/cjs.es6` exposes an ES6 build with commonJS modules.
213+
- `react-easy-state/dist/cjs.es5` exposes an ES5 build with commonJS modules.
214+
205215
## How does it work?
206216

207217
Under the hood Easy State uses the [@nx-js/observer-util](https://github.com/nx-js/observer-util) library, which relies on ES6 Proxies to observe state changes. Thanks to the Proxies it doesn't have edge cases or limitations. You can write any JS code without worrying about the render function. [This blog post](https://blog.risingstack.com/writing-a-javascript-framework-data-binding-es6-proxy/) gives a little sneak peek under the hood of the `observer-util`.

__mocks__/react-easy-state.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// use this to test the raw src folder
22
export * from '../src'
33

4-
// use this to test the es6 modules build
5-
// export * from '../dist/easyState.es'
6-
7-
// use to test the commonJS build
8-
// export * from '../dist/easyState.cjs'
4+
// use this to test other builds
5+
// export * from '../dist/{module_format}{es_version}'

0 commit comments

Comments
 (0)