mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 20:52:56 +01:00
Use import() for lazy loading modules
This commit is contained in:
parent
59282ddaf6
commit
b2fa948b7c
2 changed files with 11 additions and 7 deletions
|
|
@ -10,8 +10,6 @@ import Emitter = monaco.Emitter;
|
|||
import IEvent = monaco.IEvent;
|
||||
import IDisposable = monaco.IDisposable;
|
||||
|
||||
declare var require: <T>(moduleId: [string], callback: (module: T) => void) => void;
|
||||
|
||||
// --- JSON configuration and defaults ---------
|
||||
|
||||
export class LanguageServiceDefaultsImpl implements monaco.languages.json.LanguageServiceDefaults {
|
||||
|
|
@ -62,8 +60,8 @@ monaco.languages.json = createAPI();
|
|||
|
||||
// --- Registration to monaco editor ---
|
||||
|
||||
function withMode(callback: (module: typeof mode) => void): void {
|
||||
require<typeof mode>(['./jsonMode'], callback);
|
||||
function getMode(): monaco.Promise<typeof mode> {
|
||||
return monaco.Promise.wrap(import('./jsonMode'))
|
||||
}
|
||||
|
||||
monaco.languages.register({
|
||||
|
|
@ -73,5 +71,5 @@ monaco.languages.register({
|
|||
mimetypes: ['application/json'],
|
||||
});
|
||||
monaco.languages.onLanguage('json', () => {
|
||||
withMode(mode => mode.setupMode(jsonDefaults));
|
||||
getMode().then(mode => mode.setupMode(jsonDefaults));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,8 +1,14 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"module": "es6",
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "../out",
|
||||
"target": "es5"
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"dom",
|
||||
"es5",
|
||||
"es2015.collection",
|
||||
"es2015.promise"
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue