microsoft / microsoft/monaco-editor
How to set alias path for files in monaco editor?
Open
Nobody has claimed this yet.
typescript
upstream
- Dominant language
- JavaScript
- Stars
- 46.8k
- Forks
- 4.1k
- Avg merge
- 17h 58m
- Merged PRs (30d)
- 1
Description
monaco-editor version: 0.2.0
Browser: chrome
OS: mac
Playground code that reproduces the issue:
monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
allowNonTsExtensions: true,
allowJs: true,
target: 99,
paths: {
"@/*": ["./"]
},
baseUrl: './',
})
const fooModel = monaco.editor.createModel(
`export const a = {name: 'abc'}`,
'javascript',
monaco.Uri.parse('file:///foo.js')
);
const mainModel = monaco.editor.createModel(
`import {a} from '@/foo';\n`,
'javascript',
monaco.Uri.parse('file:///main.js')
);
monaco.editor.create(document.getElementById('container'), {model:mainModel});
import {a} from '@/foo' no syntax tips for a
Expect
a has IntelliSense
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 by running the supplied Playground code with Monaco Editor 0.2.0 and inspect how the JavaScript defaults handle the paths and baseUrl compiler options. Trace module resolution for the two created models; done means the import from '@/foo' provides IntelliSense for a.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 30/100