diff --git a/build/gulpfile.compile.js b/build/gulpfile.compile.js index e1afa13c445..e40b05f8d39 100644 --- a/build/gulpfile.compile.js +++ b/build/gulpfile.compile.js @@ -11,7 +11,6 @@ const util = require('./lib/util'); const date = require('./lib/date'); const task = require('./lib/task'); const compilation = require('./lib/compilation'); -const optimize = require('./lib/optimize'); /** * @param {boolean} disableMangle @@ -21,8 +20,7 @@ function makeCompileBuildTask(disableMangle) { util.rimraf('out-build'), date.writeISODate('out-build'), compilation.compileApiProposalNamesTask, - compilation.compileTask('src', 'out-build', true, { disableMangle }), - optimize.optimizeLoaderTask('out-build', 'out-build', true) + compilation.compileTask('src', 'out-build', true, { disableMangle }) ); } diff --git a/build/gulpfile.editor.js b/build/gulpfile.editor.js index 0d55982a8aa..9bd00fec66d 100644 --- a/build/gulpfile.editor.js +++ b/build/gulpfile.editor.js @@ -96,13 +96,6 @@ const optimizeEditorAMDTask = task.define('optimize-editor-amd', optimize.optimi src: 'out-editor-build', entryPoints: editorEntryPoints, resources: editorResources, - loaderConfig: { - paths: { - 'vs': 'out-editor-build/vs', - 'vs/css': 'out-editor-build/vs/css.build', - 'vscode': 'empty:' - } - }, header: BUNDLED_FILE_HEADER, bundleInfo: true, languages diff --git a/build/gulpfile.reh.js b/build/gulpfile.reh.js index 647c31d6a99..fba7d43ec64 100644 --- a/build/gulpfile.reh.js +++ b/build/gulpfile.reh.js @@ -465,7 +465,6 @@ function tweakProductForServerWeb(product) { entryPoints: (type === 'reh' ? serverEntryPoints : serverWithWebEntryPoints).flat(), otherSources: [], resources: type === 'reh' ? serverResources : serverWithWebResources, - loaderConfig: optimize.loaderConfig(), inlineAmdImages: true, bundleInfo: undefined, fileContentMapper: createVSCodeWebFileContentMapper('.build/extensions', type === 'reh-web' ? tweakProductForServerWeb(product) : product) diff --git a/build/gulpfile.vscode.js b/build/gulpfile.vscode.js index 9e2c153e7c5..f281970a453 100644 --- a/build/gulpfile.vscode.js +++ b/build/gulpfile.vscode.js @@ -145,7 +145,6 @@ const optimizeVSCodeTask = task.define('optimize-vscode', task.series( src: 'out-build', entryPoints: vscodeEntryPoints, resources: vscodeResources, - loaderConfig: optimize.loaderConfig(), bundleInfo: undefined }, commonJS: { diff --git a/build/gulpfile.vscode.web.js b/build/gulpfile.vscode.web.js index 9afe07f1cac..3617fa37faa 100644 --- a/build/gulpfile.vscode.web.js +++ b/build/gulpfile.vscode.web.js @@ -169,7 +169,6 @@ const optimizeVSCodeWebTask = task.define('optimize-vscode-web', task.series( entryPoints: vscodeWebEntryPoints.flat(), otherSources: [], resources: vscodeWebResources, - loaderConfig: optimize.loaderConfig(), externalLoaderInfo: util.createExternalLoaderConfig(product.webEndpointUrl, commit, quality), inlineAmdImages: true, bundleInfo: undefined, diff --git a/build/lib/optimize.js b/build/lib/optimize.js index 9b109c6b6cd..4fabac42716 100644 --- a/build/lib/optimize.js +++ b/build/lib/optimize.js @@ -4,8 +4,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ Object.defineProperty(exports, "__esModule", { value: true }); -exports.loaderConfig = loaderConfig; -exports.optimizeLoaderTask = optimizeLoaderTask; exports.optimizeTask = optimizeTask; exports.minifyTask = minifyTask; const es = require("event-stream"); @@ -22,81 +20,6 @@ const postcss_1 = require("./postcss"); const esbuild = require("esbuild"); const sourcemaps = require("gulp-sourcemaps"); const REPO_ROOT_PATH = path.join(__dirname, '../..'); -function loaderConfig() { - const result = { - paths: { - 'vs': 'out-build/vs', - 'vscode': 'empty:' - }, - amdModulesPattern: /^vs\// - }; - result['vs/css'] = { inlineResources: true }; - return result; -} -function loaderPlugin(src, base, amdModuleId) { - return (gulp - .src(src, { base }) - .pipe(es.through(function (data) { - if (amdModuleId) { - let contents = data.contents.toString('utf8'); - contents = contents.replace(/^define\(/m, `define("${amdModuleId}",`); - data.contents = Buffer.from(contents); - } - this.emit('data', data); - }))); -} -function loader(src, bundledFileHeader, bundleLoader, externalLoaderInfo) { - let loaderStream = gulp.src(`${src}/vs/loader.js`, { base: `${src}` }); - if (bundleLoader) { - loaderStream = es.merge(loaderStream, loaderPlugin(`${src}/vs/css.js`, `${src}`, 'vs/css')); - } - const files = []; - const order = (f) => { - if (f.path.endsWith('loader.js')) { - return 0; - } - if (f.path.endsWith('css.js')) { - return 1; - } - return 2; - }; - return (loaderStream - .pipe(es.through(function (data) { - files.push(data); - }, function () { - files.sort((a, b) => { - return order(a) - order(b); - }); - files.unshift(new VinylFile({ - path: 'fake', - base: '.', - contents: Buffer.from(bundledFileHeader) - })); - if (externalLoaderInfo !== undefined) { - files.push(new VinylFile({ - path: 'fake2', - base: '.', - contents: Buffer.from(emitExternalLoaderInfo(externalLoaderInfo)) - })); - } - for (const file of files) { - this.emit('data', file); - } - this.emit('end'); - })) - .pipe(concat('vs/loader.js'))); -} -function emitExternalLoaderInfo(externalLoaderInfo) { - const externalBaseUrl = externalLoaderInfo.baseUrl; - externalLoaderInfo.baseUrl = '$BASE_URL'; - // If defined, use the runtime configured baseUrl. - const code = ` -(function() { - const baseUrl = require.getConfig().baseUrl || ${JSON.stringify(externalBaseUrl)}; - require.config(${JSON.stringify(externalLoaderInfo, undefined, 2)}); -})();`; - return code.replace('"$BASE_URL"', 'baseUrl'); -} const DEFAULT_FILE_HEADER = [ '/*!--------------------------------------------------------', ' * Copyright (C) Microsoft Corporation. All rights reserved.', @@ -233,9 +156,6 @@ function optimizeManualTask(options) { }); return es.merge(...concatenations); } -function optimizeLoaderTask(src, out, bundleLoader, bundledFileHeader = '', externalLoaderInfo) { - return () => loader(src, bundledFileHeader, bundleLoader, externalLoaderInfo).pipe(gulp.dest(out)); -} function optimizeTask(opts) { return function () { const optimizers = []; diff --git a/build/lib/optimize.ts b/build/lib/optimize.ts index a0e37fc9f65..2721f020012 100644 --- a/build/lib/optimize.ts +++ b/build/lib/optimize.ts @@ -20,97 +20,6 @@ import * as sourcemaps from 'gulp-sourcemaps'; const REPO_ROOT_PATH = path.join(__dirname, '../..'); -export function loaderConfig() { - const result: any = { - paths: { - 'vs': 'out-build/vs', - 'vscode': 'empty:' - }, - amdModulesPattern: /^vs\// - }; - - result['vs/css'] = { inlineResources: true }; - - return result; -} - -function loaderPlugin(src: string, base: string, amdModuleId: string | undefined): NodeJS.ReadWriteStream { - return ( - gulp - .src(src, { base }) - .pipe(es.through(function (data: VinylFile) { - if (amdModuleId) { - let contents = data.contents.toString('utf8'); - contents = contents.replace(/^define\(/m, `define("${amdModuleId}",`); - data.contents = Buffer.from(contents); - } - this.emit('data', data); - })) - ); -} - -function loader(src: string, bundledFileHeader: string, bundleLoader: boolean, externalLoaderInfo?: util.IExternalLoaderInfo): NodeJS.ReadWriteStream { - let loaderStream = gulp.src(`${src}/vs/loader.js`, { base: `${src}` }); - if (bundleLoader) { - loaderStream = es.merge( - loaderStream, - loaderPlugin(`${src}/vs/css.js`, `${src}`, 'vs/css') - ); - } - - const files: VinylFile[] = []; - const order = (f: VinylFile) => { - if (f.path.endsWith('loader.js')) { - return 0; - } - if (f.path.endsWith('css.js')) { - return 1; - } - return 2; - }; - - return ( - loaderStream - .pipe(es.through(function (data) { - files.push(data); - }, function () { - files.sort((a, b) => { - return order(a) - order(b); - }); - files.unshift(new VinylFile({ - path: 'fake', - base: '.', - contents: Buffer.from(bundledFileHeader) - })); - if (externalLoaderInfo !== undefined) { - files.push(new VinylFile({ - path: 'fake2', - base: '.', - contents: Buffer.from(emitExternalLoaderInfo(externalLoaderInfo)) - })); - } - for (const file of files) { - this.emit('data', file); - } - this.emit('end'); - })) - .pipe(concat('vs/loader.js')) - ); -} - -function emitExternalLoaderInfo(externalLoaderInfo: util.IExternalLoaderInfo): string { - const externalBaseUrl = externalLoaderInfo.baseUrl; - externalLoaderInfo.baseUrl = '$BASE_URL'; - - // If defined, use the runtime configured baseUrl. - const code = ` -(function() { - const baseUrl = require.getConfig().baseUrl || ${JSON.stringify(externalBaseUrl)}; - require.config(${JSON.stringify(externalLoaderInfo, undefined, 2)}); -})();`; - return code.replace('"$BASE_URL"', 'baseUrl'); -} - export interface IOptimizeAMDTaskOpts { /** * The folder to read files from. @@ -124,7 +33,6 @@ export interface IOptimizeAMDTaskOpts { * (svg, etc.) */ resources: string[]; - loaderConfig: any; /** * Additional info we append to the end of the loader */ @@ -352,10 +260,6 @@ function optimizeManualTask(options: IOptimizeManualTaskOpts[]): NodeJS.ReadWrit return es.merge(...concatenations); } -export function optimizeLoaderTask(src: string, out: string, bundleLoader: boolean, bundledFileHeader = '', externalLoaderInfo?: util.IExternalLoaderInfo): () => NodeJS.ReadWriteStream { - return () => loader(src, bundledFileHeader, bundleLoader, externalLoaderInfo).pipe(gulp.dest(out)); -} - export interface IOptimizeTaskOpts { /** * Destination folder for the optimized files.