Closed danfma closed 8 years ago
I made a pull request to this.
But I think it's intentional, isn't it? Objects are frozen only in development mode. Because in production it will result in performance issues.
@smashercosmo I think the issue is that it is not freezing in non-node environments (like a browser). @danfma Is that right?
From the project description:
In the development build, objects are frozen. (Note that Safari is relatively slow to iterate over frozen objects.) The development build also overrides unsupported methods (methods that ordinarily mutate the underlying data structure) to throw helpful exceptions.
The production (minified) build does neither of these, which significantly improves performance.
So if you use the main /src/seamless-immutable.js
it just works and respects your NODE_ENV setting if you run it in node. If you run it in a browser you can either use the same file if you have a build environment where you have configured it or you can use the /seamless-immutable.development.js
or /seamless-immutable.production.js
directly which requires no setup of NODE_ENV.
If you want to use the default /src/seamless-immutable.js
and configure your build to set the correct mode then do as they suggest in React: https://facebook.github.io/react/downloads.html#npm (check the note for npm). It works in the same way for seamless-immutable.
Yep, this is working as intended. Thanks to all who responded explaining why this works the way it does!
Simple test:
\ Probably reason**
The Object.freeze is inside the node checking if.