Conversation
leeyi45
left a comment
There was a problem hiding this comment.
Left some comments. Also please address some of the linting errors. Otherwise, thanks for doing the migration work
|
Will close #557 |
|
Btw, was there any particular reason why you're performing this migration? @AaravMalani |
I wanted to increase build times for |
RichDom2185
left a comment
There was a problem hiding this comment.
If @leeyi45 has further comments please do comment
| 'prefer-const': ['warn', { destructuring: 'all' }], | ||
|
|
||
| '@sourceacademy/default-import-name': ['warn', { path: 'pathlib' }], | ||
| '@sourceacademy/no-barrel-imports': ['error', ['lodash']], |
| "react": "^18.3.1", | ||
| "react-dom": "^18.3.1", |
There was a problem hiding this comment.
Revert
| "react": "^18.3.1", | |
| "react-dom": "^18.3.1", |
There was a problem hiding this comment.
I think the tests were failing without react in package.json for some reason
| expect(utils.extractPackageName('es-toolkit@npm:^1.44.0')) | ||
| .toEqual('es-toolkit'); |
There was a problem hiding this comment.
Why do we need to update these?
There was a problem hiding this comment.
I wasn't sure what the purpose of the file was, considering I can't find any uses for it in the repo
Co-authored-by: Richard Dominick <34370238+RichDom2185@users.noreply.github.com>
Co-authored-by: Richard Dominick <34370238+RichDom2185@users.noreply.github.com>
| return defaultConfig; | ||
| } | ||
| return _.merge({ ...defaultConfig }, userConfig); | ||
| return merge({ ...defaultConfig }, userConfig); |
There was a problem hiding this comment.
Bug: The mergeConfig function uses a shallow copy, which allows the merge utility to mutate nested objects within the original defaultConfig.
Severity: MEDIUM
Suggested Fix
To prevent unintended mutations, perform a deep copy of the defaultConfig object before passing it to the merge function. This ensures that nested objects are also duplicated, breaking the reference to the original configuration and preserving its integrity.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: src/bundles/robot_simulation/src/controllers/utils/mergeConfig.ts#L8
Potential issue: The `mergeConfig` function uses a shallow copy (`{ ...defaultConfig }`)
to protect the default configuration from being modified. However, this protection is
insufficient for nested objects. When a configuration object contains nested objects
(e.g., a `THREE.Color` instance), the shallow copy shares references to these nested
objects. The `merge` function, which modifies its target object in place, will then
mutate these shared nested objects, leading to unintended mutation of the original
`defaultConfig`. The existing unit test for mutation only covers flat objects and does
not detect this issue with nested structures.
Did we get this right? 👍 / 👎 to inform future reviews.
Description
Migrate from lodash to es-toolkit
Type of change
Please delete options that are not relevant.
Checklist:
Note:
A couple of Github Actions tests fail, hence I'm making a draft PR till it gets resolvedFixed, making it a normal PR