From 69809452a843de346958f253de730d567994debb Mon Sep 17 00:00:00 2001 From: Henning Dieterichs Date: Wed, 2 Feb 2022 20:03:20 +0100 Subject: [PATCH] Don't load monaco.contribution.ts twice. Fixes #2866, #2931. --- build/build.js | 20 ++++++++++++-------- build/utils.js | 13 ++++++++++--- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/build/build.js b/build/build.js index f663b727..efed0141 100644 --- a/build/build.js +++ b/build/build.js @@ -47,7 +47,7 @@ buildESM({ 'src/language/css/cssMode.ts', 'src/language/css/css.worker.ts' ], - external: ['monaco-editor-core', '*/cssMode'] + external: ['monaco-editor-core', '*/cssMode', '*/monaco.contribution'] }); buildAMD({ base: 'language/css', @@ -58,7 +58,8 @@ buildAMD({ buildAMD({ base: 'language/css', entryPoint: 'src/language/css/cssMode.ts', - amdModuleId: 'vs/language/css/cssMode' + amdModuleId: 'vs/language/css/cssMode', + external: ['*/monaco.contribution'] }); buildAMD({ base: 'language/css', @@ -77,7 +78,7 @@ buildESM({ 'src/language/html/htmlMode.ts', 'src/language/html/html.worker.ts' ], - external: ['monaco-editor-core', '*/htmlMode'] + external: ['monaco-editor-core', '*/htmlMode', '*/monaco.contribution'] }); buildAMD({ base: 'language/html', @@ -88,7 +89,8 @@ buildAMD({ buildAMD({ base: 'language/html', entryPoint: 'src/language/html/htmlMode.ts', - amdModuleId: 'vs/language/html/htmlMode' + amdModuleId: 'vs/language/html/htmlMode', + external: ['*/monaco.contribution'] }); buildAMD({ base: 'language/html', @@ -107,7 +109,7 @@ buildESM({ 'src/language/json/jsonMode.ts', 'src/language/json/json.worker.ts' ], - external: ['monaco-editor-core', '*/jsonMode'] + external: ['monaco-editor-core', '*/jsonMode', '*/monaco.contribution'] }); buildAMD({ base: 'language/json', @@ -118,7 +120,8 @@ buildAMD({ buildAMD({ base: 'language/json', entryPoint: 'src/language/json/jsonMode.ts', - amdModuleId: 'vs/language/json/jsonMode' + amdModuleId: 'vs/language/json/jsonMode', + external: ['*/monaco.contribution'] }); buildAMD({ base: 'language/json', @@ -142,7 +145,7 @@ buildESM({ 'src/language/typescript/tsMode.ts', 'src/language/typescript/ts.worker.ts' ], - external: ['monaco-editor-core', '*/tsMode'] + external: ['monaco-editor-core', '*/tsMode', '*/monaco.contribution'] }); buildAMD({ base: 'language/typescript', @@ -153,7 +156,8 @@ buildAMD({ buildAMD({ base: 'language/typescript', entryPoint: 'src/language/typescript/tsMode.ts', - amdModuleId: 'vs/language/typescript/tsMode' + amdModuleId: 'vs/language/typescript/tsMode', + external: ['*/monaco.contribution'] }); buildAMD({ base: 'language/typescript', diff --git a/build/utils.js b/build/utils.js index 3c1a9e50..8bebf9ed 100644 --- a/build/utils.js +++ b/build/utils.js @@ -155,9 +155,15 @@ exports.buildESM = buildESM; * entryPoint: string; * amdModuleId: string; * amdDependencies?: string[]; + * external?: string[]; * }} options */ function buildOneAMD(type, options) { + if (!options.amdDependencies) { + options.amdDependencies = []; + } + options.amdDependencies.unshift('require'); + /** @type {import('esbuild').BuildOptions} */ const opts = { entryPoints: [options.entryPoint], @@ -169,9 +175,9 @@ function buildOneAMD(type, options) { }, globalName: 'moduleExports', banner: { - js: `${bundledFileHeader}define("${options.amdModuleId}",[${(options.amdDependencies || []) + js: `${bundledFileHeader}define("${options.amdModuleId}", [${(options.amdDependencies || []) .map((dep) => `"${dep}"`) - .join(',')}],()=>{` + .join(',')}],(require)=>{` }, footer: { js: 'return moduleExports;\n});' @@ -184,7 +190,7 @@ function buildOneAMD(type, options) { 'monaco-editor-core': path.join(__dirname, '../src/fillers/monaco-editor-core-amd.ts') }) ], - external: ['vs/editor/editor.api'] + external: ['vs/editor/editor.api', ...(options.external || [])] }; if (type === 'min') { opts.minify = true; @@ -198,6 +204,7 @@ function buildOneAMD(type, options) { * entryPoint: string; * amdModuleId: string; * amdDependencies?: string[]; + * external?: string[]; * }} options */ function buildAMD(options) {