Repository navigation
chore: update monaco editor to 0.57.0 - #5992
Merged
Merged
Conversation
Bumps the vendored Function node editor from monaco 0.55.1 to 0.57.0 and updates the bundled Node.js API types to v24.19.0 (built via node-red/nr-monaco-build). Fixes a type-resolution regression this brought with it: Node 24's @types/node split BufferConstructor's overloads (Buffer.from(), .alloc(), etc.) out of buffer.d.ts into a companion buffer.buffer.d.ts file, and split NodeJS.TypedArray/ArrayBufferView out of globals.d.ts into globals.typedarray.d.ts. monaco.js only ever loaded one .d.ts file per module, so Buffer was silently resolving to `any` in the Function node editor. Added both companion files as their own tracked modules, loaded alongside buffer.d.ts and globals.d.ts respectively. Also removes a stale `RED.util.linkcall` type hint from util.d.ts. It never existed in the runtime, only `node.linkcall()` does (documented separately in func.d.ts) - it was left over from an early WIP draft of the linkcall feature and got shipped accidentally in commit 31f5a05.
Contributor
Author
|
the artifacts in this PR were built from https://github.com/node-red/nr-monaco-build artifacts in release tagged 0.57.0 |
2 of 6 tasks
Re-vendors Monaco and the Node.js/Node-RED types from the nr-monaco-build 0.57.0 release (https://github.com/node-red/nr-monaco-build/releases/tag/0.57.0) instead of a local build. Only editor.js changes: the release also exposes monaco.css.getWorker() and monaco.html.getWorker(), the same shape as monaco.json.getWorker(), so editor code can use the CSS and HTML language services for content embedded in another language. The workers and types are unchanged. The vendor README now describes updating from a release rather than building.
4 of 6 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Types of changes
Proposed changes
Summary
Bumps the Monaco editor from 0.55.1 to 0.57.0, and the bundled Node.js API type declarations from v20.14.8 to v24.19.0.
vendor/monaco/dist/**andsrc/types/**are the unmodified contents ofnr-monaco-0.57.0.zip(monaco/distandtypes) from the nr-monaco-build 0.57.0 release. Nothing in them was edited by hand.What's included
packages/node_modules/@node-red/editor-client/src/vendor/monaco/dist/**- monaco 0.55.1 → 0.57.0packages/node_modules/@node-red/editor-client/src/vendor/monaco/README.md- now describes updating from an nr-monaco-build release instead of building locallypackages/node_modules/@node-red/editor-client/src/types/node/**-@types/node20.14.8 → 24.19.0, including new Node 22-24 modules (sqlite.d.ts,sea.d.ts) and the TypeScript-version compatibility files Node 24's types package now shipsmonaco.js- the only hand-edited code file: the Buffer/TypedArray fix belowmonaco.jshere; theutil.d.tsone is part of the vendoredtypes/node-red, which comes from the releaseNew in the build: CSS and HTML workers
The 0.57.0 release exposes
monaco.css.getWorker()andmonaco.html.getWorker(), the same shape as Monaco's ownmonaco.json.getWorker(). Monaco only had public getters for its TypeScript and JSON workers, so editor code could not use the CSS or HTML language services for content embedded in another language. Nothing in the editor calls them yet; #5994 uses them for<style>blocks in HTML editors. This adds about 720 bytes toeditor.js; the workers are unchanged.Verifying the vendored files
Download
nr-monaco-0.57.0.zipfrom the release, unzip it, and copymonaco/dist/.oversrc/vendor/monaco/dist/andtypes/.oversrc/types/, as described in the updatedvendor/monaco/README.md.git statusshould then show no changes. All 162 files in the zip are byte-identical to what this PR vendors.Fixes bundled with the bump
Buffer/TypedArray types silently resolving to
any. Node 24's@types/nodesplitBufferConstructor's overloads (Buffer.from(),.alloc(), etc.) out ofbuffer.d.tsinto a companionbuffer.buffer.d.ts, and splitNodeJS.TypedArray/ArrayBufferViewout ofglobals.d.tsintoglobals.typedarray.d.ts.monaco.jsonly ever loaded one.d.tsfile per module, soBuffersilently resolved toanyin the Function node editor after the types bump. Added both companion files as their own tracked modules, loaded alongsidebuffer.d.tsandglobals.d.tsrespectively. Verified with a real Function node:Buffer.from(...)now shows the full overload signature and autocomplete instead ofany.Stale
RED.util.linkcalltype hint removed fromutil.d.ts. It never existed in the runtime - onlynode.linkcall()does, correctly documented infunc.d.ts. Traced it to an early WIP commit (31f5a0542) that briefly exposedlinkcallon the Function node sandbox'sutilobject before the feature was finalized ontonode.linkcallinstead; the staleutil.d.tsentry was never cleaned up.Related
While testing this on Node 24, found and filed #5991 -
node:-scoped core modules (node:sqlite,node:test, etc.) can't be used as a Function node module, the runtime treats them as an npm dependency and halts the flow. That's a separate, pre-existing bug unrelated to this bump (not something this PR introduces or fixes), tracked separately since it needs its own discussion on the right fix shape. The corresponding editor-side type support for those modules is parked pending that fix landing, to avoid shipping correct-looking types for something that still fails at runtime.Testing
Built and tested in a browser after every change:
monaco.versionreports correctly, the editor loads and runs, intellisense for Node/node-red globals resolves correctly (including the Buffer fix above), and the editor's own dev build/watch pipeline (npm run dev) picks up all changes cleanly with no console errorsChecklist
npm run testto verify the unit tests pass