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

Error with Vite #168

Open
stephantabor opened this issue Apr 16, 2021 · 0 comments · May be fixed by #205
Open

Error with Vite #168

stephantabor opened this issue Apr 16, 2021 · 0 comments · May be fixed by #205

Comments

@stephantabor
Copy link

stephantabor commented Apr 16, 2021

Using Vite to build a vue project, with es module import like

import MonacoEditor from 'vue-monaco'
ReferenceError: require is not defined
    at a.mounted (vue-monaco.es.181a4dd2.js:6)
    at Mt (vendor.6a78aee7.js:6)
    at Qe (vendor.6a78aee7.js:6)
    at Object.insert (vendor.6a78aee7.js:6)
    at A (vendor.6a78aee7.js:6)
    at a.__patch__ (vendor.6a78aee7.js:6)
    at a.t._update (vendor.6a78aee7.js:6)
    at a.n (vendor.6a78aee7.js:6)
    at ui.get (vendor.6a78aee7.js:6)
    at ui.run (vendor.6a78aee7.js:6)

Error is from this block in the source

    } else {
      // ESM format so it can't be resolved by commonjs `require` in eslint
      // eslint-disable-next-line import/no-unresolved
      var monaco = require('monaco-editor');

      this.monaco = monaco;
      this.$nextTick(function () {
        _this.initMonaco(monaco);
      });
    }

I don't understand why the es-module build has require in it, but if I remove that and add

import * as monaco from 'monaco-editor';

I get up to the point where this issue vitejs/vite#1791 is relevant

@segevfiner segevfiner linked a pull request Aug 30, 2022 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant