Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: immerjs/immer
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: fa1f5e60b560a4c5fe2da4ffcbcaaae98632c473
Choose a base ref
...
head repository: immerjs/immer
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: da2bd4fa0edc9335543089fe7d290d6a346c40c5
Choose a head ref
Loading
Showing with 30,269 additions and 8,940 deletions.
  1. +1 −1 .babelrc
  2. +3 −0 .codesandbox/ci.json
  3. +2 −0 .dockerignore
  4. +3 −0 .github/FUNDING.yml
  5. +19 −8 .github/ISSUE_TEMPLATE/bug.md
  6. +4 −0 .github/ISSUE_TEMPLATE/feature.md
  7. +21 −0 .github/ISSUE_TEMPLATE/question.md
  8. +26 −0 .github/lock.yml
  9. +3 −1 .gitignore
  10. +11 −0 .gitpod.yml
  11. +3 −3 .prettierrc
  12. +17 −21 .travis.yml
  13. +18 −20 .vscode/launch.json
  14. +2 −1 .vscode/settings.json
  15. +3 −0 .watchmanconfig
  16. +10 −0 Dockerfile
  17. +67 −55 __performance_tests__/add-data.js
  18. +102 −96 __performance_tests__/incremental.js
  19. +212 −206 __performance_tests__/todo.js
  20. +617 −0 __tests__/__prod_snapshots__/base.js.snap
  21. +17 −0 __tests__/__prod_snapshots__/curry.js.snap
  22. +25 −0 __tests__/__prod_snapshots__/frozen.js.snap
  23. +97 −0 __tests__/__prod_snapshots__/manual.js.snap
  24. +7 −0 __tests__/__prod_snapshots__/patch.js.snap
  25. +11 −0 __tests__/__prod_snapshots__/plugins.js.snap
  26. +3 −0 __tests__/__prod_snapshots__/readme.js.snap
  27. +527 −51 __tests__/__snapshots__/base.js.snap
  28. +8 −8 __tests__/__snapshots__/curry.js.snap
  29. +25 −0 __tests__/__snapshots__/frozen.js.snap
  30. +0 −297 __tests__/__snapshots__/hooks.js.snap
  31. +12 −12 __tests__/__snapshots__/manual.js.snap
  32. +3 −3 __tests__/__snapshots__/patch.js.snap
  33. +11 −0 __tests__/__snapshots__/plugins.js.snap
  34. +3 −0 __tests__/__snapshots__/readme.js.snap
  35. +2,429 −1,246 __tests__/base.js
  36. +212 −0 __tests__/current.js
  37. +87 −61 __tests__/curry.js
  38. +332 −284 __tests__/draft.ts
  39. +151 −0 __tests__/empty.ts
  40. +3 −0 __tests__/flow/.flowconfig
  41. +59 −4 __tests__/flow/flow.js.flow
  42. +258 −125 __tests__/frozen.js
  43. +0 −227 __tests__/hooks.js
  44. +118 −55 __tests__/immutable.ts
  45. +137 −128 __tests__/manual.js
  46. +299 −0 __tests__/map-set.js
  47. +0 −11 __tests__/null-base.js
  48. +11 −0 __tests__/null.js
  49. +65 −45 __tests__/original.js
  50. +1,177 −341 __tests__/patch.js
  51. +49 −0 __tests__/plugins.js
  52. +65 −49 __tests__/polyfills.js
  53. +388 −327 __tests__/produce.ts
  54. +259 −167 __tests__/readme.js
  55. +101 −0 __tests__/redux.ts
  56. +243 −0 __tests__/regressions.js
  57. +45 −56 __tests__/test-data.json
  58. +2 −1 __tests__/tsconfig.json
  59. +18 −0 _site/.github/ISSUE_TEMPLATE/bug/index.html
  60. +6 −0 _site/.github/ISSUE_TEMPLATE/feature/index.html
  61. +1,190 −0 _site/readme/index.html
  62. +0 −29 bili.config.ts
  63. +315 −0 compat/pre-3.7/dist/immer.d.ts
  64. +18 −0 docker-compose.yml
  65. +52 −0 docs/api.md
  66. +56 −0 docs/async.md
  67. +24 −0 docs/built-with.md
  68. +73 −0 docs/complex-objects.md
  69. +58 −0 docs/current.md
  70. +71 −0 docs/curried-produce.md
  71. +63 −0 docs/example-reducer.md
  72. +45 −0 docs/example-setstate.md
  73. +45 −0 docs/faq.md
  74. +25 −0 docs/freezing.md
  75. +78 −0 docs/installation.md
  76. +66 −0 docs/introduction.md
  77. +60 −0 docs/map-set.md
  78. +34 −0 docs/original.md
  79. +178 −0 docs/patches.md
  80. +59 −0 docs/performance.md
  81. +91 −0 docs/pitfalls.md
  82. +63 −0 docs/produce.md
  83. +18 −0 docs/resources.md
  84. +123 −0 docs/return.md
  85. +12 −0 docs/support.md
  86. +132 −0 docs/typescript.md
  87. +146 −0 docs/update-patterns.md
  88. +6 −0 ignoreObseleteSnapshots.js
  89. BIN images/immer-logo.png
  90. +8 −0 images/immer-logo.svg
  91. BIN images/immer.png
  92. BIN images/performance.png
  93. BIN images/proxy.png
  94. BIN images/tree.png
  95. +23 −0 index.html
  96. +19 −0 jest.config.build.js
  97. +15 −0 jest.config.build.snapshots.js
  98. +15 −0 jest.config.js
  99. +54 −40 package.json
  100. +16 −773 readme.md
  101. +0 −108 src/common.js
  102. +61 −0 src/core/current.ts
  103. +161 −0 src/core/finalize.ts
  104. +227 −0 src/core/immerClass.ts
  105. +270 −0 src/core/proxy.ts
  106. +86 −0 src/core/scope.ts
  107. +0 −263 src/es5.js
  108. +0 −248 src/immer.d.ts
  109. +0 −288 src/immer.js
  110. +0 −105 src/immer.js.flow
  111. +54 −10 src/{index.js → immer.ts}
  112. +11 −0 src/internal.ts
  113. +0 −136 src/patches.js
  114. +9 −0 src/plugins/all.ts
  115. +270 −0 src/plugins/es5.ts
  116. +345 −0 src/plugins/mapset.ts
  117. +304 −0 src/plugins/patches.ts
  118. +0 −183 src/proxy.js
  119. +0 −42 src/scope.js
  120. +1 −0 src/types/globals.d.ts
  121. +113 −0 src/types/index.js.flow
  122. +188 −0 src/types/types-external.ts
  123. +51 −0 src/types/types-internal.ts
  124. +208 −0 src/utils/common.ts
  125. +47 −0 src/utils/env.ts
  126. +60 −0 src/utils/errors.ts
  127. +112 −0 src/utils/plugins.ts
  128. +15 −3 tsconfig.json
  129. +28 −0 tsdx.config.js
  130. +33 −0 website/core/Footer.js
  131. +100 −0 website/i18n/en.json
  132. +14 −0 website/package.json
  133. +7 −0 website/sidebars.json
  134. +102 −0 website/siteConfig.js
  135. +24 −0 website/static/css/custom.css
  136. BIN website/static/img/favicon.ico
  137. BIN website/static/img/immer-logo.png
  138. +8 −0 website/static/img/immer-logo.svg
  139. BIN {images/hd → website/static/img}/immer.png
  140. BIN website/static/img/performance.png
  141. BIN {images/hd → website/static/img}/proxy.png
  142. BIN {images/hd → website/static/img}/tree.png
  143. +15 −0 website/static/index.html
  144. +6,753 −0 website/yarn.lock
  145. +8,934 −2,802 yarn.lock
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"presets": ["modern-browsers"]
"presets": [["@babel/preset-env", { "targets": { "ie": "11" } }]]
}
3 changes: 3 additions & 0 deletions .codesandbox/ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"sandboxes": ["82zqr6n3kj"]
}
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*/node_modules
*.log
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
open_collective: immer
custom: https://www.paypal.me/michelweststrate
patreon: mweststrate
27 changes: 19 additions & 8 deletions .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,38 @@
---
name: 🐛 Bug report
labels: "bug"
labels:
about: Create a report to help us improve
---

## 🐛 Bug Report

A clear and concise description of what the bug is.

If your bug report involves classes, check the [docs](https://immerjs.github.io/immer/docs/complex-objects) on how classes are handled first. For patches, don't file issues if they are not optimal, only if they are incorrect.

## Link to repro

_A bug report without a reproduction is not a bug report. Failing to follow this templately is likely to result in an immediate close & lock of the issue._

Please provide either a [CodeSandbox demo](https://codesandbox.io/s/immer-sandbox-6wijw), or a PR with a unit test. In limited cases, a _minimal_ repository on GitHub is accepted as well.

## To Reproduce

Steps to reproduce the behavior:

## Expected behavior
## Observed behavior

A clear and concise description of what you expected to happen.
A description of what behavior you observed and why you consider it faulty.

## Link to repro (highly encouraged)
## Expected behavior

Please provide either a [CodeSandbox demo](https://codesandbox.io/s/82zqr6n3kj) or a minimal repository on GitHub.
A clear and concise description of what you expected to happen instead.

## Environment

- **Immer version:**
- [ ] Occurs with `setUseProxies(true)`
- [ ] Occurs with `setUseProxies(false)` (ES5 only)
We only accept bug reports against the latest Immer version.

- **Immer version:**
- [ ] I filed this report against the _latest_ version of Immer
- [ ] Occurs with `setUseProxies(true)`
- [ ] Occurs with `setUseProxies(false)` (ES5 only)
4 changes: 4 additions & 0 deletions .github/ISSUE_TEMPLATE/feature.md
Original file line number Diff line number Diff line change
@@ -12,6 +12,10 @@ A clear and concise description of what the feature is.

Please outline the motivation for the proposal.

## Can this be solved in user-land code?

Request that can be solved in user-land code, or are out of scope of Immer (Immer is not a general data management library!) will typically be declined. We try to stay lean and mean here.

## Example

Please provide an example for how this feature would be used.
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: 🙋‍♂ Question
labels: "question"
about: Submit a proposal for a new feature
---

## 🙋‍♂ Question

A clear and concise description of what the question is. In general we recommend to use Stack Overflow for questions. Questions typically are processed with less priority.

## Link to repro

Please provide a [CodeSandbox demo](https://codesandbox.io/s/immer-sandbox-6wijw) to clarify your question if possible. Typically, questions without minimal codesandbox demo won't be answered.

## Environment

We only accept questions against the latest Immer version.

- **Immer version:**
- [ ] Occurs with `setUseProxies(true)`
- [ ] Occurs with `setUseProxies(false)` (ES5 only)
26 changes: 26 additions & 0 deletions .github/lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Configuration for Lock Threads - https://github.com/dessant/lock-threads

# Number of days of inactivity before a closed issue or pull request is locked
daysUntilLock: 60

# Skip issues and pull requests created before a given timestamp. Timestamp must
# follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable
skipCreatedBefore: 2019-01-01

# Issues and pull requests with these labels will be ignored. Set to `[]` to disable
exemptLabels: []

# Label to add before locking, such as `outdated`. Set to `false` to disable
lockLabel: false

# Comment to post before locking. Set to `false` to disable
lockComment: >
This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs or questions.
# Assign `resolved` as the reason for locking. Set to `false` to disable
setLockReason: true

# Limit to only `issues` or `pulls`
only: issues
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -58,4 +58,6 @@ typings/
.env

.idea
dist/
/dist/
website/build
.rts2*
11 changes: 11 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
tasks:
- command: gp await-port 3000 && gp preview $(gp url 3000)/immer/
- init: yarn install && cd website && yarn install && cd ..
command: yarn run start
ports:
- port: 3000
onOpen: ignore

vscode:
extensions:
- flowtype.flow-for-vscode@1.5.0:AwOT6wgHTF43loZQCAUMLA==
6 changes: 3 additions & 3 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -5,15 +5,15 @@
"requirePragma": false,
"semi": false,
"singleQuote": false,
"tabWidth": 4,
"trailingComma": "none",
"useTabs": false,
"useTabs": true,
"overrides": [
{
"files": [".prettierrc", "*.json"],
"options": {
"printWidth": 200,
"tabWidth": 2
"tabWidth": 2,
"useTabs": false
}
}
]
38 changes: 17 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
language: node_js
node_js:
- "8"
- "10"
- "node"
# - "10.18.1"
- "node"
env:
- NODE_ENV=TEST
- NODE_ENV=TEST
cache:
yarn: true
directories:
- "node_modules"
yarn: true
# directories:
# - "node_modules"
before_script:
- yarn global add if-node-version
- yarn global add if-node-version
script:
- yarn build || travis_terminate 1
- if-node-version 10 || { yarn test && travis_terminate 0; }
- yarn coveralls
- yarn test:flow
- yarn test:dts
- yarn build || travis_terminate 1
- yarn test || travis_terminate 1
- yarn coveralls || travis_terminate 0
jobs:
include:
- stage: deploy
if: branch == master && !fork
node_js: "8.9.1" # pre-installed version
script:
- yarn build
- yarn global add semantic-release@^15
- semantic-release
include:
- stage: deploy
if: branch == master && !fork
script:
- yarn test || travis_terminate 1
- NODE_ENV= yarn build || travis_terminate 1
- yarn semantic-release
38 changes: 18 additions & 20 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
// Note; this config requires node 8.4 or higher
"type": "node",
"protocol": "auto",
"request": "launch",
"name": "debug unit test",
"stopOnEntry": false,
"program": "${workspaceRoot}/node_modules/jest-cli/bin/jest.js",
"args": ["--verbose", "--testRegex",".*", "-i", "${file}"],
"runtimeArgs": [
"--nolazy"
]
}
]
}
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
// Note; this config requires node 8.4 or higher
"type": "node",
"protocol": "auto",
"request": "launch",
"name": "debug unit test",
"stopOnEntry": false,
"program": "${workspaceRoot}/node_modules/jest-cli/bin/jest.js",
"args": ["--verbose", "-i", "${file}"],
"runtimeArgs": ["--nolazy"]
}
]
}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"javascript.validate.enable": false,
"typescript.tsdk": "node_modules/typescript/lib"
"typescript.tsdk": "node_modules/typescript/lib",
"jest.enableInlineErrorMessages": true
}
3 changes: 3 additions & 0 deletions .watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ignore_dirs": ["node_modules", "_site", "dist", "coverage"]
}
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:8.11.4

WORKDIR /app/website

EXPOSE 3000 35729
COPY ./docs /app/docs
COPY ./website /app/website
RUN yarn install

CMD ["yarn", "start"]
Loading