Skip to content

[Bug] Loading monaco via require doesn't always respect urlArgs parameter #4310

Open

Description

Reproducible in vscode.dev or in VS Code Desktop?

  • Not reproducible in vscode.dev or VS Code Desktop

Reproducible in the monaco editor playground?

Monaco Editor Playground Link

No response

Monaco Editor Playground Code

No response

Reproduction Steps

No response

Actual (Problematic) Behavior

No response

Expected Behavior

No response

Additional Context

We have been using the AMD style to load the monaco editor in the browser.

It works mostly well but we are running into an issue.

Monaco being a fairly large library, we want to load the library lazily.
To improve performance, we also want to use HTTP caching heavily to avoid users having to reload the monaco files unnecessarily.

To achieve this, we used the code from the AMD sample and simply added the urlArgs parameter in the require.config call.

Requirejs docs:
image

Below is the same code as in the sample, with the added urlArgs: "v=0.35.0" so that the version parameter is added to all fetch requests

<script src="monaco-editor/min/vs/loader.js"></script>
<script>
	require.config({ paths: { vs: 'monaco-editor/min/vs' }, urlArgs: "v=0.35.0" });
	require(['vs/editor/editor.main'], function () {
		var editor = monaco.editor.create(document.getElementById('container'), {
			value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
			language: 'javascript'
		});
	});
</script>

Since we don't use requirejs for anything else, we use the provided vs loader.js

What we found is that it works well for the initial files but not all subsequent files.
Below you can see a screenshot from the Chrome network requests. The urlArgs parameter is correctly added to the editor.main.* files. However the workerMain.js url appends the query param twice and, more importantly, no param is added to simpleWorker.nl.js

image

Is this a known issue? Can a fix be released?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugIssue identified by VS Code Team member as probable bugeditor-core

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions