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

Fix __webpack_public_path__ within getWorkerUrl method #63

Merged
merged 1 commit into from
Dec 18, 2019

Conversation

mikegreiling
Copy link
Contributor

@mikegreiling mikegreiling commented Mar 13, 2019

According to webpack's documentation, the __webpack_public_path__ variable is not in the global scope, but is instead a free variable provided by a closure which webpack creates when it generates its runtime wrapper.

https://webpack.js.org/configuration/output/#outputpublicpath

window.__webpack_public_path__ should just be __webpack_public_path__

closes #7

@mikegreiling
Copy link
Contributor Author

issue reference: #7 (comment)

@bjrmatos
Copy link

@alexandrudima sorry to bother, but i can confirm that there was an issue before this PR. this PR correctly recognize __webpack_public_path__ when it has been set.

@mikegreiling
Copy link
Contributor Author

@alexandrudima could I bother you to take a look at this one please? 🙏

@mikegreiling
Copy link
Contributor Author

also /cc @TheLarkInn I know you work at Microsoft... any chance you could ping the appropriate person to get this one noticed?

@TheLarkInn
Copy link
Member

Ill do my best @mikegreiling!!!

@z1haze
Copy link

z1haze commented Jun 12, 2019

I had this same issue, and applied the same patch. I can confirm as well this fixes. Please merge!!

@ghost
Copy link

ghost commented Jun 17, 2019

Like @z1haze, we also can confirm, that this patch fixes the issue #7. We hope, that this PR will be merged in the near future... :)
EDIT: @alexandrudima sorry but do you have time to have a look at this PR?

@ghost ghost mentioned this pull request Aug 23, 2019
@katis
Copy link

katis commented Nov 1, 2019

Need this to make monaco-editor work with Next.js 9.1.2

apmorton added a commit to compiler-explorer/compiler-explorer that referenced this pull request Nov 14, 2019
This is a workaround to make cross origin monaco web workers function
in spite of the monaco webpack plugin hijacking the MonacoEnvironment global.

see microsoft/monaco-editor-webpack-plugin#42

This workaround wouldn't be so bad, if it didn't _also_ rely on *another* bug to
actually work.

The webpack plugin incorrectly uses
    window.__webpack_public_path__
when it should use
    __webpack_public_path__

see microsoft/monaco-editor-webpack-plugin#63

We can leave __webpack_public_path__ with the correct value, which lets runtime chunk
loading continue to function correctly.

We can then set window.__webpack_public_path__ to the below handler, which lets us
fabricate a worker on the fly.

This is bad and I feel bad.
apmorton added a commit to compiler-explorer/compiler-explorer that referenced this pull request Nov 14, 2019
This is a workaround to make cross origin monaco web workers function
in spite of the monaco webpack plugin hijacking the MonacoEnvironment global.

see microsoft/monaco-editor-webpack-plugin#42

This workaround wouldn't be so bad, if it didn't _also_ rely on *another* bug to
actually work.

The webpack plugin incorrectly uses
    window.__webpack_public_path__
when it should use
    __webpack_public_path__

see microsoft/monaco-editor-webpack-plugin#63

We can leave __webpack_public_path__ with the correct value, which lets runtime chunk
loading continue to function correctly.

We can then set window.__webpack_public_path__ to the below handler, which lets us
fabricate a worker on the fly.

This is bad and I feel bad.
@masad-frost
Copy link

masad-frost commented Nov 15, 2019

I have a fork here
https://github.com/masad-frost/monaco-editor-webpack-plugin

npm install monaco-editor-webpack-plugin https://github.com/masad-frost/monaco-editor-webpack-plugin.git#a9969f2d91c623218edcfae3d8a5cea821302ab1

You can set the publicPath to whatever you want

  if (!isServer) {
    config.plugins.push(
      new MonacoWebpackPlugin({
        output: 'monaco/' + monacoVersion,
        publicPath: '/public',
      }),
    );
  }

@alexdima
Copy link
Member

Thank you and apologies for the long waiting time! ❤️

@alexdima alexdima added this to the December 2019 milestone Dec 18, 2019
@alexdima alexdima merged commit f6a2196 into microsoft:master Dec 18, 2019
@mikegreiling
Copy link
Contributor Author

Thank you, @alexdima. Any ETA when this might land in a new package release?

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 this pull request may close these issues.

Support __webpack_public_path__
7 participants