Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Support __webpack_public_path__ #7

Closed
rgbkrk opened this issue Apr 27, 2018 · 7 comments · Fixed by #63
Closed

Support __webpack_public_path__ #7

rgbkrk opened this issue Apr 27, 2018 · 7 comments · Fixed by #63
Milestone

Comments

@rgbkrk
Copy link

rgbkrk commented Apr 27, 2018

We've made good use of this plugin in nteract/nteract#2779. We're running into one major issue though -- when we host our app on a subpath it appears that Monaco's webworkers aren't loading based on the __webpack_public_path__, instead relying only on the static publicPath in the webpack config.

What would we need to do to make monaco recognize the dynamic public path?

cc @yuvipanda

@dmitriylyner
Copy link
Contributor

dmitriylyner commented Jun 13, 2018

@rgbkrk This was recently fixed here: #14. Newest release of this plugin v1.3.0 should have this.

@rgbkrk
Copy link
Author

rgbkrk commented Jun 13, 2018

🙏 Thank you!

@rgbkrk
Copy link
Author

rgbkrk commented Jun 14, 2018

I'm currently running into an issue with this here: nteract/nteract#2992

screen shot 2018-06-14 at 2 22 36 pm

$ npm ls monaco-editor-webpack-plugin
nteract-monorepo@0.0.0 /Users/kylek/code/src/github.com/nteract/nteract-ext
└── monaco-editor-webpack-plugin@1.3.0

@rgbkrk rgbkrk reopened this Jun 14, 2018
@rgbkrk
Copy link
Author

rgbkrk commented Jun 14, 2018

We dynamically set the __webpack_public_path__ well before monaco is loaded (it loads in a chunk, dynamically imported, much later).

@akihikodaki
Copy link

Confirmed the problem. It incorrectly refers to window.__webpack_public_path__.

@z1haze
Copy link

z1haze commented Jun 12, 2019

We dynamically set the __webpack_public_path__ well before monaco is loaded (it loads in a chunk, dynamically imported, much later).

Could you provide an example of how you're going about setting the __webpack_public_path__ before monaco-editor-webpack-plugin initializes? I don't see how that is feasible as at least in my situation the webpack public path variable is set at runtime.

I end up with files in the correct location but instead of webpack looking for files in the correct public path, it looks for them a domain.com/js/worker.js when in reality it is domain.com/multi-site-name/default/some-version-hash/js/worker.js. We need this plugin to respect the runtime setting of __webpack_public_path__

@ghost
Copy link

ghost commented Aug 23, 2019

We wanted to provide an app which is loadable from any path, so therefore we dynamically determine the base path on runtime and use it as __webpack_public_path__. The determination happens in the index.html and afterwards based on the determined base path the bundle.js is loaded.

So therefore we also had the problem loading the editor.worker.js file.
We managed to overcome this problem by overriding the getWorkerUrl in the MonacoEnvironment object like this:

window.MonacoEnvironment = {
  getWorkerUrl(moduleId, label) {
    return `${BASE_PATH}${label == 'javascript' ? 'typescript' : 'editor'}.worker.js`;
  }
};

If you want to provide more languages then you have to consider more workers (see issue).
As long as this issue and the subsequent PR is open, this can be considered as a temporary solution.

I hope this helps some people.

@alexdima alexdima added this to the December 2019 milestone Dec 18, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Feb 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants