Support for bulk adding models/extraLibs
See original GitHub issuemonaco-editor version: 0.20.0 Browser: Chrome OS: Windows Playground code that reproduces the issue:
monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
target: monaco.languages.typescript.ScriptTarget.ES2016,
allowNonTsExtensions: true,
moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs,
module: monaco.languages.typescript.ModuleKind.CommonJS,
noEmit: true,
typeRoots: ["node_modules/@types"]
});
for (let i = 0; i < 500; i++) {
monaco.languages.typescript.typescriptDefaults.addExtraLib(
`export declare function next${i}() : string`,
`file:///node_modules/@types/external${i}/index.d.ts`
)
monaco.editor.createModel(`export declare function next${i}() : string`, "typescript", monaco.Uri.file(`/node_modules/@types/external${i}/index.d.ts`));
}
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
noSemanticValidation: false,
noSyntaxValidation: false
})
var jsCode = `import * as x from "external1"
const tt : string = x.next1();`;
monaco.editor.create(document.getElementById("container"), {
model: monaco.editor.createModel(jsCode, "typescript", monaco.Uri.file("main.tsx")),
});
In the above sample, I can try to add 500 models to the editor. Normally, in small numbers, adding models isn’t in issue, however, when adding more than about 100, I end up with “Loading…” when trying to hover over a function or import for about a minute or two.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Bulk add members to a distribution list - Microsoft Community
I need to bulk add member of my organization to a new distribution list. I have been using PowerShell commands but can't get...
Read more >How to Add Bulk Users to Distribution Group in Office 365 via ...
This blog helps admins add multiple members to the distribution group using PowerShell. The script accepts bulk users through import CSV and ...
Read more >Add/update multiple devices in bulk - AlgoSec
Open a text or csv file, and add a list of comma separated column headers. Each column header supports a device property or...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Running your code with
the language service reacts pretty fast so I don’t think it’s the model creation. It’s more likely the 500 simultaneous requests to the language service to validate all those models.
The validation is done in this class https://github.com/microsoft/monaco-typescript/blob/778ace10c0b702197eb06a3a1dc3b62b46eb5ceb/src/languageFeatures.ts#L90
more specifically here https://github.com/microsoft/monaco-typescript/blob/778ace10c0b702197eb06a3a1dc3b62b46eb5ceb/src/languageFeatures.ts#L173-L181
if you want to play around with that. Unfortunately, I don’t know another way to bulk add models and circumvent those language service requests. Good luck!
No worries. I should just mention, the method I used did have a side effect.
eagerModelSync
had to be set to false, otherwise I ran into performance issues with validating the model as the user types (i.e. marker data would lag behind whatever the user typed by about 1-2 seconds). Setting it to false corrected the issue and didn’t seem to cause any other issues that I have found.