monaco-editor version: 0.18.0
Steps or JS usage snippet reproducing the issue:
I am trying to build the latest monaco with webpack but I am getting the following error:
./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
You can reproduce this error by cloning https://github.com/vega/editor/tree/dom/upgrade and running
yarn && yarn start
same problem
Not sure if it is related but in addition to that warning I'm also getting the following error:
Uncaught ReferenceError: __insane_exports is not defined
at Object.push../node_modules/monaco-editor/esm/vs/base/common/insane/insane.js.4../defaults (:3000/static/js/0.chunk.js:78167)
at o (:3000/static/js/0.chunk.js:78086)
at r (:3000/static/js/0.chunk.js:78095)
at Object../node_modules/monaco-editor/esm/vs/base/common/insane/insane.js (:3000/static/js/0.chunk.js:78101)
at __webpack_require__ (:3000/static/js/bundle.js:787)
at fn (:3000/static/js/bundle.js:150)
at Module../node_modules/monaco-editor/esm/vs/base/browser/markdownRenderer.js (:3000/static/js/0.chunk.js:53998)
at __webpack_require__ (:3000/static/js/bundle.js:787)
at fn (:3000/static/js/bundle.js:150)
at Module../node_modules/monaco-editor/esm/vs/editor/contrib/markdown/markdownRenderer.js (:3000/static/js/0.chunk.js:187682)
at __webpack_require__ (:3000/static/js/bundle.js:787)
at fn (:3000/static/js/bundle.js:150)
at Module../node_modules/monaco-editor/esm/vs/editor/contrib/hover/modesContentHover.js (:3000/static/js/0.chunk.js:183158)
at __webpack_require__ (:3000/static/js/bundle.js:787)
at fn (:3000/static/js/bundle.js:150)
at Module../node_modules/monaco-editor/esm/vs/editor/contrib/hover/hover.js (:3000/static/js/0.chunk.js:182126)
at __webpack_require__ (:3000/static/js/bundle.js:787)
at fn (:3000/static/js/bundle.js:150)
at Object../include-loader!./node_modules/monaco-editor/esm/vs/editor/editor.api.js (:3000/static/js/0.chunk.js:67)
at __webpack_require__ (:3000/static/js/bundle.js:787)
at fn (:3000/static/js/bundle.js:150)
at Object../node_modules/react-monaco-editor/lib/editor.js (:3000/static/js/0.chunk.js:260909)
at __webpack_require__ (:3000/static/js/bundle.js:787)
at fn (:3000/static/js/bundle.js:150)
at Object../node_modules/react-monaco-editor/lib/index.js (:3000/static/js/0.chunk.js:261284)
at __webpack_require__ (:3000/static/js/bundle.js:787)
After updating from 0.17.1 to 0.18.0 appeared a new bug:
Compiled with 1 warnings
warning in ./node_modules/monaco-editor/esm/vs/base/worker/defaultWorkerFactory.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
monaco: 0.18.0
webpack: 4.35.3.
worker-loader: 2.0.0
With 0.17.1 works fine.
Workers loaded like this:
import CssWorker from 'worker-loader!../node_modules/monaco-editor/esm/vs/language/css/css.worker.js'
import HtmlWorker from 'worker-loader!../node_modules/monaco-editor/esm/vs/language/html/html.worker.js'
import TsWorker from 'worker-loader!../node_modules/monaco-editor/esm/vs/language/typescript/ts.worker.js'
import EditorWorker from 'worker-loader!../node_modules/monaco-editor/esm/vs/editor/editor.worker.js'
const extensionMap = {
'css': 'css',
'scss': 'css',
'sass': 'css',
'less': 'css',
'html': 'html',
'pug': 'html',
'inky': 'html',
'typescript': 'js',
'javascript': 'js',
}
const workers = {
css: CssWorker,
html: HtmlWorker,
js: TsWorker,
editor: EditorWorker,
}
self.MonacoEnvironment = {
getWorker: function ( moduleId, label ) {
const workerType = extensionMap.hasOwnProperty(label) ? extensionMap[label] : 'editor'
return new workers[workerType]()
},
}
@rebornix can you take a look at this issue?
Thank you!
Most helpful comment
Fixed via https://github.com/microsoft/vscode/commit/1ce58ccde7941cccd5448cb95f81e2f469db35d1