rtfeldman / seamless-immutable

Immutable data structures for JavaScript which are backwards-compatible with normal JS Arrays and Objects.
BSD 3-Clause "New" or "Revised" License
5.37k stars 195 forks source link

code minified for production is getting error `merge is not a function` #221

Open tsdexter opened 7 years ago

tsdexter commented 7 years ago

I have code like this:

import Immutable from 'seamless-immutable';

export const initialState = Immutable({
  sidebarOpened: false,
  isMobile: false
})

export default function layout (state = initialState, action) {
  switch (action.type) {
    case commonTypes.APP_INIT:
      {
        let isMobile = false
        if(!SERVER){
          let { innerWidth } = window
          isMobile = innerWidth < 1025 // 1024px - is the main breakpoint in ui
        }
        return state.merge({
          isMobile: isMobile
        })
      }
    default: return state
    }
  }
}

it works fine in development but when I bundle/build for production I get the following error - not sure why - any ideas?

Uncaught TypeError: e.merge is not a function
    at r (browser.b704458….js:1)
    at vendor.d1edc2b….js:1
    at f (vendor.d1edc2b….js:1)
    at r (vendor.d1edc2b….js:1)
    at vendor.d1edc2b….js:1
    at r (vendor.d1edc2b….js:1)
    at r (browser.b704458….js:1)
    at Object.<anonymous> (browser.b704458….js:1)
    at Object.TBTs (browser.b704458….js:1)
    at r (manifest.d41d8cd….js:1)
r @ browser.b704458….js:1
(anonymous) @ vendor.d1edc2b….js:1
f @ vendor.d1edc2b….js:1
r @ vendor.d1edc2b….js:1
(anonymous) @ vendor.d1edc2b….js:1
r @ vendor.d1edc2b….js:1
r @ browser.b704458….js:1
(anonymous) @ browser.b704458….js:1
TBTs @ browser.b704458….js:1
r @ manifest.d41d8cd….js:1
0 @ browser.b704458….js:1
r @ manifest.d41d8cd….js:1
window.webpackJsonp @ manifest.d41d8cd….js:1
(anonymous) @ browser.b704458….js:1

which is triggered here:

function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:s;switch(arguments[1].type){case i.a:var t=!1;return t=1025>window.innerWidth,e.merge({isMobile:t});
tsdexter commented 7 years ago

@rtfeldman any idea what might be going on here? Here is some more info from dev tools... looks to me like e is definitely a function... not sure how to debug it further?

https://www.dropbox.com/s/4nwxd7r11d37uw4/Screen%20Shot%202017-05-31%20at%2011.20.28%20AM.png?dl=0

sachinB94 commented 7 years ago

Hey, any update on this? I'm facing a similar issue with the react-native release build. Debug build works fine. @tsdexter did you find anything? using v7.1.2