mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 17:25:39 +01:00
Use import() for lazy-loading modules
This commit is contained in:
parent
22f5c6aa9e
commit
4903cb5f00
2 changed files with 13 additions and 9 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;
|
||||
|
||||
// --- HTML configuration and defaults ---------
|
||||
|
||||
export class LanguageServiceDefaultsImpl implements monaco.languages.html.LanguageServiceDefaults {
|
||||
|
|
@ -93,16 +91,16 @@ monaco.languages.html = createAPI();
|
|||
|
||||
// --- Registration to monaco editor ---
|
||||
|
||||
function withMode(callback: (module: typeof mode) => void): void {
|
||||
require<typeof mode>(['./htmlMode'], callback);
|
||||
function getMode(): monaco.Promise<typeof mode> {
|
||||
return monaco.Promise.wrap(import('./htmlMode'))
|
||||
}
|
||||
|
||||
monaco.languages.onLanguage(htmlLanguageId, () => {
|
||||
withMode(mode => mode.setupMode(htmlDefaults));
|
||||
getMode().then(mode => mode.setupMode(htmlDefaults));
|
||||
});
|
||||
monaco.languages.onLanguage(handlebarsLanguageId, () => {
|
||||
withMode(mode => mode.setupMode(handlebarDefaults));
|
||||
getMode().then(mode => mode.setupMode(handlebarDefaults));
|
||||
});
|
||||
monaco.languages.onLanguage(razorLanguageId, () => {
|
||||
withMode(mode => mode.setupMode(razorDefaults));
|
||||
getMode().then(mode => mode.setupMode(razorDefaults));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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