microsoft / microsoft/monaco-editor

[Bug] `monaco-editor-webpack-plugin` resolves `customLanguages` from `path.join(monacoEditorPath, "esm")` when `monacoEditorPath` is supplied

Open
#4,193 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug ESM
Dominant language
JavaScript
Stars
46.8k
Forks
4.1k
Avg merge
17h 58m
Merged PRs (30d)
1

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

This is a monaco-editor-webpack-plugin bug, so it doesn't apply to the playground.

This is fairly minor, but if you supply a monacoEditorPath, it's a bit unexpected that customLanguages paths would be resolved from path.join(monacoEditorPath, "esm"). Custom languages aren't going to be "monaco paths," so I wouldn't expect any paths passed in there to need to run through resolveMonacoPath. However, the entry paths get aggregated into languagePaths here: https://github.com/microsoft/monaco-editor/blob/94c055bcbdd49f04a0fa15515e848542a79fb948/webpack-plugin/src/index.ts#L251

Then those are all run through resolveMonacoPath here: https://github.com/microsoft/monaco-editor/blob/94c055bcbdd49f04a0fa15515e848542a79fb948/webpack-plugin/src/index.ts#L312

Then, because monacoEditorPath is passed in, you hit the first condition, causing it to throw an error when trying to resolve the path from path.join(monacoEditorPath, "esm"): https://github.com/microsoft/monaco-editor/blob/94c055bcbdd49f04a0fa15515e848542a79fb948/webpack-plugin/src/index.ts#L25-L27

The same issue happens with the worker paths in getWorkerFilename: https://github.com/microsoft/monaco-editor/blob/94c055bcbdd49f04a0fa15515e848542a79fb948/webpack-plugin/src/index.ts#L49

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in webpack-plugin/src/index.ts, reading resolveMonacoPath and the code around the reported lines where custom language and worker paths are collected and resolved. Verify the behavior when monacoEditorPath is supplied; done means customLanguages and worker paths are handled without being incorrectly resolved as Monaco paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, webpack
Domain
build-system, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.