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
Provenance
- Commit
c4f2c2d- Tree
fd7a19e- Author
Michel Weststrate <mweststrate@gmail.com>- Committer
Michel Weststrate <mweststrate@gmail.com>- Parent
74a97b6
5 files changed+144 added−62 removed
added:changelog.md+81 added
1+# Changelog2+3+### 0.8.04+5+* 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.8+9+### 0.7.010+11+* Immer will now use `Object.is` instead of `===` for equality checks12+13+### 0.6.114+15+* Fixed issue where proxies inside new objects where not cleaned up. Fixes Fixes [#53](https://github.com/mweststrate/immer/issues/53)16+17+### 0.6.018+19+* 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`20+21+### 0.5.022+23+* Make sure es5.js is transpiled24+25+### 0.4.226+27+* 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 supported29+30+### 0.4.131+32+* Added UMD build33+34+### 0.4.035+36+* 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"`.39+40+### 0.3.141+42+* Republished, somehow NPM still returned 0.2.243+44+### 0.3.0 (8-1-2018)45+46+* 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)49+50+### 0.2.251+52+* Fixed [#32](https://github.com/mweststrate/immer/issue/32): changes are not properly reflected in proxies when using for example `console.dir`53+54+### 0.2.155+56+* 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)57+58+### 0.2.059+60+* Immer now supports JavaScript engines without Proxies as well! Just require `immer` from `"immer/es5"`. See [#22](https://github.com/mweststrate/immer/pull/22)61+62+### 0.1.2 (2-1-2018)63+64+* Fixed issue where trailing commas could break consumers. Fixes [#21](https://github.com/mweststrate/immer/pull/21).65+66+### 0.1.1 (2-1-2018)67+68+* Fixed issue where TypeScript typings were not correctly exposed. Fixes [#18](https://github.com/mweststrate/immer/issue/18).69+70+### 0.1.0 (1-1-2018)71+72+* 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)77+78+### 0.0.4 (31-12-2017)79+80+* 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
1234567891011121328 unmodified lines4243444546474849506 unmodified lines575859605661626364659 unmodified lines{ "name": "immer", "version": "0.7.0", "description": "Create your next immutable state by mutating the current one", "main": "dist/immer.js", "umd:main": "dist/immer.umd.js", "module": "dist/immer.module.js", "jsnext:main": "dist/immer.module.js", "react-native": "dist/immer.module.js", "types": "./immer.d.ts", "scripts": { "test": "jest", "test:perf": "yarn build:babel && node --expose-gc node_modules/jest-cli/bin/jest.js --verbose --testRegex '__performance_tests__/.*'",28 unmodified lines "@types/jest": "^22.0.0", "babel-cli": "^6.26.0", "babel-core": "^6.26.0", "babel-jest": "^22.0.4", "babel-plugin-external-helpers": "^6.22.0", "babel-preset-env": "^1.6.1", "babel-preset-es2015": "^6.24.1", "babel-preset-modern-browsers": "^10.0.1", "coveralls": "^3.0.0",6 unmodified lines "prettier": "^1.9.2", "regenerator-runtime": "^0.11.1", "rimraf": "^2.6.2", "rollup": "^0.54.0", "rollup-plugin-buble": "^0.18.0", "rollup-plugin-babel": "^3.0.3", "rollup-plugin-commonjs": "^8.2.6", "rollup-plugin-filesize": "^1.5.0", "rollup-plugin-node-resolve": "^3.0.2", "rollup-plugin-uglify": "^2.0.1",9 unmodified linesmodified:readme.md+4 added-11 removed
8 unmodified lines9 10 ---11 12 * 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`.14 15 ---16 17 * 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 lines85 * 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.90 91 Read further to see all these benefits explained.92 93 ## Reducer Example88 unmodified lines182 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.185 185-## Using Immer on older JavaScript environments186+## Immer on older JavaScript environments?187 188 By default `produce` tries to use proxies for optimal performance.189 However, on older JavaScript engines `Proxy` is not available.189-For example, Microsoft Internet Explorer or React Native on Android.190+For example, when running Microsoft Internet Explorer or React Native on Android.191 In such cases Immer will fallback to an ES5 compatible implementation which works identical, but is a bit slower.191-However, if you want to slim down your bundle, you could only include the Proxy based implementation by importing from `immer/proxy`.192 193-An overview of the available builds:194-195-Immer 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)199-193 ## Pitfalls194 195 1. Currently, Immer only supports plain objects and arrays. PRs are welcome for more language built-in types like `Map` and `Set`.196 2. 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 linesmodified:rollup.config.js+29 added-13 removed
1223456788910111213131415161718192021222324252627282930313233342324252627282930353637383940414243324445464748493850515253545556import {minify} from "uglify-es"import buble from "rollup-plugin-buble"import commonjs from "rollup-plugin-commonjs"import filesize from "rollup-plugin-filesize"import resolve from "rollup-plugin-node-resolve"import uglify from "rollup-plugin-uglify"import babel from "rollup-plugin-babel"
function getConfig(format) {function getConfig(dest, format, ugly) { const conf = { input: "src/index.js", output: { exports: "named", file: `dist/immer${format === "umd" ? ".umd" : ""}.js`, file: dest, format, name: "immer", sourcemap: true }, plugins: [ resolve({ jsnext: true }), commonjs(), babel({ babelrc: false, presets: [ [ "env", { modules: false } ] ], plugins: ["external-helpers"] }), buble(), uglify( { warnings: true, toplevel: true }, minify ), ugly && uglify( { warnings: true, toplevel: true }, minify ), filesize() ] ].filter(Boolean) }
return conf}
const config = [getConfig("cjs"), getConfig("umd")]const config = [ getConfig("dist/immer.js", "cjs", false), getConfig("dist/immer.umd.js", "umd", true), getConfig("dist/immer.module.js", "es", false)]
export default configmodified:yarn.lock+24 added-37 removed
30 unmodified lines31 resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-4.1.0.tgz#ab716025dbe17c54d3ef81d32ece2b2d99fe2538"32 dependencies:33 acorn "^5.0.0"34 35-acorn-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"40-41-acorn5-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"46-47-acorn@^3.0.4:48- version "3.3.0"49- resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a"50-35 acorn@^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 lines375 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"378 379+babel-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"384+385 babel-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 lines852 resolved "https://registry.yarnpkg.com/bser/-/bser-2.0.0.tgz#9ac78d3ed5d915804fd87acb158bc797147a1719"853 dependencies:854 node-int64 "^0.4.0"855 866-buble@^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"878-856 builtin-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 lines893 has-ansi "^2.0.0"894 strip-ansi "^3.0.0"895 supports-color "^2.0.0"896 920-chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0:897+chalk@^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 lines1209 estraverse@^4.2.0:1210 version "4.2.0"1211 resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13"1212 1213+estree-walker@^0.2.1:1214+ version "0.2.1"1215+ resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.2.1.tgz#bdafe8095383d8414d5dc2ecf4c9173b6db9412e"1216+1217 estree-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 lines2484 prelude-ls "~1.1.2"2485 type-check "~0.3.2"2486 wordwrap "~1.0.0"2487 2507-os-homedir@^1.0.0, os-homedir@^1.0.1:2488+os-homedir@^1.0.0:2489 version "1.0.2"2490 resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3"2491 2492 os-locale@^2.0.0:390 unmodified lines2883 resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36"2884 dependencies:2885 glob "^7.0.5"2886 2906-rollup-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"2887+rollup-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"2892 2893 rollup-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 lines2923 resolved "https://registry.yarnpkg.com/rollup-plugin-uglify/-/rollup-plugin-uglify-2.0.1.tgz#67b37ad1efdafbd83af4c36b40c189ee4866c969"2924 dependencies:2925 uglify-js "^3.0.9"2926 2927+rollup-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"2933+2934 rollup-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 lines3324 assert-plus "^1.0.0"3325 core-util-is "1.0.2"3326 extsprintf "^1.2.0"3327 3341-vlq@^0.2.1, vlq@^0.2.2:3328+vlq@^0.2.1:3329 version "0.2.3"3330 resolved "https://registry.yarnpkg.com/vlq/-/vlq-0.2.3.tgz#8f3e4328cf63b1540c0d67e1b2778386f8975b26"3331 3332 walker@~1.0.5:143 unmodified lines