Disable immutable check in production#6619
Conversation
to make sure that process.env.NODE_ENV is properly defined also in babel builds.
WalkthroughReplaced JSON Babel config with a programmatic Changes
Sequence Diagram(s)sequenceDiagram
participant App as App init
participant Store as store.ts
participant Middleware as getDefaultMiddleware
rect rgb(235,245,255)
App->>Store: initialize store
Store->>Store: read process.env.NODE_ENV
alt NODE_ENV in ['commonjs','es6','production']
Store->>Middleware: immutableCheck: false
else
Store->>Middleware: immutableCheck: true
end
Store->>Middleware: serializableCheck: false
Store->>App: return configured store
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🔇 Additional comments (1)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Do we run babel? I thought that's for umd build only. |
|
Nvm it's the opposite. Babel everywhere except umd. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6619 +/- ##
=======================================
Coverage 94.14% 94.15%
=======================================
Files 493 493
Lines 41080 41105 +25
Branches 4777 4784 +7
=======================================
+ Hits 38676 38701 +25
Misses 2399 2399
Partials 5 5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Bundle ReportChanges will increase total bundle size by 1.58kB (0.06%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: recharts/bundle-cjsAssets Changed:
|
src/state/store.ts
Outdated
| middleware: getDefaultMiddleware => | ||
| getDefaultMiddleware({ | ||
| serializableCheck: false, | ||
| immutableCheck: process.env.NODE_ENV === 'test', |
There was a problem hiding this comment.
Can we do !== prod instead? Pretty sure this doesn't get set to test when running things locally (besides tests)
There was a problem hiding this comment.
I also thought about this in the first place, but the build scripts for CommonJS and ES6 builds use NODE_ENV "commonjs" and "es6" respectively which would lead to the immutableCheck not being disabled for them. At least vitest sets "test" as NODE_ENV which is why I chose it here. To be correct, we would have to change it to
immutableCheck: ['commonjs', 'es6', 'production'].includes(process.env.NODE_ENV ?? ''),to my understanding. Do you agree?
There was a problem hiding this comment.
thats fine but I think you would need to negate that so that the check would be off for those values
There was a problem hiding this comment.
Certainly! My bad 😞 I will push a new commit shortly
Description
Make sure redux-tookit's
immutableCheckis only active during testing and not in production build to avoid other modules using this module having warnings emitted by redux-toolkit during their testing.This was harder to implement than initially thought as the babel build was still lacking to define
process.env.NODE_ENVproperly. I aligned this with the existing implementation for the webpack build.Related Issue
Fixes #6617
Motivation and Context
Fix #6617
How Has This Been Tested?
Built production artifacts and checked that
immutableCheckis disabled. Ran tests and checked thatimmutableCheckis enabled.Types of changes
Checklist:
Summary by CodeRabbit
Chores
Tests