Suprising Babel error after upgrading a Node.js module (monaco-editor)

282 views Asked by At

I'm working on an React-based web application (created using CRA), so it uses Babel to transpile and pack our code and Node.js modules. Creating the production build worked fine until I upgraded the monaco-editor Node.js module from 0.20.0 to 0.21.2. After that an error started showing up, which is totally unexpected and probably caused by (valid) code changes in monaco-editor:

Creating an optimized production build...
Failed to compile.

./node_modules/monaco-editor/esm/vs/editor/contrib/suggest/wordDistance.js
Error: <path>/node_modules/monaco-editor/esm/vs/editor/contrib/suggest/wordDistance.js: unknown Expression of type "ClassExpression"
    at Array.forEach (<anonymous>)

I'm pretty sure this is not a failure in the monaco-editor Node.js module and my web search brought me to some code that made me think this is an error printed by Babel. Beside others, I found this pull request for Babel which fixes a very similar error message.

There's no other information in the error message, so I cannot be 100% sure, and therefore I would also very much welcome anything I could use to get more context for this error message.

I created a minimal example which produces this behavior and allows to prove that the monaco-editor upgrade is the culprit: https://github.com/mike-lischke/babel-test.

But since this is valid JavaScript code, I supposed the real culprit is Babel, not being able to deal with the used syntax (or maybe I need a newer version, but since this is all integrated in CRA it's tricky to use newer versions of automatically installed components).

1

There are 1 answers

0
Mike Lischke On BEST ANSWER

At the time being there's no other way than to return to the previous version of Monaco editor.