monaco-languageclient icon indicating copy to clipboard operation
monaco-languageclient copied to clipboard

Error in Angular Example : Unable to load extension-file://vscode.theme-defaults/extension/themes/dark_modern.json: Not Found

Open rawatSingh2022 opened this issue 10 months ago • 33 comments

  --

harset='utf-8'>


rawatSingh2022 avatar Feb 04 '25 15:02 rawatSingh2022

Can you please format your issue, use a code block and explain a little bit more what is happening to you?

CGNonofr avatar Feb 04 '25 16:02 CGNonofr

Can you please format your issue, use a code block and explain a little bit more what is happening to you? I have cloned the latest code form repository and, when running angular code form verify folder , I am encountering the following error in the console:

Image

rawatSingh2022 avatar Feb 04 '25 16:02 rawatSingh2022

@CGNonofr this is the same problem we saw here. I don't have a solution for it, yet. The existing esbuild plugin you provide does not work as is in angular. Everything I tried so far did not work, but it also did not spend much time.

kaisalmen avatar Feb 04 '25 20:02 kaisalmen

Ok 🤔 Can you please create an issue on the monaco-vscode-api side with a minimal reproduction repo?

CGNonofr avatar Feb 05 '25 09:02 CGNonofr

@CGNonofr is this sufficient? https://github.com/TypeFox/monaco-languageclient/tree/main/verify/angular

kaisalmen avatar Feb 05 '25 09:02 kaisalmen

Oh you mean it's not working in the demo here!

CGNonofr avatar Feb 05 '25 09:02 CGNonofr

Yes, and the angular setup is already there. Just do: npm run verify in the directory. The verification examples are all independent packages. That run command will bring up the ng dev server on port 4200

kaisalmen avatar Feb 05 '25 10:02 kaisalmen

@CGNonofr any updates on this?

rawatSingh2022 avatar Feb 06 '25 13:02 rawatSingh2022

Not yet, it's in my backlog

CGNonofr avatar Feb 06 '25 13:02 CGNonofr

I've had a look, there is NO WAY to inject a load esbuild plugin because angular injects its own angular-compiler first to load all files, and esbuild doesn't support transforming files except while loading it

CGNonofr avatar Feb 06 '25 18:02 CGNonofr

@CGNonofr thank you, so there is no way to make the stack work with ng dev server?

kaisalmen avatar Feb 07 '25 08:02 kaisalmen

@CGNonofr thank you, so there is no way to make the stack work with ng dev server?

I'm not exactly sure what is possible. It seems that esbuild is used directly, and that vite can be used instead, isn't it?

There is always a way though ^^ I've managed to make it work by patching the angular-compiler, so we can still hack it using patch-package

CGNonofr avatar Feb 07 '25 09:02 CGNonofr

I'm not exactly sure what is possible. It seems that esbuild is used directly, and that vite can be used instead, isn't it?

Did you find good documentation on it?

There is always a way though ^^ I've managed to make it work by patching the angular-compiler, so we can still hack it using patch-package

🚀

kaisalmen avatar Feb 07 '25 09:02 kaisalmen

Did you find good documentation on it?

Not really, I've only seen mentions of it, also ChatGPT talked about it, totally unclear to me though

🚀

Do you want me to create a PR with the hack?

CGNonofr avatar Feb 07 '25 09:02 CGNonofr

totally unclear to me though

You are not the only one.

Do you want me to create a PR with the hack?

@CGNonofr yes, but how long will that last?

kaisalmen avatar Feb 07 '25 12:02 kaisalmen

@CGNonofr yes, but how long will that last?

Do you mean how reliable the hack is?

CGNonofr avatar Feb 07 '25 13:02 CGNonofr

Yes, I meant that

kaisalmen avatar Feb 07 '25 13:02 kaisalmen

Probably not really... we should probably investigate the vite alternative before

CGNonofr avatar Feb 07 '25 13:02 CGNonofr

@CGNonofr Yes, that would be best, but I haven't found a way/documentation how to achieve that, yet. Maybe the angular tooling nx provides is a way out/forward.

kaisalmen avatar Feb 07 '25 18:02 kaisalmen

My understanding is that Angular uses esbuild directly, and vite is only used as a dev server, i.e. not for building and not at all in production builds. But, like it is possible to directly configure webpack using a custom builder, the same is available for esbuild: https://www.npmjs.com/package/@angular-builders/custom-esbuild I don't know if you can inject the esbuild plugins you want through that, but it does mention loading esbuild plugins.

jhk-mjolner avatar Feb 11 '25 08:02 jhk-mjolner

I don't know if you can inject the esbuild plugins you want through that, but it does mention loading esbuild plugins.

Hi @jhk-mjolner I tried this already, but without success and I think the reason for this is what @CGNonofr mentioned: "injects its own angular-compiler first to load all files, and esbuild doesn't support transforming files except while loading it"

kaisalmen avatar Feb 11 '25 08:02 kaisalmen

@CGNonofr I just had an idea: Is it possible to auto-transform all json assets to js. I see that you already make use of @rollup/plugin-json. The we could completely prevent the problem. I don't know the implications of this idea, but maybe it is not as immersive as may seem. WDYT?

kaisalmen avatar Feb 13 '25 10:02 kaisalmen

@CGNonofr I just had an idea: Is it possible to auto-transform all json assets to js. I see that you already make use of @rollup/plugin-json. The we could completely prevent the problem. I don't know the implications of this idea, but maybe it is not as immersive as may seem. WDYT?

It's not possible, some assets are loaded directly by VSCode, or even directly used in the HTML (like images, css, fonts...). And we can't cheat using glob urls because assets can be used in multiple contexts (main thread or in the extension host worker)

CGNonofr avatar Feb 13 '25 10:02 CGNonofr

@CGNonofr ok, that is the caveat. Is it possible to statically analyse the code related imports and treat them differently at least. I know this would lead to duplication. The least bundlers need to mess with things, the easier it will be to integrate the packages.

kaisalmen avatar Feb 13 '25 10:02 kaisalmen

Is it possible to statically analyse the code related imports and treat them differently at least

I have no idea what you mean 🤔

CGNonofr avatar Feb 13 '25 10:02 CGNonofr

I have no idea what you mean 🤔

I was thinking about theme instructions or language configuration, but I guess that is not the correct way. It is just frustrating that frameworks like angular or next and their tooling like to throw stones at you if you want to achieve something that does fit their regime.

kaisalmen avatar Feb 13 '25 10:02 kaisalmen

Instead of patching the lib, I vote for submitting a PR on their side (:

I'm aware of the issue with angular, but what about next?

CGNonofr avatar Feb 13 '25 13:02 CGNonofr

Regarding next, that was just a general remark, because if you want to use this stack you have to load everything dynamically. At least you can configure their webpack tooling directly.

kaisalmen avatar Feb 13 '25 13:02 kaisalmen

Instead of hiding a bundler in their framework they should provide tools/plugins to integrate what the need into existing tools. You have to solve some many problems, because of bad tooling infrastructure design decisions.

kaisalmen avatar Feb 13 '25 13:02 kaisalmen

The next issues are not related to assets though, so only angular has issues with it

CGNonofr avatar Feb 13 '25 13:02 CGNonofr