microsoft / microsoft/monaco-editor
[Bug] setExtraLibs does only work with relative paths
Nobody has claimed this yet.
- 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?
- Not reproducible in the monaco editor playground
Monaco Editor Playground Link
Monaco Editor Playground Code
const value = `import { Class1 } from '/aa.js';
import { Class2 } from 'myLib';
new Class1;
new Class2;`;
monaco.languages.typescript.typescriptDefaults.setExtraLibs(
[
{content:'export class Class1 {}', filePath:'/aa.js'},
{content:'export class Class2 {}', filePath:'myLib'}
]);
// Hover on each property to see its docs!
const myEditor = monaco.editor.create(document.getElementById("container"), {
value,
language: "typescript",
automaticLayout: true,
});
Reproduction Steps
look at the playground code
Actual (Problematic) Behavior
As importmaps are now a thing, not only relative path could be used, but also some with a package name, wich is then resolved via importmap.
But the editor only works with imports with relative paths.
Expected Behavior
the sample provided should work and not show an error in the playground.
Additional Context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the playground reproduction and the setExtraLibs call in the supplied TypeScript example. Trace how the TypeScript language service resolves the relative '/aa.js' and package-like 'myLib' file paths, then verify that the sample resolves both imports without an error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100