Skip to content
Myr

Use babel (for Symbol polyfill). Also generate ES module

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Michel Weststrate · committed by Michel Weststrate · parent 74a97b6 · Browse files · 5 files+144 added−62 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+144 added−62 removed

  • other:+144 added−62 removed

5 files+144 added−62 removed

added:changelog.md+81 added
1# Changelog23### 0.8.045* The built is now being rolled up [#64](https://github.com/mweststrate/immer/pull/64) by [Arthur Denner](https://github.com/arthurdenner). A minified gzipped built is only 2kb!6* There are no longer separate builds available for the proxy and es5 implementation. The sources where merged to allow for more code reuse.7* The package now exposes an ES module as well.89### 0.7.01011* Immer will now use `Object.is` instead of `===` for equality checks1213### 0.6.11415* Fixed issue where proxies inside new objects where not cleaned up. Fixes Fixes [#53](https://github.com/mweststrate/immer/issues/53)1617### 0.6.01819* The default import now bundles both the es5 and proxy implementation as a convenient default. For more optimal bundle sizes, import `immer/proxy` or `immer/es5`2021### 0.5.02223* Make sure es5.js is transpiled2425### 0.4.22627* Fixed generating a wrong property descriptor for the `length` property of arrays. Fixes [#50](https://github.com/mweststrate/immer/issues/50)28* Defining custom properties on drafts is no longer supported2930### 0.4.13132* Added UMD build3334### 0.4.03536* Introduce support for [currying](https://github.com/mweststrate/immer#currying). [#37](https://github.com/mweststrate/immer/pull/37)37* Added argument checking38* The name of the immer import is now idiomatically `produce`. So the recommend import statement is: `import produce from "immer"`.3940### 0.3.14142* Republished, somehow NPM still returned 0.2.24344### 0.3.0 (8-1-2018)4546* Increased performance of the proxy-based implementation by a factor 2x - 3x. [#38](https://github.com/mweststrate/immer/pull/38)47* Improved typescript typings [#40](https://github.com/mweststrate/immer/pull/40) by [Julien Cavaleiro](https://github.com/Julienng)48* Added badges, coverage and typical project shizzle. [#25](https://github.com/mweststrate/immer/pull/25) by [Gregory Assasie](https://github.com/Gregjarvez) and [#39](https://github.com/mweststrate/immer/pull/39) by [Fadi Khadra](https://github.com/fkhadra)4950### 0.2.25152* Fixed [#32](https://github.com/mweststrate/immer/issue/32): changes are not properly reflected in proxies when using for example `console.dir`5354### 0.2.15556* Fixed: `immer/es5.js` was not packed into the package. PR [#28](https://github.com/mweststrate/immer/pull/28) by [Nicolas Lepage](https://github.com/nlepage)5758### 0.2.05960* Immer now supports JavaScript engines without Proxies as well! Just require `immer` from `"immer/es5"`. See [#22](https://github.com/mweststrate/immer/pull/22)6162### 0.1.2 (2-1-2018)6364* Fixed issue where trailing commas could break consumers. Fixes [#21](https://github.com/mweststrate/immer/pull/21).6566### 0.1.1 (2-1-2018)6768* Fixed issue where TypeScript typings were not correctly exposed. Fixes [#18](https://github.com/mweststrate/immer/issue/18).6970### 0.1.0 (1-1-2018)7172* Fixed `immer` function export, it is now properly exposed as the `default` export. So `import immer from "immer"`. See [#15](https://github.com/mweststrate/immer/pull/15)73* Immer now automatically freezes any state modifications made. Turn this is using `setAutoFreeze(false)` for more efficiency in production builds. See [#15](https://github.com/mweststrate/immer/pull/15)74* Added support for frozen state trees in strict mode. See [#15](https://github.com/mweststrate/immer/pull/15)75* `immer` will now warn if you accidentally return something from the _thunk_. Fixes [#] through [#16](https://github.com/mweststrate/immer/pull/16/). By [Gregory Assasie](https://github.com/Gregjarvez).76* Proxies are now automatically cleaned up. This makes it impossible to read proxies after the `immer` function has finished. This prevents users from accidentally reading stale date. [#14](https://github.com/mweststrate/immer/pull/14) by [@benbraou](https://github.com/benbraou)7778### 0.0.4 (31-12-2017)7980* Added typescript typings [#11](https://github.com/mweststrate/immer/pull/11) by [@benbraou](https://github.com/benbraou)81* Fixed bug when setting properties to `undefined`. Fixes [#12](https://github.com/mweststrate/immer/issues/12) through [#13](https://github.com/mweststrate/immer/pull/13) by [@benbraou](https://github.com/benbraou)
modified:package.json+6 added-1 removed
modified:readme.md+4 added-11 removed
8 unmodified lines
910---1112* NPM / Yarn: `npm install immer`13* CDN: https://unpkg.com/immer/dist/immer.umd.js or https://unpkg.com/immer/dist/es5.umd.js. Exposed global is `immer`.13* CDN: https://unpkg.com/immer/dist/immer.umd.js. Exposed global is `immer`.1415---1617* Egghead lesson covering all of immer (7m): [Simplify creating immutable data trees with Immer](https://egghead.io/lessons/redux-simplify-creating-immutable-data-trees-with-immer)
67 unmodified lines
85* Structural sharing out of the box86* Object freezing out of the box87* Deep updates are a breeze88* Boilerplate reduction. Less noise, more concise code.89* Small: bundled and minified: 2KB.9091Read further to see all these benefits explained.9293## Reducer Example
88 unmodified lines
182 This comes with a performance impact, so it is recommended to disable this option in production.183 It is by default enabled.184 Use `setAutoFreeze(true / false)` to turn this feature on or off.185185## Using Immer on older JavaScript environments186## Immer on older JavaScript environments?187188By default `produce` tries to use proxies for optimal performance.189However, on older JavaScript engines `Proxy` is not available.189For example, Microsoft Internet Explorer or React Native on Android.190For example, when running Microsoft Internet Explorer or React Native on Android.191In such cases Immer will fallback to an ES5 compatible implementation which works identical, but is a bit slower.191However, if you want to slim down your bundle, you could only include the Proxy based implementation by importing from `immer/proxy`.192193An overview of the available builds:194195Immer exposes its functionality in 3 different ways:196* `import produce from "immer"`, the default, ships with both the Proxy and ES5 compatible implementation, and picks at runtime the best matching one. This is the most convenient, but adds the most to the bundle size (~2KB)197* `import produce from "immer/proxy"`: This build is optimized for modern browser, which support Proxies and other modern language features, and doesn't polyfill things like `Symbol`. Use this if you are targetting a modern environment only198* `import produce from "immer/es5"`: Only bundle the ES5 compatible implementation (which of course also works for modern browsers)199193## Pitfalls1941951. Currently, Immer only supports plain objects and arrays. PRs are welcome for more language built-in types like `Map` and `Set`.1962. Immer only processes native arrays and plain objects (with a prototype of `null` or `Object`). Any other type of value will be treated verbatim! So if you modify a `Map` or `Buffer` (or whatever complex object from the draft state), the changes will be persisted. But, both in your new and old state! So, in such cases, make sure to always produce fresh instances if you want to keep your state truly immutable.
66 unmodified lines
modified:rollup.config.js+29 added-13 removed
modified:yarn.lock+24 added-37 removed
30 unmodified lines
31 resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-4.1.0.tgz#ab716025dbe17c54d3ef81d32ece2b2d99fe2538"32 dependencies:33 acorn "^5.0.0"3435acorn-jsx@^3.0.1:36 version "3.0.1"37 resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-3.0.1.tgz#afdf9488fb1ecefc8348f6fb22f464e32a58b36b"38 dependencies:39 acorn "^3.0.4"4041acorn5-object-spread@^4.0.0:42 version "4.0.0"43 resolved "https://registry.yarnpkg.com/acorn5-object-spread/-/acorn5-object-spread-4.0.0.tgz#d5758081eed97121ab0be47e31caaef2aa399697"44 dependencies:45 acorn "^5.1.2"4647acorn@^3.0.4:48 version "3.3.0"49 resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a"5035acorn@^5.0.0, acorn@^5.1.2, acorn@^5.2.1:36 version "5.3.0"37 resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.3.0.tgz#7446d39459c54fb49a80e6ee6478149b940ec822"38
336 unmodified lines
375 resolved "https://registry.yarnpkg.com/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz#35157b101426fd2ffd3da3f75c7d1e91835bbf8a"376 dependencies:377 babel-runtime "^6.22.0"378379babel-plugin-external-helpers@^6.22.0:380 version "6.22.0"381 resolved "https://registry.yarnpkg.com/babel-plugin-external-helpers/-/babel-plugin-external-helpers-6.22.0.tgz#2285f48b02bd5dede85175caf8c62e86adccefa1"382 dependencies:383 babel-runtime "^6.22.0"384385babel-plugin-istanbul@^4.1.5:386 version "4.1.5"387 resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.5.tgz#6760cdd977f411d3e175bb064f2bc327d99b2b6e"388 dependencies:
463 unmodified lines
852 resolved "https://registry.yarnpkg.com/bser/-/bser-2.0.0.tgz#9ac78d3ed5d915804fd87acb158bc797147a1719"853 dependencies:854 node-int64 "^0.4.0"855866buble@^0.18.0:867 version "0.18.0"868 resolved "https://registry.yarnpkg.com/buble/-/buble-0.18.0.tgz#63b338b8248c474b46fd3e3546560ae08d8abe91"869 dependencies:870 acorn "^5.1.2"871 acorn-jsx "^3.0.1"872 acorn5-object-spread "^4.0.0"873 chalk "^2.1.0"874 magic-string "^0.22.4"875 minimist "^1.2.0"876 os-homedir "^1.0.1"877 vlq "^0.2.2"878856builtin-modules@^1.0.0, builtin-modules@^1.1.0:857 version "1.1.1"858 resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f"859
33 unmodified lines
893 has-ansi "^2.0.0"894 strip-ansi "^3.0.0"895 supports-color "^2.0.0"896920chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0:897chalk@^2.0.0, chalk@^2.0.1:898 version "2.3.0"899 resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.0.tgz#b5ea48efc9c1793dccc9b4767c93914d3f2d52ba"900 dependencies:901 ansi-styles "^3.1.0"
307 unmodified lines
1209estraverse@^4.2.0:1210 version "4.2.0"1211 resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13"12121213estree-walker@^0.2.1:1214 version "0.2.1"1215 resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.2.1.tgz#bdafe8095383d8414d5dc2ecf4c9173b6db9412e"12161217estree-walker@^0.3.0:1218 version "0.3.1"1219 resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.3.1.tgz#e6b1a51cf7292524e7237c312e5fe6660c1ce1aa"1220
1263 unmodified lines
2484 prelude-ls "~1.1.2"2485 type-check "~0.3.2"2486 wordwrap "~1.0.0"24872507os-homedir@^1.0.0, os-homedir@^1.0.1:2488os-homedir@^1.0.0:2489 version "1.0.2"2490 resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3"24912492os-locale@^2.0.0:
390 unmodified lines
2883 resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36"2884 dependencies:2885 glob "^7.0.5"28862906rollup-plugin-buble@^0.18.0:2907 version "0.18.0"2908 resolved "https://registry.yarnpkg.com/rollup-plugin-buble/-/rollup-plugin-buble-0.18.0.tgz#6e20d1b2840c59eb496b9f954f75243e51786ac1"2887rollup-plugin-babel@^3.0.3:2888 version "3.0.3"2889 resolved "https://registry.yarnpkg.com/rollup-plugin-babel/-/rollup-plugin-babel-3.0.3.tgz#63adedc863130327512a4a9006efc2241c5b7c15"2890 dependencies:2910 buble "^0.18.0"2911 rollup-pluginutils "^2.0.1"2891 rollup-pluginutils "^1.5.0"28922893rollup-plugin-commonjs@^8.2.6:2894 version "8.2.6"2895 resolved "https://registry.yarnpkg.com/rollup-plugin-commonjs/-/rollup-plugin-commonjs-8.2.6.tgz#27e5b9069ff94005bb01e01bb46a1e4873784677"
27 unmodified lines
2923 resolved "https://registry.yarnpkg.com/rollup-plugin-uglify/-/rollup-plugin-uglify-2.0.1.tgz#67b37ad1efdafbd83af4c36b40c189ee4866c969"2924 dependencies:2925 uglify-js "^3.0.9"29262927rollup-pluginutils@^1.5.0:2928 version "1.5.2"2929 resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-1.5.2.tgz#1e156e778f94b7255bfa1b3d0178be8f5c552408"2930 dependencies:2931 estree-walker "^0.2.1"2932 minimatch "^3.0.2"29332934rollup-pluginutils@^2.0.1:2935 version "2.0.1"2936 resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.0.1.tgz#7ec95b3573f6543a46a6461bd9a7c544525d0fc0"2937 dependencies:
386 unmodified lines
3324 assert-plus "^1.0.0"3325 core-util-is "1.0.2"3326 extsprintf "^1.2.0"33273341vlq@^0.2.1, vlq@^0.2.2:3328vlq@^0.2.1:3329 version "0.2.3"3330 resolved "https://registry.yarnpkg.com/vlq/-/vlq-0.2.3.tgz#8f3e4328cf63b1540c0d67e1b2778386f8975b26"33313332walker@~1.0.5:
143 unmodified lines