Skip to content
Myr

Merge pull request #68 from mweststrate/feature/reuse

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

Reuse code between es5 and proxy build

authored by Michel Weststrate · committed by GitHub · parents e70fd42, e34a548 · Browse files · 19 files+589 added−679 removed
This commit

State

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

Diff stats

19 files+589 added−679 removed

  • tests:+23 added−24 removed
  • other:+566 added−655 removed

19 files+589 added−679 removed

modified:__performance_tests__/todo.js+14 added-12 removed
modified:__tests__/base.js+12 added-11 removed
1"use strict"2import * as immerProxy from "../src/immer"3import * as immerEs5 from "../src/es5"2import produce, {setAutoFreeze, setUseProxies} from "../src"3import deepFreeze from "deep-freeze"45jest.setTimeout(1000)68runBaseTest("proxy (no freeze)", immerProxy, false)9runBaseTest("proxy (autofreeze)", immerProxy, true)10runBaseTest("es5 (no freeze)", immerEs5, false)11runBaseTest("es5 (autofreeze)", immerEs5, true)7runBaseTest("proxy (no freeze)", true, false)8runBaseTest("proxy (autofreeze)", true, true)9runBaseTest("es5 (no freeze)", false, false)10runBaseTest("es5 (autofreeze)", false, true)1113function runBaseTest(name, lib, freeze) {12function runBaseTest(name, useProxies, freeze) {13 describe(`base functionality - ${name}`, () => {15 const produce = lib.default14 let baseState15 let origBaseState1617 beforeEach(() => {20 lib.setAutoFreeze(freeze)18 setAutoFreeze(freeze)19 setUseProxies(useProxies)20 origBaseState = baseState = createBaseState()21 })2223 it("should return the original without modifications", () => {
250 unmodified lines
274 expect(nextState.aProp).toBe(undefined)275 })276277 // ES implementation does't protect against all outside modifications, just some..279 if (lib === immerProxy) {278 if (useProxies) {279 it("should revoke the proxy of the baseState after immer function is executed", () => {280 let proxy281 const nextState = produce(baseState, s => {282 proxy = s
132 unmodified lines
415 ).toEqual(["0", "1", "length"])416 })417 })418420 if (lib === immerProxy)419 if (useProxies === true) {420 it("should not be possible to set property descriptors", () => {421 expect(() => {422 debugger423 produce({}, draft => {424 Object.defineProperty(draft, "xx", {425 enumerable: true,426 writeable: true,
1 unmodified line
428 })429 })430 }).toThrowError(/not support/)431 })432 }433434 it("should not throw error, see #53 - 1", () => {435 const base = {arr: [{count: 1}, {count: 2}, {count: 3}]}436 const result = produce(base, draft => {
168 unmodified lines
modified:__tests__/curry.js+5 added-6 removed
1"use strict"2import * as immerProxy from "../src/immer"3import * as immerEs5 from "../src/es5"2import produce, {setUseProxies} from "../src/"35runTests("proxy", immerProxy)6runTests("es5", immerEs5)4runTests("proxy", true)5runTests("es5", false)68function runTests(name, lib) {7function runTests(name, useProxies) {8 describe("curry - " + name, () => {10 const produce = lib.default9 setUseProxies(useProxies)1011 it("should check arguments", () => {12 expect(() => produce()).toThrow(/produce expects 1 or 2 arguments/)13 expect(() => produce(() => {}, {})).toThrow(
26 unmodified lines
modified:__tests__/frozen.js+5 added-6 removed
1"use strict"2import * as immerProxy from "../src/immer"3import * as immerEs5 from "../src/es5"2import deepFreeze from "deep-freeze"3import produce, {setUseProxies} from "../src/"46runTests("proxy", immerProxy)7runTests("es5", immerEs5)5runTests("proxy", true)6runTests("es5", false)79function runTests(name, lib) {8function runTests(name, useProxies) {9 describe("auto freeze - " + name, () => {11 const produce = lib.default10 setUseProxies(useProxies)11 const baseState = {12 object: {a: 1},13 array: [1, 2]14 }
42 unmodified lines
modified:__tests__/readme.js+1 added-1 removed
1"use strict"2import produce from "../src/immer"2import produce from "../src/"34describe("readme example", () => {5 it("works", () => {6 const baseState = [
30 unmodified lines
added:src/common.js+33 added
modified:src/es5.js+174 added-234 removed
1"use strict"2// @ts-check34const PROXY_STATE = Symbol("immer-proxy-state") // TODO: create per closure, to avoid sharing proxies between multiple immer version4import {autoFreeze, isProxyable, isProxy, freeze, PROXY_STATE} from "./common"56let autoFreeze = true6const descriptors = {}7let states = null88/**9 * Immer takes a state, and runs a function against it.10 * That function can freely mutate the state, as it will create copies-on-write.11 * This means that the original state will stay unchanged, and once the function finishes, the modified state is returned12 *13 * @export14 * @param {any} baseState - the state to start with15 * @param {Function} producer - function that receives a proxy of the base state as first argument and which can be freely modified16 * @returns {any} a new state, or the base state if nothing was modified17 */18export default function produce(baseState, producer) {19 // curried invocation20 if (arguments.length === 1) {21 const producer = baseState22 // prettier-ignore23 if (typeof producer !== "function") throw new Error("if produce is called with 1 argument, the first argument should be a function")24 return function() {25 const args = arguments26 return produce(args[0], draft => {27 args[0] = draft // blegh!28 baseState.apply(null, args)29 })30 }9function createState(parent, proxy, base) {10 return {11 modified: false,12 hasCopy: false,13 parent,14 base,15 proxy,16 copy: undefined,17 finished: false,18 finalizing: false19 }20}2133 // prettier-ignore34 {35 if (arguments.length !== 2) throw new Error("produce expects 1 or 2 arguments, got " + arguments.length)36 if (!isProxyable(baseState)) throw new Error("the first argument to produce should be a plain object or array, got " + (typeof baseState))37 if (typeof producer !== "function") throw new Error("the second argument to produce should be a function")22function source(state) {23 return state.hasCopy ? state.copy : state.base24}2526function get(state, prop) {27 assertUnfinished(state)28 const value = source(state)[prop]29 if (!state.finalizing && !isProxy(value) && isProxyable(value)) {30 prepareCopy(state)31 return (state.copy[prop] = createProxy(state, value))32 }33 return value34}3540 let finalizing = false41 let finished = false42 const descriptors = {}43 const states = []36function set(state, prop, value) {37 assertUnfinished(state)38 if (!state.modified) {39 if (Object.is(source(state)[prop], value)) return40 markChanged(state)41 }42 prepareCopy(state)43 state.copy[prop] = value44}4545 class State {46 constructor(parent, proxy, base) {47 this.modified = false48 this.hasCopy = false49 this.parent = parent50 this.base = base51 this.proxy = proxy52 this.copy = undefined53 }46function markChanged(state) {47 if (!state.modified) {48 state.modified = true49 if (state.parent) markChanged(state.parent)50 }51}5255 get source() {56 return this.hasCopy ? this.copy : this.base57 }53function prepareCopy(state) {54 if (state.hasCopy) return55 state.hasCopy = true56 state.copy = Array.isArray(state.base)57 ? state.base.slice()58 : Object.assign({}, state.base)59}6059 get(prop) {60 assertUnfinished()61 const value = this.source[prop]62 if (!finalizing && !isProxy(value) && isProxyable(value)) {63 this.prepareCopy()64 return (this.copy[prop] = createProxy(this, value))65 }66 return value67 }61// creates a proxy for plain objects / arrays62function createProxy(parent, base) {63 let proxy64 if (Array.isArray(base)) proxy = createArrayProxy(base)65 else proxy = createObjectProxy(base)66 const state = createState(parent, proxy, base)67 createHiddenProperty(proxy, PROXY_STATE, state)68 states.push(state)69 return proxy70}7169 set(prop, value) {70 assertUnfinished()71 if (!this.modified) {72 if (Object.is(this.source[prop], value)) return73 this.markChanged()72function createPropertyProxy(prop) {73 return (74 descriptors[prop] ||75 (descriptors[prop] = {76 configurable: true,77 enumerable: true,78 get() {79 return get(this[PROXY_STATE], prop)80 },81 set(value) {82 set(this[PROXY_STATE], prop, value)83 }75 this.prepareCopy()76 this.copy[prop] = value77 }84 })85 )86}8779 markChanged() {80 if (!this.modified) {81 this.modified = true82 if (this.parent) this.parent.markChanged()83 }84 }88function createObjectProxy(base) {89 const proxy = Object.assign({}, base)90 Object.keys(base).forEach(prop =>91 Object.defineProperty(proxy, prop, createPropertyProxy(prop))92 )93 return proxy94}9586 prepareCopy() {87 if (this.hasCopy) return88 this.hasCopy = true89 this.copy = Array.isArray(this.base)90 ? this.base.slice()91 : Object.assign({}, this.base)92 }93 }96function createArrayProxy(base) {97 const proxy = new Array(base.length)98 for (let i = 0; i < base.length; i++)99 Object.defineProperty(proxy, "" + i, createPropertyProxy("" + i))100 return proxy101}10295 // creates a proxy for plain objects / arrays96 function createProxy(parent, base) {97 let proxy98 if (Array.isArray(base)) proxy = createArrayProxy(base)99 else proxy = createObjectProxy(base)100 const state = new State(parent, proxy, base)101 createHiddenProperty(proxy, PROXY_STATE, state)102 states.push(state)103 return proxy104 }105106 function createPropertyProxy(prop) {107 return (108 descriptors[prop] ||109 (descriptors[prop] = {110 configurable: true,111 enumerable: true,112 get() {113 return this[PROXY_STATE].get(prop)114 },115 set(value) {116 this[PROXY_STATE].set(prop, value)117 }118 })103function assertUnfinished(state) {104 if (state.finished === true)105 throw new Error(106 "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process?"107 )120 }108}109122 function createObjectProxy(base) {123 const proxy = Object.assign({}, base)124 Object.keys(base).forEach(prop =>125 Object.defineProperty(proxy, prop, createPropertyProxy(prop))126 )127 return proxy128 }129130 function createArrayProxy(base) {131 const proxy = new Array(base.length)132 for (let i = 0; i < base.length; i++)133 Object.defineProperty(proxy, "" + i, createPropertyProxy("" + i))134 return proxy135 }136137 function assertUnfinished() {138 if (finished)139 throw new Error(140 "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process?"141 )142 }143144 // this sounds very expensive, but actually it is not that extensive in practice145 // as it will only visit proxies, and only do key-based change detection for objects for146 // which it is not already know that they are changed (that is, only object for which no known key was changed)147 function markChanges() {148 // intentionally we process the proxies in reverse order;149 // ideally we start by processing leafs in the tree, because if a child has changed, we don't have to check the parent anymore150 // reverse order of proxy creation approximates this151 for (let i = states.length - 1; i >= 0; i--) {152 const state = states[i]153 if (state.modified === false) {154 if (Array.isArray(state.base)) {155 if (hasArrayChanges(state)) state.markChanged()156 } else if (hasObjectChanges(state)) state.markChanged()110// this sounds very expensive, but actually it is not that extensive in practice111// as it will only visit proxies, and only do key-based change detection for objects for112// which it is not already know that they are changed (that is, only object for which no known key was changed)113function markChanges() {114 // intentionally we process the proxies in reverse order;115 // ideally we start by processing leafs in the tree, because if a child has changed, we don't have to check the parent anymore116 // reverse order of proxy creation approximates this117 for (let i = states.length - 1; i >= 0; i--) {118 const state = states[i]119 if (state.modified === false) {120 if (Array.isArray(state.base)) {121 if (hasArrayChanges(state)) markChanged(state)122 } else if (hasObjectChanges(state)) markChanged(state)157 }123 }124 }125}126161 function hasObjectChanges(state) {162 const baseKeys = Object.keys(state.base)163 const keys = Object.keys(state.proxy)164 return !shallowEqual(baseKeys, keys)165 }127function hasObjectChanges(state) {128 const baseKeys = Object.keys(state.base)129 const keys = Object.keys(state.proxy)130 return !shallowEqual(baseKeys, keys)131}132167 function hasArrayChanges(state) {168 return state.proxy.length !== state.base.length169 }133function hasArrayChanges(state) {134 return state.proxy.length !== state.base.length135}136171 function finalize(proxy) {172 // TODO: almost litterally same as Proxy impl; let's reduce code duplication and rollup173 if (isProxy(proxy)) {174 const state = proxy[PROXY_STATE]175 if (state.modified === true) {176 if (Array.isArray(state.base))177 return finalizeArray(proxy, state)178 return finalizeObject(proxy, state)179 } else return state.base180 } else if (proxy !== null && typeof proxy === "object") {181 // If finalize is called on an object that was not a proxy, it means that it is an object that was not there in the original182 // tree and it could contain proxies at arbitrarily places. Let's find and finalize them as well183 if (Array.isArray(proxy)) {184 for (let i = 0; i < proxy.length; i++)185 proxy[i] = finalize(proxy[i])186 return freeze(proxy)187 }188 const proto = Object.getPrototypeOf(proxy)189 if (proto === null || proto === Object.prototype) {190 for (let key in proxy) proxy[key] = finalize(proxy[key])191 return freeze(proxy)192 }137function finalize(proxy) {138 // TODO: almost litterally same as Proxy impl; let's reduce code duplication and rollup139 if (isProxy(proxy)) {140 const state = proxy[PROXY_STATE]141 if (state.modified === true) {142 if (Array.isArray(state.base)) return finalizeArray(proxy, state)143 return finalizeObject(proxy, state)144 } else return state.base145 } else if (proxy !== null && typeof proxy === "object") {146 // If finalize is called on an object that was not a proxy, it means that it is an object that was not there in the original147 // tree and it could contain proxies at arbitrarily places. Let's find and finalize them as well148 if (Array.isArray(proxy)) {149 for (let i = 0; i < proxy.length; i++) proxy[i] = finalize(proxy[i])150 return freeze(proxy)151 }194 return proxy195 }196197 function finalizeObject(proxy, state) {198 const res = Object.assign({}, proxy)199 const base = state.base200 for (let prop in res) {201 if (proxy[prop] !== base[prop]) res[prop] = finalize(res[prop])152 const proto = Object.getPrototypeOf(proxy)153 if (proto === null || proto === Object.prototype) {154 for (let key in proxy) proxy[key] = finalize(proxy[key])155 return freeze(proxy)156 }203 return freeze(res)157 }158 return proxy159}160206 function finalizeArray(proxy, state) {207 const res = proxy.slice()208 const base = state.base209 for (let i = 0; i < res.length; i++) {210 if (res[i] !== base[i]) res[i] = finalize(res[i])211 }212 return freeze(res)161function finalizeObject(proxy, state) {162 const res = Object.assign({}, proxy)163 const base = state.base164 for (let prop in res) {165 if (proxy[prop] !== base[prop]) res[prop] = finalize(res[prop])166 }214215 // create proxy for root216 const rootClone = createProxy(undefined, baseState)217 // execute the thunk218 const maybeVoidReturn = producer(rootClone)219 //values either than undefined will trigger warning;220 !Object.is(maybeVoidReturn, undefined) &&221 console.warn(222 `Immer callback expects no return value. However ${typeof maybeVoidReturn} was returned`223 )224 // and finalize the modified proxy225 finalizing = true226 // find and mark all changes (for parts not done yet)227 markChanges()228 const res = finalize(rootClone)229 // make sure all proxies become unusable230 finished = true231 return res167 return freeze(res)168}169234function isProxy(value) {235 return !!value && !!value[PROXY_STATE]170function finalizeArray(proxy, state) {171 const res = proxy.slice()172 const base = state.base173 for (let i = 0; i < res.length; i++) {174 if (res[i] !== base[i]) res[i] = finalize(res[i])175 }176 return freeze(res)177}178238function isProxyable(value) {239 if (!value) return false240 if (typeof value !== "object") return false241 if (Array.isArray(value)) return true242 const proto = Object.getPrototypeOf(value)243 return proto === null || proto === Object.prototype244}245246function freeze(value) {247 if (autoFreeze) {248 Object.freeze(value)179export function produceEs5(baseState, producer) {180 const prevStates = states181 states = []182 try {183 // create proxy for root184 const rootClone = createProxy(undefined, baseState)185 // execute the thunk186 const maybeVoidReturn = producer(rootClone)187 //values either than undefined will trigger warning;188 !Object.is(maybeVoidReturn, undefined) &&189 console.warn(190 `Immer callback expects no return value. However ${typeof maybeVoidReturn} was returned`191 )192 // and finalize the modified proxy193 for (let i = 0; i < states.length; i++) states[i].finalizing = true194 // find and mark all changes (for parts not done yet)195 markChanges()196 const res = finalize(rootClone)197 // make sure all proxies become unusable198 for (let i = 0; i < states.length; i++) states[i].finished = true199 return res200 } finally {201 states = prevStates202 }250 return value203}204253function createHiddenProperty(target, prop, value) {254 Object.defineProperty(target, prop, {255 value: value,256 enumerable: false,257 writable: true258 })259}260205function shallowEqual(objA, objB) {206 //From: https://github.com/facebook/fbjs/blob/c69904a511b900266935168223063dd8772dfc40/packages/fbjs/src/core/shallowEqual.js207 if (Object.is(objA, objB)) return true208 if (
17 unmodified lines
226 }227 return true228}229286/**287 * Automatically freezes any state trees generated by immer.288 * This protects against accidental modifications of the state tree outside of an immer function.289 * This comes with a performance impact, so it is recommended to disable this option in production.290 * It is by default enabled.291 *292 * @returns {void}293 */294export function setAutoFreeze(enableAutoFreeze) {295 autoFreeze = enableAutoFreeze230function createHiddenProperty(target, prop, value) {231 Object.defineProperty(target, prop, {232 value: value,233 enumerable: false,234 writable: true235 })236}
deleted:src/immer.js-287 removed
1"use strict"2// @ts-check34if (typeof Proxy === "undefined")5 throw new Error(6 "Immer requires `Proxy` to be available, but it seems to be not available on your platform. Consider requiring immer '\"immer/es5\"' instead."7 )89const PROXY_STATE = Symbol("immer-proxy-state")10let autoFreeze = true1112const objectTraps = {13 get(target, prop) {14 if (prop === PROXY_STATE) return target15 return target.get(prop)16 },17 has(target, prop) {18 return prop in target.source19 },20 ownKeys(target) {21 return Reflect.ownKeys(target.source)22 },23 set(target, prop, value) {24 target.set(prop, value)25 return true26 },27 deleteProperty(target, prop) {28 target.deleteProp(prop)29 return true30 },31 getOwnPropertyDescriptor(target, prop) {32 return target.getOwnPropertyDescriptor(prop)33 },34 defineProperty(target, property, descriptor) {35 target.defineProperty(property, descriptor)36 },37 setPrototypeOf() {38 throw new Error("Don't even try this...")39 }40}4142const arrayTraps = {43 get(target, prop) {44 if (prop === PROXY_STATE) return target[0]45 return target[0].get(prop)46 },47 has(target, prop) {48 return prop === PROXY_STATE || prop in target[0].source49 },50 ownKeys(target) {51 return Reflect.ownKeys(target[0].source)52 },53 set(target, prop, value) {54 target[0].set(prop, value)55 return true56 },57 deleteProperty(target, prop) {58 target[0].deleteProp(prop)59 return true60 },61 getOwnPropertyDescriptor(target, prop) {62 return target[0].getOwnPropertyDescriptor(prop)63 },64 defineProperty(target, property, descriptor) {65 target[0].defineProperty(property, descriptor)66 },67 setPrototypeOf() {68 throw new Error("Don't even try this...")69 }70}7172/**73 * produce takes a state, and runs a function against it.74 * That function can freely mutate the state, as it will create copies-on-write.75 * This means that the original state will stay unchanged, and once the function finishes, the modified state is returned76 *77 * @export78 * @param {any} baseState - the state to start with79 * @param {Function} producer - function that receives a proxy of the base state as first argument and which can be freely modified80 * @returns {any} a new state, or the base state if nothing was modified81 */82export default function produce(baseState, producer) {83 // curried invocation84 if (arguments.length === 1) {85 const producer = baseState86 // prettier-ignore87 if (typeof producer !== "function") throw new Error("if produce is called with 1 argument, the first argument should be a function")88 return function() {89 const args = arguments90 return produce(args[0], draft => {91 args[0] = draft // blegh!92 baseState.apply(null, args)93 })94 }95 }9697 // prettier-ignore98 {99 if (arguments.length !== 2) throw new Error("produce expects 1 or 2 arguments, got " + arguments.length)100 if (!isProxyable(baseState)) throw new Error("the first argument to produce should be a plain object or array, got " + (typeof baseState))101 if (typeof producer !== "function") throw new Error("the second argument to produce should be a function")102 }103 const revocableProxies = []104105 class State {106 constructor(parent, base) {107 this.modified = false108 this.finalized = false109 this.parent = parent110 this.base = base111 this.copy = undefined112 this.proxies = {}113 }114115 get source() {116 return this.modified === true ? this.copy : this.base117 }118119 get(prop) {120 if (this.modified) {121 const value = this.copy[prop]122 if (!isProxy(value) && isProxyable(value))123 return (this.copy[prop] = createProxy(this, value))124 return value125 } else {126 if (prop in this.proxies) return this.proxies[prop]127 const value = this.base[prop]128 if (!isProxy(value) && isProxyable(value))129 return (this.proxies[prop] = createProxy(this, value))130 return value131 }132 }133134 set(prop, value) {135 if (!this.modified) {136 if (137 (prop in this.base && Object.is(this.base[prop], value)) ||138 (prop in this.proxies && this.proxies[prop] === value)139 )140 return141 this.markChanged()142 }143 this.copy[prop] = value144 }145146 deleteProp(prop) {147 this.markChanged()148 delete this.copy[prop]149 }150151 getOwnPropertyDescriptor(prop) {152 const owner = this.modified153 ? this.copy154 : prop in this.proxies ? this.proxies : this.base155 const descriptor = Reflect.getOwnPropertyDescriptor(owner, prop)156 if (descriptor && !(Array.isArray(owner) && prop === "length"))157 descriptor.configurable = true158 return descriptor159 }160161 defineProperty(property, descriptor) {162 throw new Error(163 "Immer does currently not support defining properties on draft objects"164 )165 }166167 markChanged() {168 if (!this.modified) {169 this.modified = true170 this.copy = Array.isArray(this.base)171 ? this.base.slice()172 : Object.assign({}, this.base) // TODO: eliminate those isArray checks?173 Object.assign(this.copy, this.proxies) // yup that works for arrays as well174 if (this.parent) this.parent.markChanged()175 }176 }177 }178179 // creates a proxy for plain objects / arrays180 function createProxy(parentState, base) {181 const state = new State(parentState, base)182 let proxy183 if (Array.isArray(base)) {184 proxy = Proxy.revocable([state], arrayTraps)185 } else {186 proxy = Proxy.revocable(state, objectTraps)187 }188 revocableProxies.push(proxy)189 return proxy.proxy190 }191192 // given a base object, returns it if unmodified, or return the changed cloned if modified193 function finalize(base) {194 if (isProxy(base)) {195 const state = base[PROXY_STATE]196 if (state.modified === true) {197 if (state.finalized === true) return state.copy198 state.finalized = true199 if (Array.isArray(state.base)) return finalizeArray(state)200 return finalizeObject(state)201 } else return state.base202 } else if (base !== null && typeof base === "object") {203 // If finalize is called on an object that was not a proxy, it means that it is an object that was not there in the original204 // tree and it could contain proxies at arbitrarily places. Let's find and finalize them as well205 // TODO: optimize this; walk the tree without writing to find proxies206 if (Array.isArray(base)) {207 for (let i = 0; i < base.length; i++)208 base[i] = finalize(base[i])209 return freeze(base)210 }211 const proto = Object.getPrototypeOf(base)212 if (proto === null || proto === Object.prototype) {213 for (let key in base) base[key] = finalize(base[key])214 return freeze(base)215 }216 }217 return base218 }219220 function finalizeObject(state) {221 const copy = state.copy222 const base = state.base223 for (var prop in copy) {224 if (copy[prop] !== base[prop]) copy[prop] = finalize(copy[prop])225 }226 return freeze(copy)227 }228229 function finalizeArray(state) {230 const copy = state.copy231 const base = state.base232 for (let i = 0; i < copy.length; i++) {233 if (copy[i] !== base[i]) copy[i] = finalize(copy[i])234 }235 return freeze(copy)236 }237238 // create proxy for root239 const rootClone = createProxy(undefined, baseState)240 // execute the thunk241 const maybeVoidReturn = producer(rootClone)242 //values either than undefined will trigger warning;243 !Object.is(maybeVoidReturn, undefined) &&244 console.warn(245 `Immer callback expects no return value. However ${typeof maybeVoidReturn} was returned`246 )247 // and finalize the modified proxy248 const res = finalize(rootClone)249 // revoke all proxies250 revocableProxies.forEach(p => p.revoke())251 return res252}253254function isProxy(value) {255 return !!value && !!value[PROXY_STATE]256}257258function isProxyable(value) {259 if (!value) return false260 if (typeof value !== "object") return false261 if (Array.isArray(value)) return true262 const proto = Object.getPrototypeOf(value)263 return proto === null || proto === Object.prototype264}265266function freeze(value) {267 // short circuit to achieve 100% code coverage instead of 98%268 /*269 if(autoFreeze) {270 Object.freeze(value)271 }272 * */273 autoFreeze && Object.freeze(value)274 return value275}276277/**278 * Automatically freezes any state trees generated by immer.279 * This protects against accidental modifications of the state tree outside of an immer function.280 * This comes with a performance impact, so it is recommended to disable this option in production.281 * It is by default enabled.282 *283 * @returns {void}284 */285export function setAutoFreeze(enableAutoFreeze) {286 autoFreeze = enableAutoFreeze287}
modified:src/index.js+48 added-2 removed
1module.exports =2 typeof Proxy === "undefined" ? require("./es5") : require("./immer")1export {setAutoFreeze} from "./common"23import {isProxyable} from "./common"4import {produceProxy} from "./proxy"5import {produceEs5} from "./es5"67let useProxies = typeof Proxy !== "undefined"89/**10 * produce takes a state, and runs a function against it.11 * That function can freely mutate the state, as it will create copies-on-write.12 * This means that the original state will stay unchanged, and once the function finishes, the modified state is returned13 *14 * @export15 * @param {any} baseState - the state to start with16 * @param {Function} producer - function that receives a proxy of the base state as first argument and which can be freely modified17 * @returns {any} a new state, or the base state if nothing was modified18 */19export default function produce(baseState, producer) {20 // curried invocation21 if (arguments.length === 1) {22 const producer = baseState23 // prettier-ignore24 if (typeof producer !== "function") throw new Error("if produce is called with 1 argument, the first argument should be a function")25 return function() {26 const args = arguments27 return produce(args[0], draft => {28 args[0] = draft // blegh!29 baseState.apply(null, args)30 })31 }32 }3334 // prettier-ignore35 {36 if (arguments.length !== 2) throw new Error("produce expects 1 or 2 arguments, got " + arguments.length)37 if (!isProxyable(baseState)) throw new Error("the first argument to produce should be a plain object or array, got " + (typeof baseState))38 if (typeof producer !== "function") throw new Error("the second argument to produce should be a function")39 }4041 return useProxies42 ? produceProxy(baseState, producer)43 : produceEs5(baseState, producer)44}4546export function setUseProxies(value) {47 useProxies = value48}
added:src/proxy.js+189 added
1"use strict"2// @ts-check34import {autoFreeze, isProxyable, isProxy, freeze, PROXY_STATE} from "./common"56let revocableProxies = null78const objectTraps = {9 get,10 has(target, prop) {11 return prop in source(target)12 },13 ownKeys(target) {14 return Reflect.ownKeys(source(target))15 },16 set,17 deleteProperty,18 getOwnPropertyDescriptor,19 defineProperty,20 setPrototypeOf() {21 throw new Error("Don't even try this...")22 }23}2425const arrayTraps = {}26for (let key in objectTraps) {27 arrayTraps[key] = function() {28 arguments[0] = arguments[0][0]29 return objectTraps[key].apply(this, arguments)30 }31}3233function createState(parent, base) {34 return {35 modified: false,36 finalized: false,37 parent,38 base,39 copy: undefined,40 proxies: {}41 }42}4344function source(state) {45 return state.modified === true ? state.copy : state.base46}4748function get(state, prop) {49 if (prop === PROXY_STATE) return state50 if (state.modified) {51 const value = state.copy[prop]52 if (!isProxy(value) && isProxyable(value))53 return (state.copy[prop] = createProxy(state, value))54 return value55 } else {56 if (prop in state.proxies) return state.proxies[prop]57 const value = state.base[prop]58 if (!isProxy(value) && isProxyable(value))59 return (state.proxies[prop] = createProxy(state, value))60 return value61 }62}6364function set(state, prop, value) {65 if (!state.modified) {66 if (67 (prop in state.base && Object.is(state.base[prop], value)) ||68 (prop in state.proxies && state.proxies[prop] === value)69 )70 return true71 markChanged(state)72 }73 state.copy[prop] = value74 return true75}7677function deleteProperty(state, prop) {78 markChanged(state)79 delete state.copy[prop]80 return true81}8283function getOwnPropertyDescriptor(state, prop) {84 const owner = state.modified85 ? state.copy86 : prop in state.proxies ? state.proxies : state.base87 const descriptor = Reflect.getOwnPropertyDescriptor(owner, prop)88 if (descriptor && !(Array.isArray(owner) && prop === "length"))89 descriptor.configurable = true90 return descriptor91}9293function defineProperty() {94 throw new Error(95 "Immer does currently not support defining properties on draft objects"96 )97}9899function markChanged(state) {100 if (!state.modified) {101 state.modified = true102 state.copy = Array.isArray(state.base)103 ? state.base.slice()104 : Object.assign({}, state.base) // TODO: eliminate those isArray checks?105 Object.assign(state.copy, state.proxies) // yup that works for arrays as well106 if (state.parent) markChanged(state.parent)107 }108}109110// creates a proxy for plain objects / arrays111function createProxy(parentState, base) {112 const state = createState(parentState, base)113 let proxy114 if (Array.isArray(base)) {115 proxy = Proxy.revocable([state], arrayTraps)116 } else {117 proxy = Proxy.revocable(state, objectTraps)118 }119 revocableProxies.push(proxy)120 return proxy.proxy121}122123// given a base object, returns it if unmodified, or return the changed cloned if modified124function finalize(base) {125 if (isProxy(base)) {126 const state = base[PROXY_STATE]127 if (state.modified === true) {128 if (state.finalized === true) return state.copy129 state.finalized = true130 if (Array.isArray(state.base)) return finalizeArray(state)131 return finalizeObject(state)132 } else return state.base133 } else if (base !== null && typeof base === "object") {134 // If finalize is called on an object that was not a proxy, it means that it is an object that was not there in the original135 // tree and it could contain proxies at arbitrarily places. Let's find and finalize them as well136 // TODO: optimize this; walk the tree without writing to find proxies137 if (Array.isArray(base)) {138 for (let i = 0; i < base.length; i++) base[i] = finalize(base[i])139 return freeze(base)140 }141 const proto = Object.getPrototypeOf(base)142 if (proto === null || proto === Object.prototype) {143 for (let key in base) base[key] = finalize(base[key])144 return freeze(base)145 }146 }147 return base148}149150function finalizeObject(state) {151 const copy = state.copy152 const base = state.base153 for (var prop in copy) {154 if (copy[prop] !== base[prop]) copy[prop] = finalize(copy[prop])155 }156 return freeze(copy)157}158159function finalizeArray(state) {160 const copy = state.copy161 const base = state.base162 for (let i = 0; i < copy.length; i++) {163 if (copy[i] !== base[i]) copy[i] = finalize(copy[i])164 }165 return freeze(copy)166}167168export function produceProxy(baseState, producer) {169 const previousProxies = revocableProxies170 revocableProxies = []171 try {172 // create proxy for root173 const rootClone = createProxy(undefined, baseState)174 // execute the thunk175 const maybeVoidReturn = producer(rootClone)176 //values either than undefined will trigger warning;177 !Object.is(maybeVoidReturn, undefined) &&178 console.warn(179 `Immer callback expects no return value. However ${typeof maybeVoidReturn} was returned`180 )181 // and finalize the modified proxy182 const res = finalize(rootClone)183 // revoke all proxies184 revocableProxies.forEach(p => p.revoke())185 return res186 } finally {187 revocableProxies = previousProxies188 }189}
modified:.gitignore-1 removed
57 unmodified lines
58.env5960.idea61dist/62proxy.js
modified:changelog.md+6 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 checks12
69 unmodified lines
deleted:es5.js-1 removed
1module.exports = require("./dist/es5.js")
added:immer.d.ts+37 added
1/**2 * Immer takes a state, and runs a function against it.3 * That function can freely mutate the state, as it will create copies-on-write.4 * This means that the original state will stay unchanged, and once the function finishes, the modified state is returned5 *6 * If only one argument is passed, this is interpreted as the recipe, and will create a curried function that will execute the recipe7 * any time it is called with a base state8 *9 * @param currentState - the state to start with10 * @param thunk - function that receives a proxy of the current state as first argument and which can be freely modified11 * @returns The next state: a new state, or the current state if nothing was modified12 */13export default function<S = any>(14 currentState: S,15 recipe: (draftState: S) => void16): S17// curried invocations18export default function<S = any, A = any, B = any, C = any>(19 recipe: (draftState: S, a: A, b: B, c: C) => void20): (currentState: S, a: A, b: B, c: C) => S21export default function<S = any, A = any, B = any>(22 recipe: (draftState: S, a: A, b: B) => void23): (currentState: S, a: A, b: B) => S24export default function<S = any, A = any>(25 recipe: (draftState: S, a: A) => void26): (currentState: S) => S27export default function<S = any>(28 recipe: (draftState: S, ...extraArgs: any[]) => void29): (currentState: S, ...extraArgs: any[]) => S3031/**32 * Automatically freezes any state trees generated by immer.33 * This protects against accidental modifications of the state tree outside of an immer function.34 * This comes with a performance impact, so it is recommended to disable this option in production.35 * It is by default enabled.36 */37export function setAutoFreeze(autoFreeze: boolean): void
deleted:index.d.ts-37 removed
1/**2 * Immer takes a state, and runs a function against it.3 * That function can freely mutate the state, as it will create copies-on-write.4 * This means that the original state will stay unchanged, and once the function finishes, the modified state is returned5 *6 * If only one argument is passed, this is interpreted as the recipe, and will create a curried function that will execute the recipe7 * any time it is called with a base state8 *9 * @param currentState - the state to start with10 * @param thunk - function that receives a proxy of the current state as first argument and which can be freely modified11 * @returns The next state: a new state, or the current state if nothing was modified12 */13export default function<S = any>(14 currentState: S,15 recipe: (draftState: S) => void16): S17// curried invocations18export default function<S = any, A = any, B = any, C = any>(19 recipe: (draftState: S, a: A, b: B, c: C) => void20): (currentState: S, a: A, b: B, c: C) => S21export default function<S = any, A = any, B = any>(22 recipe: (draftState: S, a: A, b: B) => void23): (currentState: S, a: A, b: B) => S24export default function<S = any, A = any>(25 recipe: (draftState: S, a: A) => void26): (currentState: S) => S27export default function<S = any>(28 recipe: (draftState: S, ...extraArgs: any[]) => void29): (currentState: S, ...extraArgs: any[]) => S3031/**32 * Automatically freezes any state trees generated by immer.33 * This protects against accidental modifications of the state tree outside of an immer function.34 * This comes with a performance impact, so it is recommended to disable this option in production.35 * It is by default enabled.36 */37export function setAutoFreeze(autoFreeze: boolean): void
modified:package.json+9 added-6 removed
1{2 "name": "immer",3 "version": "0.7.0",4 "description": "Create your next immutable state by mutating the current one",5 "main": "dist/index.js",6 "types": "./index.d.ts",5 "main": "dist/immer.js",6 "umd:main": "dist/immer.umd.js",7 "module": "dist/immer.module.js",8 "jsnext:main": "dist/immer.module.js",9 "react-native": "dist/immer.module.js",10 "types": "./immer.d.ts",11 "scripts": {12 "test": "jest",9 "test:perf": "yarn build:babel && node --expose-gc node_modules/jest-cli/bin/jest.js --verbose --testRegex '__performance_tests__/.*'",13 "test:perf": "yarn build && node --expose-gc node_modules/jest-cli/bin/jest.js --verbose --testRegex '__performance_tests__/.*'",14 "coveralls": "jest --coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",15 "build": "rimraf dist/ && cross-env NODE_ENV=production rollup -c",16 "prettier": "prettier \"*/**/*.js\" --ignore-path ./.prettierignore --write",17 "prepublish": "yarn build"
16 unmodified lines
34 "url": "https://github.com/mweststrate/immer/issues"35 },36 "homepage": "https://github.com/mweststrate/immer#readme",37 "files": [34 "es5.js",35 "proxy.js",38 "index.d.ts",39 "dist/"40 ],41 "devDependencies": {42 "@types/jest": "^22.0.0",43 "babel-cli": "^6.26.0",44 "babel-core": "^6.26.0",45 "babel-jest": "^22.0.4",46 "babel-plugin-external-helpers": "^6.22.0",47 "babel-preset-env": "^1.6.1",48 "babel-preset-es2015": "^6.24.1",49 "babel-preset-modern-browsers": "^10.0.1",50 "coveralls": "^3.0.0",
6 unmodified lines
57 "prettier": "^1.9.2",58 "regenerator-runtime": "^0.11.1",59 "rimraf": "^2.6.2",60 "rollup": "^0.54.0",58 "rollup-plugin-buble": "^0.18.0",61 "rollup-plugin-babel": "^3.0.3",62 "rollup-plugin-commonjs": "^8.2.6",63 "rollup-plugin-filesize": "^1.5.0",64 "rollup-plugin-node-resolve": "^3.0.2",65 "rollup-plugin-uglify": "^2.0.1",
9 unmodified lines
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+28 added-27 removed
1import {minify} from "uglify-es"2import buble from "rollup-plugin-buble"2import commonjs from "rollup-plugin-commonjs"3import filesize from "rollup-plugin-filesize"4import resolve from "rollup-plugin-node-resolve"5import uglify from "rollup-plugin-uglify"6import babel from "rollup-plugin-babel"78function getFileName(file, format) {9 if (format === "umd") {10 return `dist/${file}.umd.js`11 }1213 return `dist/${file}.js`14}1516function getConfig(input, file, format) {8function getConfig(dest, format, ugly) {9 const conf = {18 input,10 input: "src/index.js",11 output: {12 exports: "named",21 file: getFileName(file, format),13 file: dest,14 format,15 name: "immer",16 sourcemap: true17 },
1 unmodified line
19 resolve({20 jsnext: true21 }),22 commonjs(),31 buble(),32 uglify({}, minify),23 babel({24 babelrc: false,25 presets: [26 [27 "env",28 {29 modules: false30 }31 ]32 ],33 plugins: ["external-helpers"]34 }),35 ugly &&36 uglify(37 {38 warnings: true,39 toplevel: true40 },41 minify42 ),43 filesize()34 ]44 ].filter(Boolean)45 }4647 return conf48}4950const config = [41 getConfig("src/es5.js", "es5", "cjs"),42 getConfig("src/es5.js", "es5", "umd"),43 getConfig("src/immer.js", "immer", "cjs"),44 getConfig("src/immer.js", "immer", "umd"),45 {46 input: "src/index.js",47 output: {48 file: "dist/index.js",49 format: "cjs"50 },51 plugins: [uglify({}, minify), filesize()]52 }51 getConfig("dist/immer.js", "cjs", false),52 getConfig("dist/immer.umd.js", "umd", true),53 getConfig("dist/immer.module.js", "es", false)54]5556export default config
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