Monaco-editor: Webpack build error with 0.18

Created on 5 Sep 2019  路  6Comments  路  Source: microsoft/monaco-editor

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
bug important

Most helpful comment

All 6 comments

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brandalorian picture brandalorian  路  3Comments

poloten4uk picture poloten4uk  路  3Comments

robclive picture robclive  路  3Comments

SoftTimur picture SoftTimur  路  3Comments

inf9144 picture inf9144  路  3Comments