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

fix: ts worker `customWorkerPath` error by exporting the `TypescriptWorker` class

Open okikio opened this issue 3 years ago • 9 comments

This pr is meant to fix issue #3151 in which the TypescriptWorker class isn't exported, reducing the ability for devs to extend monaco in a module worker, as importScripts (which the customWorkerPath uses to extend the typescript worker) isn't available for module workers.

okikio avatar Jun 17 '22 16:06 okikio

CLA assistant check
All CLA requirements met.

ghost avatar Jun 17 '22 16:06 ghost

@hediet The importScript syntax doesn't work in esmodule workers, by allowing the TypeScript class to be exported I can make the TypeScript class work in esmodule workers even if the Monaco team doesn't officially support esmodule workers.

The problem is that customWorkerPath doesn't work in esmodule workers and unfortunately my situation requires that I use module workers.

okikio avatar Jul 21 '22 13:07 okikio

@okikio Can you look into why CI fails?

hediet avatar Aug 03 '22 12:08 hediet

@hediet For some reason the CI complains that esbuild hasn't been configured for .ttf files, but I never touch .ttf files in this pr

okikio avatar Aug 03 '22 13:08 okikio

The CI on main is green though, thus the failure must be caused by this PR.

hediet avatar Aug 03 '22 15:08 hediet

@hediet I've pushed a change to the package-esbuild.ts file that tells esbuild to treat the codicon.ttf file as an external file, from local testing it seems to fix the problem, but I'd need your opinion before confirming if the solution works.

okikio avatar Aug 04 '22 05:08 okikio

Do you know why this problem happens here, but not in main?

hediet avatar Aug 05 '22 08:08 hediet

I have no idea why it's doing this

okikio avatar Aug 05 '22 13:08 okikio

I'm running into a similar issue. My codebase uses a custom TS Worker as well, e.g.:

import { TypeScriptWorker } from "monaco-editor/esm/vs/language/typescript/tsWorker";

export class CustomTypeScriptWorker extends TypeScriptWorker {
...

Which worked on 0.27.0, but fails after upgrading to the latest version

YousefED avatar Aug 09 '22 14:08 YousefED

Any update on this one?

camargo avatar Sep 23 '22 02:09 camargo

@camargo Thanks for reminding me, I'll look into this again

okikio avatar Sep 23 '22 02:09 okikio

After a bunch of trial and error, I've determined that the cause of this issue is due to the exports being made, but I can't determine why the extra exports are causing the smoketests to fail

okikio avatar Sep 23 '22 03:09 okikio

@camargo I'll need some help here as I'm unable to debug why the playwright tests keep crashing when I export functions that aren't create

okikio avatar Sep 23 '22 21:09 okikio

Hi alexdima and okikio. We would love to use this feature if possible. Any ideas how to get this PR working? Happy to help get it through just need some guidance on where to start. Thanks!

camargo avatar Feb 01 '23 23:02 camargo

@camargo The pr itself is working, it's the test that's broken and I can't figure out how to fix it

okikio avatar Feb 01 '23 23:02 okikio

@alexdima Any advice on how to fix the test?

camargo avatar Feb 01 '23 23:02 camargo

Getting this merged would be great for our project.

Is there any chance of getting this assigned to a monaco milestone?

joswig avatar Apr 12 '23 00:04 joswig

Closing in favor of https://github.com/microsoft/monaco-editor/pull/4035

hediet avatar Jul 07 '23 15:07 hediet