Monaco-editor: Unsupported regex for Dart in Safari

Created on 7 Oct 2020  路  9Comments  路  Source: microsoft/monaco-editor

monaco-editor version: 0.21.0
Browser: Safari Version 14.0 (15610.1.28.1.9, 15610)
OS: MacOS Catalina

Hello team,

Hesitating to report this in vscode, but because vscode runs in a recent webkit not sure it's an issue.

Some languages use unsupported regex that breaks Safari. dart for example.

You can reproduce by going to the playground and pick "dart" languages.
It will throw an error in the console SyntaxError: Invalid regular expression: invalid group specifier name

Best Regards

bug help wanted monaco-languages

All 9 comments

I also experienced this. For example :

monaco.editor.create(document.getElementById("container"), {
    value: "",
    language: "dart"
});

image

Not a fix, but for anyone using the webpack plugin and experiencing this issue(assuming you don't need dart), one quick fix is to :

 new MonacoWebpackPlugin({
      languages : [] 
    })

Which comes with other benefits

Anyone know how to fix this? Or which languages are affected?

I think only the dart language uses the regex. In the meantime I have used yeikel鈥檚 solution until a proper fix. Excluding only dart fixes my build.

This is quite insidious in my case because I use webpack and the invalid regex causes the whole chunk to fail parsing in safari. It broke my whole app :/

Forgot to share how I fixed it temporarly:


const monacoLanguages = ['javascript', 'json', 'typescript', 'html'];
[...]
rules: [
  {
    test: new RegExp(`basic-languages\/(?!${monacoLanguages.join('|')}|_|monaco|fillers)`),
    use: 'null-loader',
  }
],
[...]
plugins: [
  new MonacoWebpackPlugin({
    languages: monacoLanguages,
  }),
]

Thank you both, that did it!

Fixed via microsoft/monaco-languages#121

Can you update the NPM package as soon as possible?

Was this page helpful?
0 / 5 - 0 ratings