monaco-editor icon indicating copy to clipboard operation
monaco-editor copied to clipboard

The global window object is polluted after monaco-editor initialization

Open makstakeda opened this issue 3 years ago • 4 comments

Just a possible bug I assume,

I landed in this repo by debugging https://www.npmjs.com/package/monaco-editor and its dependency on https://www.npmjs.com/package/monaco-editor-core which is basically leads to this repo. The issue is that if you try to use monaco-editor in your project (not vscode), it will pollute the global window object by setting define property in there which is leading to possible issues. For example, here in babel. As result, if I need to use babel-standalone after monaco-editor initialization, the babel check will not be invoked properly (as it will detect window.define.amd).

Is there any reason why define implementation (in here) is made on global window object?

makstakeda avatar Apr 21 '22 11:04 makstakeda

I met this issue when in sandbox

footmess avatar Sep 07 '22 03:09 footmess

Is there any progress on this issue?

liuwei1025 avatar Nov 21 '22 06:11 liuwei1025

If you load the editor via AMD, a global define will be in the global scope. If you load the editor via ESM, then there will be no globals defined.

alexdima avatar Apr 08 '23 20:04 alexdima