Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warnings & errors (+) #18

Open
PROFITVenchurs opened this issue Jan 9, 2019 · 4 comments
Open

Warnings & errors (+) #18

PROFITVenchurs opened this issue Jan 9, 2019 · 4 comments

Comments

@PROFITVenchurs
Copy link

I'm getting some warnings and errors in console.

Warning: Could not create web worker(s). Falling back to loading web worker code in main thread, which might cause UI freezes. Please see https://github.com/Microsoft/monaco-editor#faq
Error: Unexpected usage
    at EditorSimpleWorkerImpl.BaseEditorSimpleWorker.loadForeignModule (editorSimpleWorker.js?ccf6:468)
    at eval (webWorker.js?af50:39)
Error: undefined:1 Uncaught SyntaxError: Unexpected token <

I'm using vue-CLI 3 generated base app with vue.config.js:

const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');

module.exports = {
	configureWebpack: {
		plugins: [
			new MonacoWebpackPlugin({
				languages: ['javascript', 'css', 'html']
			})
		]
	}
}

What I'm doing wrong?

@mbwhite
Copy link

mbwhite commented Jan 17, 2019

Likewise same problem here; there does seem to be some discussion on various vsCode issues.
But it's not clear what the issue is as yet; digging into it ...

UPDATE:
Believe that it is related to microsoft/monaco-editor-webpack-plugin#27

In my use case, I wanted to have just json editting - and removing both JavaScript and TypeScript
got rid of the error for me. I also tried setting the langauge to be null in the vue template. That stopped the errors but then also gets rid of highlighting etc..

Setting that programmaticly might work after the editor is setup?

@shawyo
Copy link

shawyo commented Jun 17, 2020

I solved the problem

vue-CLI 3 vue.config.js:

const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');

module.exports = {
  configureWebpack: {
    plugins: [
      // To load all
      new MonacoWebpackPlugin()
    ]
  }
}

.vue

<template>
  <div class="monaco">
    <MonacoEditor v-if="isShow" v-model="code" class="editor" language="javascript" />
  </div>
</template>

<script>
import MonacoEditor from 'vue-monaco'

export default {
  components: {
    MonacoEditor
  },

  data() {
    return {
      isShow: false,
      code: 'const noop = () => {}'
    }
  },
  //  Lifecycle Hooks  mounted  use $nextTick
  mounted() {
    this.$nextTick(() => {
      this.isShow = true;
    })
  },
}
</script>

<style>
.editor {
  width: 600px;
  height: 800px;
}
</style>

@ghost
Copy link

ghost commented Aug 27, 2020

I believe that the reason this is happening in this case is because of this comment: microsoft/monaco-editor-webpack-plugin#27 (comment)

That would make sense why when you remove JavaScript or pass in null it works. In my case, I'm using this in Quasar so:

quasar.config.js

extendWebpack (cfg) {
  const MonacoEditorPlugin = require('monaco-editor-webpack-plugin')
  cfg.plugins.push(new MonacoEditorPlugin({
    // Require typescript to include a dependency needed by javascript
    languages: ['javascript', 'typescript']
  }))
}

component.vue:

<template lang="pug">
  MonacoEditor.editor(v-model='workspace.code' language='javascript')
</template>

@danielmeloalencar
Copy link

danielmeloalencar commented Sep 22, 2021

For javascript don't add 'javascript' on vue.config.js. Add 'typescript'

App.vue

<MonacoEditor v-if="isShow" v-model="code" class="editor" language="javascript" />

vue.config.js

const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');

module.exports = {
	configureWebpack: {
		plugins: [
			new MonacoWebpackPlugin({
				languages: ['typescript']
			})
		]
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants