-
Notifications
You must be signed in to change notification settings - Fork 52
fix(immutable): remove Immutable (option 2) #5755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
smouillour
wants to merge
17
commits into
master
Choose a base branch
from
smouillour-remove-immutable
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+4,213
−2,483
Open
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
6651ca0
add gitignore + tmp copilot instruction
smouillour 8d089d8
epic 1 done and reviewed
smouillour 7f4be7f
epic 2 done and reviewed
smouillour c75791c
epic 3 done and reviewed
smouillour f985689
epic 4 done and reviewed
smouillour 2b764a6
epic-5 partial
smouillour 1acd4a1
fix changeset
smouillour 30d583e
fix some tests in cmf
smouillour 7b8fa58
fix more test
smouillour 0e5b45d
add migration guide
smouillour fe6e8cd
Add vote description
smouillour 23936be
manage copilot review
smouillour 0664114
revert changes made in flow-designer
smouillour 78e74a1
update migration doc
smouillour f024c74
fix yarn.lock
smouillour a6c46f1
sync with master
smouillour dc28473
fix review
smouillour File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| --- | ||
| '@talend/react-cmf': major | ||
| '@talend/react-containers': major | ||
| '@talend/react-cmf-cqrs': major | ||
| '@talend/react-components': major | ||
| '@talend/react-sagas': major | ||
| '@talend/react-stepper': patch | ||
| --- | ||
|
|
||
| feat: remove immutable dependency | ||
|
|
||
| ## Breaking changes | ||
|
|
||
| ### `@talend/react-cmf` (major) | ||
|
|
||
| The CMF Redux store no longer uses ImmutableJS. `state.cmf.collections` and `state.cmf.components` are now plain objects. | ||
|
|
||
| Migrate: | ||
| - `.get(key)` → `[key]` | ||
| - `.getIn([a, b])` → `lodash.get(state, [a, b])` | ||
| - `.toJS()` → identity (already plain JS) | ||
| - `.size` → `Object.keys(x).length` | ||
|
|
||
| The `cmf.selectors.collections.*` and `cmf.selectors.components.*` APIs still work and are the recommended way to access CMF state. | ||
|
|
||
| ### `@talend/react-containers` (major) | ||
|
|
||
| `defaultState` is now a plain object. Selectors updated accordingly. Same migration as above. | ||
|
|
||
| ### `@talend/react-cmf-cqrs` (major) | ||
|
|
||
| `state.ack` is now a plain object. Consumers reading ack state directly must migrate `.get(key)` → `[key]`. | ||
|
|
||
| ### `@talend/react-sagas` (major) | ||
|
|
||
| Exported functions `findPenders(state)` and `findPenderById(state, id)` now return plain JS values instead of Immutable structures. Any consumer calling `.get()`, `.set()`, `.toJS()`, or `.size` on the return values must migrate to plain object access. | ||
|
|
||
| ### `@talend/react-components` (major) | ||
|
|
||
| The `Iterable.isIterable` backward-compat guard was removed from `ActionDropdown`. Consumers passing an Immutable List as `items` will no longer work — migrate to plain arrays. | ||
|
|
||
| `immutable` and `react-immutable-proptypes` removed from published `dependencies`. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # Migration Guide: Removal of ImmutableJS | ||
|
|
||
| This is the index for per-package migration guides covering the breaking changes introduced by the removal of [ImmutableJS](https://immutable-js.com/) from the Talend UI monorepo. | ||
|
|
||
| ## Affected packages | ||
|
|
||
| | Package | Version bump | Guide | | ||
| | -------------------------- | ------------ | ------------------------------------------------------------------------------------------------------------------- | | ||
| | `@talend/react-cmf` | **MAJOR** | [migration-guide-remove-immutable-cmf.md](./remove-immutable/migration-guide-remove-immutable-cmf.md) | | ||
| | `@talend/react-containers` | **MAJOR** | [migration-guide-remove-immutable-containers.md](./remove-immutable/migration-guide-remove-immutable-containers.md) | | ||
| | `@talend/react-cmf-cqrs` | **MAJOR** | [migration-guide-remove-immutable-cmf-cqrs.md](./remove-immutable/migration-guide-remove-immutable-cmf-cqrs.md) | | ||
| | `@talend/react-sagas` | **MAJOR** | [migration-guide-remove-immutable-sagas.md](./remove-immutable/migration-guide-remove-immutable-sagas.md) | | ||
| | `@talend/react-components` | **MAJOR** | [migration-guide-remove-immutable-components.md](./remove-immutable/migration-guide-remove-immutable-components.md) | | ||
| | `@talend/react-stepper` | patch | [migration-guide-remove-immutable-stepper.md](./remove-immutable/migration-guide-remove-immutable-stepper.md) | | ||
|
|
||
| --- | ||
|
|
||
| ## Quick reference: ImmutableJS → Plain JS | ||
|
|
||
| | ImmutableJS | Plain JS | | ||
| | ------------------------ | ---------------------------------------------------------- | | ||
| | `map.get(key)` | `obj[key]` | | ||
| | `map.getIn([a, b, c])` | `lodash.get(obj, [a, b, c])` | | ||
| | `map.set(key, val)` | `{ ...obj, [key]: val }` | | ||
| | `map.setIn([a, b], val)` | `produce(obj, d => set(d, [a, b], val))` (immer + lodash) | | ||
| | `map.merge(other)` | `{ ...obj, ...other }` | | ||
| | `map.delete(key)` | `const { [key]: _, ...rest } = obj; return rest;` | | ||
| | `map.has(key)` | `key in obj` | | ||
| | `list.push(item)` | `[...arr, item]` | | ||
| | `list.filter(fn)` | `arr.filter(fn)` | | ||
| | `list.filterNot(fn)` | `arr.filter(item => !fn(item))` | | ||
| | `list.find(fn)` | `arr.find(fn)` | | ||
| | `list.includes(val)` | `arr.includes(val)` | | ||
| | `Map.isMap(x)` | `typeof x === 'object' && x !== null && !Array.isArray(x)` | | ||
| | `List.isList(x)` | `Array.isArray(x)` | | ||
| | `Iterable.isIterable(x)` | N/A — remove the guard | | ||
| | `fromJS(obj)` | `obj` (already plain) | | ||
| | `x.toJS()` | `x` (already plain) | | ||
| | `x.size` | `Array.isArray(x) ? x.length : Object.keys(x).length` | | ||
|
|
||
| ## Useful grep patterns | ||
|
|
||
| ```bash | ||
| # Find all Immutable imports | ||
| grep -r "from 'immutable'" src/ --include="*.ts" --include="*.tsx" --include="*.js" --include="*.jsx" | ||
|
|
||
| # Find react-immutable-proptypes usage | ||
| grep -r "react-immutable-proptypes" src/ --include="*.ts" --include="*.tsx" --include="*.js" --include="*.jsx" | ||
|
|
||
| # Find residual Immutable method calls | ||
| grep -rE "\.(getIn|setIn|toJS|fromJS|isMap|isList|isIterable)\(" src/ | ||
| ``` |
103 changes: 103 additions & 0 deletions
103
.../migration-guides/remove-immutable/migration-guide-remove-immutable-cmf-cqrs.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| # Migration Guide: `@talend/react-cmf-cqrs` — Removal of ImmutableJS | ||
|
|
||
| **Version bump**: MAJOR | ||
|
|
||
| --- | ||
|
|
||
| ## What changed | ||
|
|
||
| `state.ack` is now a plain JavaScript object. The Immutable methods previously used to read/write acknowledgment state have been replaced with standard object operations. | ||
|
|
||
| Removed dependency: `immutable`. | ||
|
|
||
| --- | ||
|
|
||
| ## Breaking changes | ||
|
|
||
| ### 1. `state.ack` is now a plain object | ||
|
|
||
| The ACK reducer now stores state as `{ [requestId]: { data, actionCreator, received } }` — a plain JS object keyed by `requestId`. | ||
|
|
||
| **Before** | ||
|
|
||
| ```js | ||
| // state.ack was an Immutable.Map | ||
| const ackEntry = state.ack.getIn([requestId, 'data']); | ||
| const received = state.ack.getIn([requestId, 'received']); | ||
| const actionCreator = state.ack.getIn([requestId, 'actionCreator']); | ||
|
|
||
| // checking if an entry exists | ||
| const exists = state.ack.has(requestId); | ||
| ``` | ||
|
|
||
| **After** | ||
|
|
||
| ```js | ||
| // state.ack is now a plain object: { [requestId]: { data, actionCreator, received } } | ||
| const ackEntry = state.ack[requestId]?.data; | ||
| const received = state.ack[requestId]?.received; | ||
| const actionCreator = state.ack[requestId]?.actionCreator; | ||
|
|
||
| // checking if an entry exists | ||
| const exists = requestId in state.ack; | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### 2. `ACKDispatcher` — `acks` prop is a plain object | ||
|
|
||
| The `ACKDispatcher` component now iterates over `props.acks` using `Object.entries()`. Previously it was iterated as an Immutable-style iterable. | ||
|
|
||
| If you use `ACKDispatcher` through `cmfConnect` (the standard usage), this is handled automatically — `state.ack` is now a plain object and is passed as `acks` directly. **No action required** for this pattern. | ||
|
|
||
| If you pass `acks` **manually as a prop**, it must be a plain object: | ||
|
|
||
| ```js | ||
| // Before — custom acks prop (Immutable) | ||
| import { Map } from 'immutable'; | ||
| <ACKDispatcher | ||
| acks={Map({ | ||
| 'req-123': Map({ received: true, actionCreator: 'dataset:fetchAll', data: {} }), | ||
| })} | ||
| /> | ||
|
|
||
| // After — custom acks prop (plain object) | ||
| <ACKDispatcher | ||
| acks={{ | ||
| 'req-123': { received: true, actionCreator: 'dataset:fetchAll', data: {} }, | ||
| }} | ||
| /> | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### 3. Test fixtures | ||
|
|
||
| Tests that build mock ACK state with Immutable must be updated: | ||
|
|
||
| ```js | ||
| // Before | ||
| import Immutable from 'immutable'; | ||
| const state = { | ||
| ack: Immutable.fromJS({ | ||
| 'req-123': { received: false, data: null, actionCreator: 'dataset:fetch' }, | ||
| }), | ||
| }; | ||
|
|
||
| // After | ||
| const state = { | ||
| ack: { | ||
| 'req-123': { received: false, data: null, actionCreator: 'dataset:fetch' }, | ||
| }, | ||
| }; | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Checklist | ||
|
|
||
| - [ ] Replace `state.ack.getIn([requestId, 'key'])` → `state.ack[requestId]?.key` | ||
| - [ ] Replace `state.ack.has(requestId)` → `requestId in state.ack` | ||
| - [ ] Ensure manually-passed `acks` props are plain objects | ||
| - [ ] Update test fixtures to use plain objects instead of `Immutable.fromJS({...})` | ||
| - [ ] Remove `immutable` from your own `package.json` if transitively relied on |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.