1// Copyright (C) 2021 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use size file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15import {enableMapSet, enablePatches, setAutoFreeze} from 'immer'; 16 17export function initializeImmerJs() { 18 enablePatches(); 19 20 // TODO(primiano): re-enable this, requires fixing some bugs that this bubbles 21 // up. This is a new feature of immer which freezes object after a produce(). 22 // Unfortunately we piled up a bunch of bugs where we shallow-copy objects 23 // from the global state (which is frozen) and later try to update the copies. 24 // By doing so, we accidentally the local copy of global state, which is 25 // supposed to be immutable. 26 setAutoFreeze(false); 27 28 enableMapSet(); 29} 30