|
3 | 3 | * Licensed under the MIT License. See License.txt in the project root for license information. |
4 | 4 | *--------------------------------------------------------------------------------------------*/ |
5 | 5 |
|
| 6 | +/// <reference path="typings/require.d.ts" /> |
| 7 | + |
6 | 8 | //@ts-check |
7 | 9 | 'use strict'; |
8 | 10 |
|
|
19 | 21 | globalThis.MonacoBootstrapWindow = factory(); |
20 | 22 | } |
21 | 23 | }(this, function () { |
22 | | - const path = require('path'); |
23 | | - const webFrame = require('electron').webFrame; |
24 | | - const ipc = require('electron').ipcRenderer; |
25 | | - const bootstrap = globalThis.MonacoBootstrap || require('./bootstrap'); |
| 24 | + const path = require.__$__nodeRequire('path'); |
| 25 | + const webFrame = require.__$__nodeRequire('electron').webFrame; |
| 26 | + const ipc = require.__$__nodeRequire('electron').ipcRenderer; |
| 27 | + const bootstrap = globalThis.MonacoBootstrap; |
26 | 28 |
|
27 | 29 | /** |
28 | 30 | * @param {string[]} modulePaths |
|
83 | 85 |
|
84 | 86 | window.document.documentElement.setAttribute('lang', locale); |
85 | 87 |
|
86 | | - // Load the loader |
87 | | - const amdLoader = require(`${configuration.appRoot}/out/vs/loader.js`); |
88 | | - const amdRequire = amdLoader.require; |
89 | | - const amdDefine = amdLoader.require.define; |
90 | | - const nodeRequire = amdLoader.require.nodeRequire; |
91 | | - |
92 | | - window['nodeRequire'] = nodeRequire; |
93 | | - window['require'] = amdRequire; |
| 88 | + // do not advertise AMD to avoid confusing UMD modules loaded with nodejs |
| 89 | + window['define'] = undefined; |
94 | 90 |
|
95 | 91 | // replace the patched electron fs with the original node fs for all AMD code |
96 | | - amdDefine('fs', ['original-fs'], function (originalFS) { return originalFS; }); |
| 92 | + require.define('fs', ['original-fs'], function (originalFS) { return originalFS; }); |
97 | 93 |
|
98 | 94 | window['MonacoEnvironment'] = {}; |
99 | 95 |
|
|
115 | 111 | options.beforeLoaderConfig(configuration, loaderConfig); |
116 | 112 | } |
117 | 113 |
|
118 | | - amdRequire.config(loaderConfig); |
| 114 | + require.config(loaderConfig); |
119 | 115 |
|
120 | 116 | if (nlsConfig.pseudo) { |
121 | | - amdRequire(['vs/nls'], function (nlsPlugin) { |
| 117 | + require(['vs/nls'], function (nlsPlugin) { |
122 | 118 | nlsPlugin.setPseudoTranslation(nlsConfig.pseudo); |
123 | 119 | }); |
124 | 120 | } |
|
127 | 123 | options.beforeRequire(); |
128 | 124 | } |
129 | 125 |
|
130 | | - amdRequire(modulePaths, result => { |
| 126 | + require(modulePaths, result => { |
131 | 127 | try { |
132 | 128 | const callbackResult = resultCallback(result, configuration); |
133 | 129 | if (callbackResult && typeof callbackResult.then === 'function') { |
|
199 | 195 |
|
200 | 196 | /** |
201 | 197 | * @param {string | Error} error |
202 | | - * @param {boolean} enableDeveloperTools |
| 198 | + * @param {boolean} [enableDeveloperTools] |
203 | 199 | */ |
204 | 200 | function onUnexpectedError(error, enableDeveloperTools) { |
205 | 201 | if (enableDeveloperTools) { |
|
0 commit comments