Skip to content

Commit

Permalink
Merge pull request #11 from KevinAst/next3
Browse files Browse the repository at this point in the history
publish: v0.1.3 Establish Polyfill Strategy
  • Loading branch information
KevinAst authored Jul 2, 2018
2 parents 095b451 + 79a8d46 commit 50959a3
Show file tree
Hide file tree
Showing 7 changed files with 9,370 additions and 32 deletions.
34 changes: 22 additions & 12 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
{
"presets": ["es2015", "stage-1", "react"],
"env": {
"commonjs": {
"plugins": [
["transform-es2015-modules-commonjs", { "loose": true }]
// standard presets applying various plugins
presets: [
"env", // babel-preset-env: supporting es2015, es2016, and es2017 (with configuration)
"react" // babel-preset-react: react and jsx
],

// explicit plugins NOT part of the presets (above) ... prefer this over yearly presets
plugins: [
"transform-object-rest-spread", // "object rest properties" (es2018 Stage 4)
// ... ex: myFn({p1, p2, ...restParms})
],

// additional plugins explicitly called out via the BABEL_ENV variable
// ... see: build scripts in package.json
env: {
// BABEL_ENV=commonjs ... our CommonJS distribution (promoted in lib/ directory)
commonjs: {
plugins: [
["transform-es2015-modules-commonjs", { loose: true }]
]
},
"es": {
"plugins": [
// BABEL_ENV=es ... for our ES distribution (promoted in lib/ directory)
es: {
plugins: [
]
},
"test": {
"plugins": [
["transform-es2015-modules-commonjs", { "loose": true }]
]
}
}
}
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: node_js
node_js:
- "6"
- "7"
- "6" # NOTE: even numbers only (odds are node development)
- "8"
- "10"
- node # current node version (may be duplicate, but that's OK)
script:
- npm run prepublish # lint, clean, build (bundles), test (bundles)
Expand Down
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ and **contains migration instructions**.

Release | What | *When*
---------|-------------------------------------------------|------------------
[v0.1.3] | Establish Polyfill Strategy | *July 2, 2018*
[v0.1.2] | Auto Redux DevTools Integration | *March 29, 2018*
[v0.1.1] | react-native android patch | *March 7, 2018*
[v0.1.0] | Initial Release | *March 6, 2018*


[v0.1.3]: #v013---establish-polyfill-strategy-july-2-2018
[v0.1.2]: #v012---auto-redux-devtools-integration-march-29-2018
[v0.1.1]: #v011---react-native-android-patch-march-7-2018
[v0.1.0]: #v010---initial-release-march-6-2018
Expand Down Expand Up @@ -43,10 +46,39 @@ RUNNING CONTENT (pop out as needed) ...
**Enhanced**: ... for enhancements
**Security**: ... in case of vulnerabilities
**Docs**: ... changes in documentation
**Review**: ... requires review
**Internal**: ... internal change NOT affecting user/client
UNRELEASED ******************************************************************************** -->



<!-- *** RELEASE *************************************************************** -->

## v0.1.3 - Establish Polyfill Strategy *(July 2, 2018)*

[GitHub Content](https://github.com/KevinAst/feature-redux/tree/v0.1.3)
&bull;
[GitHub Release](https://github.com/KevinAst/feature-redux/releases/tag/v0.1.3)
&bull;
[Diff](https://github.com/KevinAst/feature-redux/compare/v0.1.2...v0.1.3)

**NOTE**: This release is a **non-breaking change** _(i.e. no API was affected)_.

- **Review**: A new policy is in affect where **polyfills are the
responsibility of the client app**, when the target JavaScript
engine is inadequate _(such as the IE browser)_. Please refer to
[Potential Need for
Polyfills](./README.md#potential-need-for-polyfills) for more
information.

As a result, all previous code patches related to es2015+ polyfill
issues were removed, in favor of **polyfilling at the app-level**.

- **Internal**: The most current babel version/configuration is now
used to transpile the library's es5 distribution.


<!-- *** RELEASE *************************************************************** -->

## v0.1.2 - Auto Redux DevTools Integration *(March 29, 2018)*
Expand Down
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Let's see how this all works together ...
- [API](#api)
- [`reducerAspect: Aspect`](#reduceraspect-aspect)
- [`slicedReducer(slice, reducer): reducerFn`](#slicedreducer)
- [Potential Need for Polyfills](#potential-need-for-polyfills)


## Install
Expand All @@ -104,6 +105,12 @@ Let's see how this all works together ...
npm install --save feature-redux
```

**SideBar**: Depending on how current your target browser is
_(i.e. it's JavaScript engine)_, you may need to polyfill your app
_(please refer to [Potential Need for
Polyfills](#potential-need-for-polyfills))_.


## Usage

1. Within your mainline, register the **feature-redux**
Expand Down Expand Up @@ -604,6 +611,45 @@ reducer.getSlicedState(appState): slicedState
</ul>


## Potential Need for Polyfills

The implementation of this library employs modern es2015+ JavaScript
constructs. Even though the library distribution is transpiled to
[es5](https://en.wikipedia.org/wiki/ECMAScript#5th_Edition) _(the
least common denominator)_, **polyfills may be required** if you are
using an antiquated JavaScript engine _(such as the IE browser)_.

We take the approach that **polyfills are the responsibility of the
client app**. This is a legitimate approach, as specified by the [W3C
Polyfill Findings](https://www.w3.org/2001/tag/doc/polyfills/)
_(specifically [Advice for library
authors](https://www.w3.org/2001/tag/doc/polyfills/#advice-for-library-and-framework-authors))_.

- polyfills should only be introduced one time _(during code expansion
of the app)_
- a library should not pollute the global name space _(by including
polyfills at the library level)_
- a library should not needlessly increase it's bundle size _(by
including polyfills that are unneeded in a majority of target
environments)_

As it turns out, **app-level polyfills are not hard to implement**,
with the advent of third-party utilities, such as babel:

- simply import [babel-polyfill](https://babeljs.io/docs/en/babel-polyfill.html)
- or use babel's
[babel-preset-env](https://babeljs.io/docs/en/babel-preset-env.html)
in conjunction with babel 7's `"useBuiltins": "usage"` option

**If your target JavaScript engine is inadequate, it will generate
native run-time errors, and you will need to address the polyfills.**
Unfortunately, in many cases these errors can be very obscure _(even
to seasoned developers)_. The following [Babel Feature
Request](https://github.com/babel/babel/issues/8089) _(if/when
implemented)_ is intended to address this issue.




<!--- *** REFERENCE LINKS *** --->

Expand Down
Loading

0 comments on commit 50959a3

Please sign in to comment.