CodinGame / monaco-vscode-api

VSCode public API plugged on the monaco editor
MIT License
214 stars 29 forks source link

Fixed asset paths in dev on Windows #315

Closed dkattan closed 6 months ago

dkattan commented 6 months ago

In my environment import.meta.url does not maintain the relative path to the extension in node_modules: image

So I added NPM package import-meta-resolve and used their resolve method by replacing

const resolved = await import.meta.resolve!(path, url.pathToFileURL(args.path));

with

const resolved = await resolve(path, url.pathToFileURL(args.path).toString());

But then I had an issue because import.meta.url starts with file://C:/ causing the pathname to be /C:/node_modules which is obviously not correct

image

This can be mitigated by replacing

const pathname = new URL(req.originalUrl, import.meta.url).pathname;

with

 const pathname = new URL(req.originalUrl, server.resolvedUrls?.local.toString())
CGNonofr commented 6 months ago

This plugin was externalized and used in https://github.com/CodinGame/monaco-vscode-api/pull/329