Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Immer 10 #1028

Merged
merged 52 commits into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
503b4be
Do not replace array.length
Jul 31, 2022
31e61bf
feat: implement useStrictShallowCopy
May 18, 2022
de9569f
breaking change: Change useStrictShallowCopy to enabled by default
hrsh7th Jan 29, 2023
a9bc548
doc: Add setUseStrictShallowCopy to api.md
hrsh7th Jan 29, 2023
ecbe989
Remove promise based producer support #1015
mweststrate Jan 30, 2023
eb5ac78
Remove ES5 support WIP
mweststrate Jan 30, 2023
4df7e24
Merged ProxyType and ArchType
mweststrate Jan 30, 2023
3c199a3
Add todo comment
hrsh7th Feb 15, 2023
3819609
Change comment
hrsh7th Feb 15, 2023
99efdef
Improve documents
hrsh7th Feb 15, 2023
3cabd7b
Fix flowtype doc comment
hrsh7th Feb 15, 2023
da3de76
Fix test case comment
hrsh7th Feb 15, 2023
59971e1
[breaking] Remove `export default produce`
mweststrate Mar 23, 2023
ec72486
chore: Merge branch 'main' into immer-10
mweststrate Mar 23, 2023
cb5712a
[breaking] Merge branch 'array-remove' of github.com:kshramt/immer in…
mweststrate Mar 23, 2023
d5aba94
breaking: Emit remove instead of length replace patches when removing…
mweststrate Mar 23, 2023
07242c5
random bits of cleanup
mweststrate Mar 23, 2023
e69c766
Remove `enableAllPlugins` from API
mweststrate Mar 23, 2023
5540249
Enable Map / Set support by default
mweststrate Mar 23, 2023
7c055e7
Cleaned up production error snapshots
mweststrate Mar 23, 2023
6e9032b
chore: Upgraded to TS 5
mweststrate Mar 24, 2023
d533f24
Add large object perf test (from #941)
mweststrate Mar 24, 2023
e71aebd
feat: Introduce strictShallowCopy, See #941, hrsh7th-use-strict-shall…
mweststrate Mar 24, 2023
8195782
Fix performance tests
mweststrate Mar 24, 2023
a869118
cleanup current implementation
mweststrate Mar 24, 2023
1d93079
minor cleanup
mweststrate Mar 24, 2023
452a508
stored errors as array so that they become smaller and part of plugin
mweststrate Mar 24, 2023
a1fd163
Map / Set & old browser API cleanup
mweststrate Mar 24, 2023
27db1a1
Further simplification / optimization
mweststrate Mar 24, 2023
86fd429
some build stuff cleanup
mweststrate Mar 25, 2023
1690a55
Attempt at using ESM
mweststrate Mar 25, 2023
998b69d
More Jest/ESM fixes
mweststrate Mar 25, 2023
af92b4d
Fix prod tests
mweststrate Mar 25, 2023
5cbfc0f
fixed lockfile
mweststrate Mar 25, 2023
605ed40
Fix test:perf ESM
mweststrate Mar 26, 2023
df3bbe2
Some doc refinements
mweststrate Apr 3, 2023
bbd7fb2
Dropped module:type per https://github.com/immerjs/immer/issues/992#i…
mweststrate Apr 3, 2023
c8e7cf0
v10.0.0-beta.2
mweststrate Apr 3, 2023
6f501e6
v10.0.0-beta.3
mweststrate Apr 3, 2023
05b85f7
v10.0.0-beta.4
mweststrate Apr 3, 2023
931f963
Fixed build once again
mweststrate Apr 5, 2023
aa0e5ee
attempt2
mweststrate Apr 5, 2023
906b69b
Revert MapSet as plugin
mweststrate Apr 5, 2023
48204c9
fix issue where deleting non-existing properties fails
mweststrate Apr 6, 2023
3c1a668
Add tsup
markerikson Apr 10, 2023
17cfe4e
Output modern JS syntax
markerikson Apr 10, 2023
3ad1df5
Use tsup to build and modernize build artifacts
markerikson Apr 10, 2023
d897c6b
Micro-optimize Object.getPrototypeOf uses
markerikson Apr 10, 2023
d5be8f2
Remove tsdx
markerikson Apr 10, 2023
46cd1d5
Minor build fixes after tsup migration
mweststrate Apr 15, 2023
6f2a12b
Merge branch 'markerikson-feature/build-tsup' into immer-10
mweststrate Apr 15, 2023
41ebbbc
Restore mangleProps
mweststrate Apr 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
run: yarn test
- name: coverage test
run: yarn jest --coverage
- name: perf test
run: yarn test:perf
- uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
"use strict"

import {measure} from "./measure"
import produce, {
setAutoFreeze,
setUseProxies,
enableAllPlugins
} from "../dist/immer.cjs.production.min.js"
import {measure} from "./measure.mjs"
import {produce, setAutoFreeze} from "../dist/immer.mjs"
import cloneDeep from "lodash.clonedeep"
import {fromJS} from "immutable"
import immutable from "immutable"
const {fromJS} = immutable
import Seamless from "seamless-immutable"
import deepFreeze from "deep-freeze"

enableAllPlugins()

console.log("\n# add-data - loading large set of data\n")

const dataSet = require("./data.json")
import dataSet from "./data.json" assert { type: "json" }

const baseState = {
data: null
}
Expand Down Expand Up @@ -78,35 +74,15 @@ measure("seamless-immutable + asMutable", () => {
seamlessBaseState.set("data", dataSet).asMutable({deep: true})
})

measure("immer (proxy) - without autofreeze * " + MAX, () => {
setUseProxies(true)
setAutoFreeze(false)
for (let i = 0; i < MAX; i++)
produce(baseState, draft => {
draft.data = dataSet
})
})

measure("immer (proxy) - with autofreeze * " + MAX, () => {
setUseProxies(true)
setAutoFreeze(true)
for (let i = 0; i < MAX; i++)
produce(frozenBazeState, draft => {
draft.data = dataSet
})
})

measure("immer (es5) - without autofreeze * " + MAX, () => {
setUseProxies(false)
measure("immer - without autofreeze * " + MAX, () => {
setAutoFreeze(false)
for (let i = 0; i < MAX; i++)
produce(baseState, draft => {
draft.data = dataSet
})
})

measure("immer (es5) - with autofreeze * " + MAX, () => {
setUseProxies(false)
measure("immer - with autofreeze * " + MAX, () => {
setAutoFreeze(true)
for (let i = 0; i < MAX; i++)
produce(frozenBazeState, draft => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
"use strict"
import {measure} from "./measure"
import produce, {
setAutoFreeze,
setUseProxies,
enableAllPlugins
} from "../dist/immer.cjs.production.min.js"
import {measure} from "./measure.mjs"
import {produce, setAutoFreeze} from "../dist/immer.mjs"
import cloneDeep from "lodash.clonedeep"
import * as Immutable from "immutable"

enableAllPlugins()
import Immutable from "immutable"

console.log("\n# incremental - lot of small incremental changes\n")

Expand Down Expand Up @@ -73,26 +67,8 @@ measure(
)

measure(
"immer (proxy)",
() => {
setUseProxies(true)
setAutoFreeze(false)
return baseState
},
state => {
for (let i = 0; i < MAX; i++) {
state = produce(state, draft => {
draft.ids.push(i)
draft.map[i] = createTestObject()
})
}
}
)

measure(
"immer (es5)",
"immer",
() => {
setUseProxies(false)
setAutoFreeze(false)
return baseState
},
Expand All @@ -107,26 +83,8 @@ measure(
)

measure(
"immer (proxy) - single produce",
() => {
setUseProxies(true)
setAutoFreeze(false)
return baseState
},
state => {
produce(state, draft => {
for (let i = 0; i < MAX; i++) {
draft.ids.push(i)
draft.map[i] = createTestObject()
}
})
}
)

measure(
"immer (es5) - single produce",
"immer - single produce",
() => {
setUseProxies(false)
setAutoFreeze(false)
return baseState
},
Expand Down
35 changes: 35 additions & 0 deletions __performance_tests__/large-obj.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {measure} from "./measure.mjs"
import {
produce,
setUseStrictShallowCopy
} from "../dist/immer.mjs"

console.log("\n# large-obj - mutate large object\n")

const MAX = 50

const baseState = Object.fromEntries(
Array(10000)
.fill(0)
.map((_, i) => [i, i])
)

measure("immer - with setUseStrictShallowCopy", () => {
setUseStrictShallowCopy(true)

for (let i = 0; i < MAX; i++) {
produce(baseState, draft => {
draft[5000]++
})
}
})

measure("immer - without setUseStrictShallowCopy", () => {
setUseStrictShallowCopy(false)

for (let i = 0; i < MAX; i++) {
produce(baseState, draft => {
draft[5000]++
})
}
})
File renamed without changes.
98 changes: 14 additions & 84 deletions __performance_tests__/todo.js → __performance_tests__/todo.mjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
"use strict"

import {measure} from "./measure"
import produce, {
setAutoFreeze,
setUseProxies,
enableAllPlugins
} from "../dist/immer.cjs.production.min.js"
import {measure} from "./measure.mjs"
import {
enablePatches,
produce,
setAutoFreeze
} from "../dist/immer.mjs"
import cloneDeep from "lodash.clonedeep"
import {List, Record} from "immutable"
import immutable from "immutable"
import Seamless from "seamless-immutable"
import deepFreeze from "deep-freeze"

enableAllPlugins()
const {List, Record} = immutable

function freeze(x) {
Object.freeze(x)
Expand Down Expand Up @@ -170,9 +170,8 @@ measure("seamless-immutable + asMutable", () => {
})

measure(
"immer (proxy) - without autofreeze",
"immer - without autofreeze",
() => {
setUseProxies(true)
setAutoFreeze(false)
},
() => {
Expand All @@ -185,9 +184,8 @@ measure(
)

measure(
"immer (proxy) - with autofreeze",
"immer - with autofreeze",
() => {
setUseProxies(true)
setAutoFreeze(true)
},
() => {
Expand All @@ -200,9 +198,9 @@ measure(
)

measure(
"immer (proxy) - without autofreeze - with patch listener",
"immer - without autofreeze - with patch listener",
() => {
setUseProxies(true)
enablePatches()
setAutoFreeze(false)
},
() => {
Expand All @@ -219,77 +217,9 @@ measure(
)

measure(
"immer (proxy) - with autofreeze - with patch listener",
"immer - with autofreeze - with patch listener",
() => {
setUseProxies(true)
setAutoFreeze(true)
},
() => {
produce(
baseState,
draft => {
for (let i = 0; i < MAX * MODIFY_FACTOR; i++) {
draft[i].done = true
}
},
function() {}
)
}
)

measure(
"immer (es5) - without autofreeze",
() => {
setUseProxies(false)
setAutoFreeze(false)
},
() => {
produce(baseState, draft => {
for (let i = 0; i < MAX * MODIFY_FACTOR; i++) {
draft[i].done = true
}
})
}
)

measure(
"immer (es5) - with autofreeze",
() => {
setUseProxies(false)
setAutoFreeze(true)
},
() => {
produce(frozenBazeState, draft => {
for (let i = 0; i < MAX * MODIFY_FACTOR; i++) {
draft[i].done = true
}
})
}
)

measure(
"immer (es5) - without autofreeze - with patch listener",
() => {
setUseProxies(false)
setAutoFreeze(false)
},
() => {
produce(
baseState,
draft => {
for (let i = 0; i < MAX * MODIFY_FACTOR; i++) {
draft[i].done = true
}
},
function() {}
)
}
)

measure(
"immer (es5) - with autofreeze - with patch listener",
() => {
setUseProxies(false)
enablePatches()
setAutoFreeze(true)
},
() => {
Expand Down
Loading