Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack bundle is missing the typescript worker #837

Closed
lucat1 opened this issue Apr 20, 2018 · 6 comments
Closed

Webpack bundle is missing the typescript worker #837

lucat1 opened this issue Apr 20, 2018 · 6 comments
Labels
help wanted Issues identified as good community contribution opportunities

Comments

@lucat1
Copy link

lucat1 commented Apr 20, 2018

monaco-editor version: 0.12.0
Browser: Any
OS: Any
Steps or JS usage snippet reproducing the issue:

Build the ESM example with webpack that can be found here

screen shot 2018-04-20 at 16 05 31

The error reported in the Devtools is about a missing package, but I beleive it is related to this webpack warning, and so to the issue #759.

screen shot 2018-04-20 at 16 03 24

@alexdima
Copy link
Member

We have several fully working examples like e.g. here:
https://github.com/Microsoft/monaco-editor-samples/tree/master/browser-esm-webpack
https://github.com/Microsoft/monaco-editor-samples/tree/master/browser-esm-webpack-small
or here
https://github.com/Microsoft/monaco-editor-webpack-plugin#using

I'm sorry I cannot help you out with webpack specific questions, simply because I am not a webpack expert. I suggest to start with a sample.

@lucat1
Copy link
Author

lucat1 commented Apr 21, 2018

Indeed this issue is reproducible in the linked example. Tough I forgot to say you have to set the language to typescript. Try typing in the editor and errors shoud pop up.

@alexdima
Copy link
Member

@lucat1 The sample works fine if you follow all the steps:

kapture 2018-04-23 at 11 02 29

@alexdima alexdima added the help wanted Issues identified as good community contribution opportunities label Apr 27, 2018
@flash-me
Copy link

For the Critical Dependency you can try this solution.
Regarding ts.Worker: Are you sure, that the specific workers have been built?

@youwenda
Copy link

youwenda commented Aug 12, 2018

https://github.com/Microsoft/monaco-editor-samples/tree/master/browser-esm-webpack

this example is OK because It satisfy HTML5 Worker Same Origin Policy, But If I place webpack bundle files in CDN.

Then in webpack.config.js may using __webpack_public_path__. eg:

self.MonacoEnvironment = {
	getWorkerUrl: function (moduleId, label) {
		if (label === 'json') {
			return __webpack_public_path__ + './json.worker.js';
		}
		if (label === 'css') {
			return __webpack_public_path__ + './css.worker.js';
		}
		if (label === 'html') {
			return __webpack_public_path__ + './html.worker.js';
		}
		if (label === 'typescript' || label === 'javascript') {
			return __webpack_public_path__ + './ts.worker.js';
		}
		return __webpack_public_path__ + './editor.worker.js';
	}
}

it will cause new Worker( ... ) run error and cause chrome console errors like this:

image

SO HOW TO SOLVE THIS PROBLEM?

@alexdima
Copy link
Member

HTML5 does not allow to launch web workers from a different domain. In this case, you would need to have some piece of code that bootstraps things either inlined as base64 or in a .js on the same domain as the HTML.

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Issues identified as good community contribution opportunities
Projects
None yet
Development

No branches or pull requests

4 participants