manuscript - do not cloneDeep Kv. create safeCloneDeep#12384
Conversation
|
(Thanks @cderv!) |
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new safeCloneDeep function that leverages an object’s own cloning method, when available, to avoid a full deep clone on certain objects such as cache instances. The changes replace all usages of ld.cloneDeep with safeCloneDeep and explicitly implement a Cloneable interface on relevant classes.
- Added safeCloneDeep function in src/core/safe-clone-deep.ts.
- Updated Sass cache classes and ProjectCacheImpl to implement Cloneable, with clone methods returning the original object.
- Replaced ld.cloneDeep with safeCloneDeep in notebook contributor files and revised error handling in SCSS parsing.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/core/safe-clone-deep.ts | Introduces safeCloneDeep to use an object’s own .clone() method when available |
| src/core/sass/add-css-vars.ts | Adds SCSSParsingError and updates error handling using safeCloneDeep |
| src/core/sass.ts | Adjusts error handling logic to selectively catch SCSSParsingError |
| src/core/sass/cache.ts | Implements Cloneable on SassCache with a clone method returning the current instance |
| src/core/cache/cache.ts | Implements Cloneable on ProjectCacheImpl with a clone method returning the current instance |
| src/render/notebook/notebook-contributor-ipynb.ts | Replaces ld.cloneDeep with safeCloneDeep for cloning executedFile objects |
| src/render/notebook/notebook-contributor-html.ts | Replaces ld.cloneDeep with safeCloneDeep and applies type assertions |
| src/render/notebook/notebook-contributor-jats.ts | Replaces ld.cloneDeep with safeCloneDeep for cloning executedFile objects |
| src/render/notebook/notebook-contributor-qmd.ts | Replaces ld.cloneDeep with safeCloneDeep for cloning executedFile objects |
Comments suppressed due to low confidence (1)
src/core/sass/cache.ts:23
- The clone() method implementation returns 'this', which means it is not actually creating a deep copy. If this behavior is intentional for performance reasons, please add a clarifying comment to prevent potential misuse.
clone() {
|
There is an issue with epub in book ❯ quarto render docs\project\book\index.qmd --to epub
Check file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/quarto.ts
[1/4] index.qmd
[2/4] intro.qmd
[3/4] summary.qmd
[4/4] references.qmd
ERROR: TypeError: Cannot read private member #rid from an object whose class did not declare itNot happening in html 🤷 So changing all cloneDeep, will probably fix it. |
|
I think I found the one |
|
And this broke everything because of typechecking working 🤦♂️ I am on it |
- unused import - foundBrand is a const now
|
@cscheid |
for epub book output for example.
|
🎉 |
Closes #12380.