Skip to content

Commit fdc77c7

Browse files
committed
establish library polyfill strategy - upgrade babel ver/config
1 parent e085aab commit fdc77c7

File tree

6 files changed

+9336
-28
lines changed

6 files changed

+9336
-28
lines changed

.babelrc

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
{
2-
"presets": ["es2015", "stage-1", "react"],
3-
"env": {
4-
"commonjs": {
5-
"plugins": [
6-
["transform-es2015-modules-commonjs", { "loose": true }]
2+
// standard presets applying various plugins
3+
presets: [
4+
"env", // babel-preset-env: supporting es2015, es2016, and es2017 (with configuration)
5+
"react" // babel-preset-react: react and jsx
6+
],
7+
8+
// explicit plugins NOT part of the presets (above) ... prefer this over yearly presets
9+
plugins: [
10+
"transform-object-rest-spread", // "object rest properties" (es2018 Stage 4)
11+
// ... ex: myFn({p1, p2, ...restParms})
12+
],
13+
14+
// additional plugins explicitly called out via the BABEL_ENV variable
15+
// ... see: build scripts in package.json
16+
env: {
17+
// BABEL_ENV=commonjs ... our CommonJS distribution (promoted in lib/ directory)
18+
commonjs: {
19+
plugins: [
20+
["transform-es2015-modules-commonjs", { loose: true }]
721
]
822
},
9-
"es": {
10-
"plugins": [
23+
// BABEL_ENV=es ... for our ES distribution (promoted in lib/ directory)
24+
es: {
25+
plugins: [
1126
]
1227
},
13-
"test": {
14-
"plugins": [
15-
["transform-es2015-modules-commonjs", { "loose": true }]
16-
]
17-
}
1828
}
1929
}

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
language: node_js
22
node_js:
3-
- "6"
4-
- "7"
3+
- "6" # NOTE: even numbers only (odds are node development)
54
- "8"
5+
- "10"
66
- node # current node version (may be duplicate, but that's OK)
77
script:
88
- npm run prepublish # lint, clean, build (bundles), test (bundles)

CHANGELOG.md

Lines changed: 82 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,86 @@
11
# Change Log
22

3-
The **feature-redux-logic**project adheres to [Semantic
3+
The **feature-redux-logic** project adheres to [Semantic
44
Versioning](http://semver.org/).
55

6-
Each release, along with migration instructions, is documented on the
7-
[Github Releases](https://github.com/KevinAst/feature-redux-logic/releases)
8-
page.
6+
Each release is documented on this page *(in addition to the [Github
7+
Release Notes](https://github.com/KevinAst/feature-redux-logic/releases))*,
8+
and **contains migration instructions**.
9+
10+
## Summary:
11+
12+
Release | What | *When*
13+
---------|-------------------------------------------------|------------------
14+
[v0.1.3] | Establish Polyfill Strategy | *July ??, 2018*
15+
[v0.1.0] | Initial Release | *March 6, 2018*
16+
17+
18+
<!-- ?? change next line WHEN date is known -->
19+
[v0.1.3]: #v013---establish-polyfill-strategy-july--2018
20+
[v0.1.0]: #v010---initial-release-march-6-2018
21+
22+
23+
24+
<!-- UNRELEASED **************************************************************************
25+
26+
TEMPLATE:
27+
## vn.n.n - DESC *(DATE ?, 2018)*
28+
29+
[GitHub Content](https://github.com/KevinAst/feature-redux-logic/tree/vn.n.n)
30+
&bull;
31+
[GitHub Release](https://github.com/KevinAst/feature-redux-logic/releases/tag/vn.n.n)
32+
&bull;
33+
[Diff](see below)
34+
35+
RUNNING CONTENT (pop out as needed) ...
36+
37+
- adorn bullets with following bolded prefix
38+
**Added**: ... for new features
39+
**Changed**: ... for changes in existing functionality
40+
**Deprecated**: ... for soon-to-be removed features
41+
**Removed**: ... for now removed features
42+
**Fixed**: ... for any bug fixes
43+
**Enhanced**: ... for enhancements
44+
**Security**: ... in case of vulnerabilities
45+
**Docs**: ... changes in documentation
46+
**Review**: ... requires review
47+
**Internal**: ... internal change NOT affecting user/client
48+
49+
UNRELEASED ******************************************************************************** -->
50+
51+
52+
53+
<!-- *** RELEASE *************************************************************** -->
54+
55+
## v0.1.3 - Establish Polyfill Strategy *(July ??, 2018)*
56+
57+
[GitHub Content](https://github.com/KevinAst/feature-redux-logic/tree/v0.1.3)
58+
&bull;
59+
[GitHub Release](https://github.com/KevinAst/feature-redux-logic/releases/tag/v0.1.3)
60+
&bull;
61+
[Diff](https://github.com/KevinAst/feature-redux-logic/compare/v0.1.2...v0.1.3)
62+
63+
**NOTE**: This release is a **non-breaking change** _(i.e. no API was affected)_.
64+
65+
- **Review**: A new policy is in affect where **polyfills are the
66+
responsibility of the client app**, when the target JavaScript
67+
engine is inadequate _(such as the IE browser)_. Please refer to
68+
[Potential Need for
69+
Polyfills](./README.md#potential-need-for-polyfills) for more
70+
information.
71+
72+
As a result, all previous code patches related to es2015+ polyfill
73+
issues were removed, in favor of **polyfilling at the app-level**.
74+
75+
- **Internal**: The most current babel version/configuration is now
76+
used to transpile the library's es5 distribution.
77+
78+
79+
<!-- *** RELEASE *************************************************************** -->
80+
81+
## v0.1.0 - Initial Release *(March 6, 2018)*
82+
[GitHub Content](https://github.com/KevinAst/feature-redux-logic/tree/v0.1.0)
83+
&bull;
84+
[GitHub Release](https://github.com/KevinAst/feature-redux-logic/releases/tag/v0.1.0)
85+
86+
**This is where it all began ...**

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Let's see how this all works together ...
5656
- [Error Conditions](#error-conditions)
5757
- [API](#api)
5858
- [`logicAspect: Aspect`](#logicaspect-aspect)
59+
- [Potential Need for Polyfills](#potential-need-for-polyfills)
5960

6061

6162

@@ -79,6 +80,11 @@ Let's see how this all works together ...
7980
npm install --save feature-redux-logic
8081
```
8182

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

8389
## Usage
8490

@@ -326,6 +332,44 @@ Please refer to the [Usage] section for examples of this process.
326332
</ul>
327333

328334

335+
## Potential Need for Polyfills
336+
337+
The implementation of this library employs modern es2015+ JavaScript
338+
constructs. Even though the library distribution is transpiled to
339+
[es5](https://en.wikipedia.org/wiki/ECMAScript#5th_Edition) _(the
340+
least common denominator)_, **polyfills may be required** if you are
341+
using an antiquated JavaScript engine _(such as the IE browser)_.
342+
343+
We take the approach that **polyfills are the responsibility of the
344+
client app**. This is a legitimate approach, as specified by the [W3C
345+
Polyfill Findings](https://www.w3.org/2001/tag/doc/polyfills/)
346+
_(specifically [Advice for library
347+
authors](https://www.w3.org/2001/tag/doc/polyfills/#advice-for-library-and-framework-authors))_.
348+
349+
- polyfills should only be introduced one time _(during code expansion
350+
of the app)_
351+
- a library should not pollute the global name space _(by including
352+
polyfills at the library level)_
353+
- a library should not needlessly increase it's bundle size _(by
354+
including polyfills that are unneeded in a majority of target
355+
environments)_
356+
357+
As it turns out, **app-level polyfills are not hard to implement**,
358+
with the advent of third-party utilities, such as babel:
359+
360+
- simply import [babel-polyfill](https://babeljs.io/docs/en/babel-polyfill.html)
361+
- or use babel's
362+
[babel-preset-env](https://babeljs.io/docs/en/babel-preset-env.html)
363+
in conjunction with babel 7's `"useBuiltins": "usage"` option
364+
365+
**If your target JavaScript engine is inadequate, it will generate
366+
native run-time errors, and you will need to address the polyfills.**
367+
Unfortunately, in many cases these errors can be very obscure _(even
368+
to seasoned developers)_. The following [Babel Feature
369+
Request](https://github.com/babel/babel/issues/8089) _(if/when
370+
implemented)_ is intended to address this issue.
371+
372+
329373

330374

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

0 commit comments

Comments
 (0)