monaco-editor version: 0.18.0 (no problem on 0.17.1)
Browser: Chrome
OS: Windows
Hi, I just upgraded to version 0.18.0 today. I use monaco-editor-webpack-plugin to use the integrated ESM version. I got a message like this
```{javascript}
Uncaught ReferenceError: __insane_exports is not defined
I have traced down the problem in `/node_modules/monaco-editor/esm/vs/base/common/insane/insane/js`, apparently, this is caused by line 95 (sorry I don't really know how to link to the source code)
```{javascript}
__insane_exports = insane;
The line let __insane_exports; was commented out at the top of the file, so that might be a problem. I have searched around a bit hoping to find the answer and I found this file, I don't know how monaco-editor has anything to do with this project but it seems like these 2 insane.js files are similar, except the one I just showed has let __insane_exports uncommented.
Could you please checked this. I have just tried this on a very simple React app using ejected create-react-app and got the same error.
NOTE: I could not reproduce this on 0.17.1
I also want to add a warning that pops up in 0.18.0:
WARNING in ./node_modules/monaco-editor/esm/vs/base/worker/defaultWorkerFactory.js 35:32-39
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
Yeah, I'm seeing the same issue:
ESM-comment-begin and ESM-comment-end are removed / commented in the ESM build of monaco.getWorkerBootstrapUrl; and that function is apparently only used by some code that is commented out for the ESM version.insane.js: Monaco Editor is built from the sources at microsoft/vscode, so the file to look at is https://github.com/microsoft/vscode/blob/master/src/vs/base/common/insane/insane.jsinsane.js was added only recently (Aug 20 2019), so that explains why the error does not happen with 0.17.1. I suppose they forgot to remove line 95 as well for the ESM version. When I manually remove that line, it works. Still, the export does not seem to be recognized by webpack, so I had to install insane as an npm dependency myself and change the import in node_modules/monaco-editor/esm/vs/base/browser/markdownRenderer.js@Betalos I think this is the workaround for the critical dependency stuff, you need to change the first argument of the context though, but I have tried and it works. Still I think it's a workaround and hopefully, someone from the vscode/monaco-editor team will pay attention to this thread.
@blacksteed232, well i'll just wait for a solid fix, since 0.17.1 has no issue what so ever. For now just REVERT!!
Bump - Same, i cannot use this with ESM due to:
Uncaught ReferenceError: __insane_exports is not defined
[SOLVED],
Install insane module separately
npm install --save-dev insane
And in your webpack file, use module replace plugin to use installed insane module instead of insane module defined inside monaco-editor codebase
plugins: [
...,
new webpack.NormalModuleReplacementPlugin(
/vs\/base\/common\/insane\/insane.js/,
__dirname + '/node_modules/insane/insane.js'
)
]
In my case node_modules and webpack.config were sitting in the same folder. After adding this change the error was gone and I was able to use 0.18.0 version without any errors.
Please note that this is not a proper fix. It is just a patch to rewire the dependency. This still needs fix from monaco-editor team.
npm install --save-dev insane
Thank you for the temporary workaround while the devs fix this issue
@alexandrudima great news, thanks a lot 馃挴
When can we expect a release for monaco-editor?
I just published 0.18.1
@alexandrudima Thanks Alex. Would you be able to bump the peer dependencies in monaco-editor-webpack-plugin?
https://github.com/microsoft/monaco-editor-webpack-plugin/blob/master/package.json#L28
Most helpful comment
I just published
0.18.1