mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 21:39:43 +00:00
This reverts commit 2179e52fb9
.
This commit is contained in:
parent
107f6cade5
commit
84c46b71a5
|
@ -9,15 +9,13 @@ const gulp = require('gulp');
|
|||
const util = require('./lib/util');
|
||||
const task = require('./lib/task');
|
||||
const compilation = require('./lib/compilation');
|
||||
const optimize = require('./lib/optimize');
|
||||
|
||||
// Full compile, including nls and inline sources in sourcemaps, for build
|
||||
const compileBuildTask = task.define('compile-build',
|
||||
task.series(
|
||||
util.rimraf('out-build'),
|
||||
util.buildWebNodePaths('out-build'),
|
||||
compilation.compileTask('src', 'out-build', true),
|
||||
optimize.optimizeLoaderTask('out-build', 'out-build', true)
|
||||
compilation.compileTask('src', 'out-build', true)
|
||||
)
|
||||
);
|
||||
gulp.task(compileBuildTask);
|
||||
|
|
|
@ -7,7 +7,7 @@ const gulp = require('gulp');
|
|||
const path = require('path');
|
||||
const util = require('./lib/util');
|
||||
const task = require('./lib/task');
|
||||
const optimize = require('./lib/optimize');
|
||||
const common = require('./lib/optimize');
|
||||
const es = require('event-stream');
|
||||
const File = require('vinyl');
|
||||
const i18n = require('./lib/i18n');
|
||||
|
@ -86,29 +86,26 @@ const extractEditorSrcTask = task.define('extract-editor-src', () => {
|
|||
|
||||
const compileEditorAMDTask = task.define('compile-editor-amd', compilation.compileTask('out-editor-src', 'out-editor-build', true));
|
||||
|
||||
const optimizeEditorAMDTask = task.define('optimize-editor-amd', optimize.optimizeTask(
|
||||
{
|
||||
out: 'out-editor',
|
||||
amd: {
|
||||
src: 'out-editor-build',
|
||||
entryPoints: editorEntryPoints,
|
||||
resources: editorResources,
|
||||
loaderConfig: {
|
||||
paths: {
|
||||
'vs': 'out-editor-build/vs',
|
||||
'vs/css': 'out-editor-build/vs/css.build',
|
||||
'vs/nls': 'out-editor-build/vs/nls.build',
|
||||
'vscode': 'empty:'
|
||||
}
|
||||
},
|
||||
header: BUNDLED_FILE_HEADER,
|
||||
bundleInfo: true,
|
||||
languages
|
||||
const optimizeEditorAMDTask = task.define('optimize-editor-amd', common.optimizeTask({
|
||||
src: 'out-editor-build',
|
||||
entryPoints: editorEntryPoints,
|
||||
resources: editorResources,
|
||||
loaderConfig: {
|
||||
paths: {
|
||||
'vs': 'out-editor-build/vs',
|
||||
'vs/css': 'out-editor-build/vs/css.build',
|
||||
'vs/nls': 'out-editor-build/vs/nls.build',
|
||||
'vscode': 'empty:'
|
||||
}
|
||||
}
|
||||
));
|
||||
},
|
||||
bundleLoader: false,
|
||||
header: BUNDLED_FILE_HEADER,
|
||||
bundleInfo: true,
|
||||
out: 'out-editor',
|
||||
languages: languages
|
||||
}));
|
||||
|
||||
const minifyEditorAMDTask = task.define('minify-editor-amd', optimize.minifyTask('out-editor'));
|
||||
const minifyEditorAMDTask = task.define('minify-editor-amd', common.minifyTask('out-editor'));
|
||||
|
||||
const createESMSourcesAndResourcesTask = task.define('extract-editor-esm', () => {
|
||||
standalone.createESMSourcesAndResources2({
|
||||
|
|
|
@ -20,6 +20,7 @@ const root = path.dirname(__dirname);
|
|||
const commit = util.getVersion(root);
|
||||
const plumber = require('gulp-plumber');
|
||||
const ext = require('./lib/extensions');
|
||||
const product = require('../product.json');
|
||||
|
||||
const extensionsPath = path.join(path.dirname(__dirname), 'extensions');
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ const path = require('path');
|
|||
const es = require('event-stream');
|
||||
const util = require('./lib/util');
|
||||
const task = require('./lib/task');
|
||||
const optimize = require('./lib/optimize');
|
||||
const common = require('./lib/optimize');
|
||||
const product = require('../product.json');
|
||||
const rename = require('gulp-rename');
|
||||
const replace = require('gulp-replace');
|
||||
|
@ -58,10 +58,15 @@ const serverResources = [
|
|||
'out-build/bootstrap-fork.js',
|
||||
'out-build/bootstrap-amd.js',
|
||||
'out-build/bootstrap-node.js',
|
||||
'out-build/paths.js',
|
||||
|
||||
// Performance
|
||||
'out-build/vs/base/common/performance.js',
|
||||
|
||||
// main entry points
|
||||
'out-build/server-cli.js',
|
||||
'out-build/server-main.js',
|
||||
|
||||
// Watcher
|
||||
'out-build/vs/platform/files/**/*.exe',
|
||||
'out-build/vs/platform/files/**/*.md',
|
||||
|
@ -249,7 +254,7 @@ function packageTask(type, platform, arch, sourceFolderName, destinationFolderNa
|
|||
const date = new Date().toISOString();
|
||||
|
||||
const productJsonStream = gulp.src(['product.json'], { base: '.' })
|
||||
.pipe(json({ commit, date, version }));
|
||||
.pipe(json({ commit, date }));
|
||||
|
||||
const license = gulp.src(['remote/LICENSE'], { base: 'remote', allowEmpty: true });
|
||||
|
||||
|
@ -352,42 +357,23 @@ function tweakProductForServerWeb(product) {
|
|||
['reh', 'reh-web'].forEach(type => {
|
||||
const optimizeTask = task.define(`optimize-vscode-${type}`, task.series(
|
||||
util.rimraf(`out-vscode-${type}`),
|
||||
optimize.optimizeTask(
|
||||
{
|
||||
out: `out-vscode-${type}`,
|
||||
amd: {
|
||||
src: 'out-build',
|
||||
entryPoints: _.flatten(type === 'reh' ? serverEntryPoints : serverWithWebEntryPoints),
|
||||
otherSources: [],
|
||||
resources: type === 'reh' ? serverResources : serverWithWebResources,
|
||||
loaderConfig: optimize.loaderConfig(),
|
||||
inlineAmdImages: true,
|
||||
bundleInfo: undefined,
|
||||
fileContentMapper: createVSCodeWebFileContentMapper('.build/extensions', type === 'reh-web' ? tweakProductForServerWeb(product) : product)
|
||||
},
|
||||
commonJS: {
|
||||
src: 'out-build',
|
||||
entryPoints: [
|
||||
'out-build/server-main.js',
|
||||
'out-build/server-cli.js'
|
||||
],
|
||||
platform: 'node',
|
||||
external: [
|
||||
'minimist',
|
||||
// TODO: we cannot inline `product.json` because
|
||||
// it is being changed during build time at a later
|
||||
// point in time (such as `checksums`)
|
||||
'../product.json'
|
||||
]
|
||||
}
|
||||
}
|
||||
)
|
||||
common.optimizeTask({
|
||||
src: 'out-build',
|
||||
entryPoints: _.flatten(type === 'reh' ? serverEntryPoints : serverWithWebEntryPoints),
|
||||
otherSources: [],
|
||||
resources: type === 'reh' ? serverResources : serverWithWebResources,
|
||||
loaderConfig: common.loaderConfig(),
|
||||
out: `out-vscode-${type}`,
|
||||
inlineAmdImages: true,
|
||||
bundleInfo: undefined,
|
||||
fileContentMapper: createVSCodeWebFileContentMapper('.build/extensions', type === 'reh-web' ? tweakProductForServerWeb(product) : product)
|
||||
})
|
||||
));
|
||||
|
||||
const minifyTask = task.define(`minify-vscode-${type}`, task.series(
|
||||
optimizeTask,
|
||||
util.rimraf(`out-vscode-${type}-min`),
|
||||
optimize.minifyTask(`out-vscode-${type}`, `https://ticino.blob.core.windows.net/sourcemaps/${commit}/core`)
|
||||
common.minifyTask(`out-vscode-${type}`, `https://ticino.blob.core.windows.net/sourcemaps/${commit}/core`)
|
||||
));
|
||||
gulp.task(minifyTask);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ const _ = require('underscore');
|
|||
const util = require('./lib/util');
|
||||
const task = require('./lib/task');
|
||||
const buildfile = require('../src/buildfile');
|
||||
const optimize = require('./lib/optimize');
|
||||
const common = require('./lib/optimize');
|
||||
const root = path.dirname(__dirname);
|
||||
const commit = util.getVersion(root);
|
||||
const packageJson = require('../package.json');
|
||||
|
@ -52,6 +52,8 @@ const vscodeEntryPoints = _.flatten([
|
|||
]);
|
||||
|
||||
const vscodeResources = [
|
||||
'out-build/main.js',
|
||||
'out-build/cli.js',
|
||||
'out-build/bootstrap.js',
|
||||
'out-build/bootstrap-fork.js',
|
||||
'out-build/bootstrap-amd.js',
|
||||
|
@ -61,9 +63,12 @@ const vscodeResources = [
|
|||
'!out-build/vs/code/browser/**/*.html',
|
||||
'!out-build/vs/editor/standalone/**/*.svg',
|
||||
'out-build/vs/base/common/performance.js',
|
||||
'out-build/vs/base/common/stripComments.js',
|
||||
'out-build/vs/base/node/languagePacks.js',
|
||||
'out-build/vs/base/node/{stdForkStart.js,terminateProcess.sh,cpuUsage.sh,ps.sh}',
|
||||
'out-build/vs/base/browser/ui/codicons/codicon/**',
|
||||
'out-build/vs/base/parts/sandbox/electron-browser/preload.js',
|
||||
'out-build/vs/platform/environment/node/userDataPath.js',
|
||||
'out-build/vs/workbench/browser/media/*-theme.css',
|
||||
'out-build/vs/workbench/contrib/debug/**/*.json',
|
||||
'out-build/vs/workbench/contrib/externalTerminal/**/*.scpt',
|
||||
|
@ -85,34 +90,14 @@ const vscodeResources = [
|
|||
|
||||
const optimizeVSCodeTask = task.define('optimize-vscode', task.series(
|
||||
util.rimraf('out-vscode'),
|
||||
optimize.optimizeTask(
|
||||
{
|
||||
out: 'out-vscode',
|
||||
amd: {
|
||||
src: 'out-build',
|
||||
entryPoints: vscodeEntryPoints,
|
||||
resources: vscodeResources,
|
||||
loaderConfig: optimize.loaderConfig(),
|
||||
bundleInfo: undefined
|
||||
},
|
||||
commonJS: {
|
||||
src: 'out-build',
|
||||
entryPoints: [
|
||||
'out-build/main.js',
|
||||
'out-build/cli.js'
|
||||
],
|
||||
platform: 'node',
|
||||
external: [
|
||||
'electron',
|
||||
'minimist',
|
||||
// TODO: we cannot inline `product.json` because
|
||||
// it is being changed during build time at a later
|
||||
// point in time (such as `checksums`)
|
||||
'../product.json'
|
||||
]
|
||||
}
|
||||
}
|
||||
)
|
||||
common.optimizeTask({
|
||||
src: 'out-build',
|
||||
entryPoints: vscodeEntryPoints,
|
||||
resources: vscodeResources,
|
||||
loaderConfig: common.loaderConfig(),
|
||||
out: 'out-vscode',
|
||||
bundleInfo: undefined
|
||||
})
|
||||
));
|
||||
gulp.task(optimizeVSCodeTask);
|
||||
|
||||
|
@ -120,7 +105,7 @@ const sourceMappingURLBase = `https://ticino.blob.core.windows.net/sourcemaps/${
|
|||
const minifyVSCodeTask = task.define('minify-vscode', task.series(
|
||||
optimizeVSCodeTask,
|
||||
util.rimraf('out-vscode-min'),
|
||||
optimize.minifyTask('out-vscode', `${sourceMappingURLBase}/core`)
|
||||
common.minifyTask('out-vscode', `${sourceMappingURLBase}/core`)
|
||||
));
|
||||
gulp.task(minifyVSCodeTask);
|
||||
|
||||
|
@ -226,7 +211,7 @@ function packageTask(platform, arch, sourceFolderName, destinationFolderName, op
|
|||
.pipe(json(packageJsonUpdates));
|
||||
|
||||
const date = new Date().toISOString();
|
||||
const productJsonUpdate = { commit, date, checksums, version };
|
||||
const productJsonUpdate = { commit, date, checksums };
|
||||
|
||||
if (shouldSetupSettingsSearch()) {
|
||||
productJsonUpdate.settingsSearchBuildId = getSettingsSearchBuildId(packageJson);
|
||||
|
|
|
@ -10,7 +10,7 @@ const path = require('path');
|
|||
const es = require('event-stream');
|
||||
const util = require('./lib/util');
|
||||
const task = require('./lib/task');
|
||||
const optimize = require('./lib/optimize');
|
||||
const common = require('./lib/optimize');
|
||||
const product = require('../product.json');
|
||||
const rename = require('gulp-rename');
|
||||
const filter = require('gulp-filter');
|
||||
|
@ -153,28 +153,24 @@ exports.createVSCodeWebFileContentMapper = createVSCodeWebFileContentMapper;
|
|||
|
||||
const optimizeVSCodeWebTask = task.define('optimize-vscode-web', task.series(
|
||||
util.rimraf('out-vscode-web'),
|
||||
optimize.optimizeTask(
|
||||
{
|
||||
out: 'out-vscode-web',
|
||||
amd: {
|
||||
src: 'out-build',
|
||||
entryPoints: _.flatten(vscodeWebEntryPoints),
|
||||
otherSources: [],
|
||||
resources: vscodeWebResources,
|
||||
loaderConfig: optimize.loaderConfig(),
|
||||
externalLoaderInfo: util.createExternalLoaderConfig(product.webEndpointUrl, commit, quality),
|
||||
inlineAmdImages: true,
|
||||
bundleInfo: undefined,
|
||||
fileContentMapper: createVSCodeWebFileContentMapper('.build/web/extensions', product)
|
||||
}
|
||||
}
|
||||
)
|
||||
common.optimizeTask({
|
||||
src: 'out-build',
|
||||
entryPoints: _.flatten(vscodeWebEntryPoints),
|
||||
otherSources: [],
|
||||
resources: vscodeWebResources,
|
||||
loaderConfig: common.loaderConfig(),
|
||||
externalLoaderInfo: util.createExternalLoaderConfig(product.webEndpointUrl, commit, quality),
|
||||
out: 'out-vscode-web',
|
||||
inlineAmdImages: true,
|
||||
bundleInfo: undefined,
|
||||
fileContentMapper: createVSCodeWebFileContentMapper('.build/web/extensions', product)
|
||||
})
|
||||
));
|
||||
|
||||
const minifyVSCodeWebTask = task.define('minify-vscode-web', task.series(
|
||||
optimizeVSCodeWebTask,
|
||||
util.rimraf('out-vscode-web-min'),
|
||||
optimize.minifyTask('out-vscode-web', `https://ticino.blob.core.windows.net/sourcemaps/${commit}/core`)
|
||||
common.minifyTask('out-vscode-web', `https://ticino.blob.core.windows.net/sourcemaps/${commit}/core`)
|
||||
));
|
||||
gulp.task(minifyVSCodeWebTask);
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.minifyTask = exports.optimizeTask = exports.optimizeLoaderTask = exports.loaderConfig = void 0;
|
||||
exports.minifyTask = exports.optimizeTask = exports.loaderConfig = void 0;
|
||||
const es = require("event-stream");
|
||||
const gulp = require("gulp");
|
||||
const concat = require("gulp-concat");
|
||||
|
@ -135,83 +135,56 @@ const DEFAULT_FILE_HEADER = [
|
|||
' * Copyright (C) Microsoft Corporation. All rights reserved.',
|
||||
' *--------------------------------------------------------*/'
|
||||
].join('\n');
|
||||
function optimizeAMDTask(opts) {
|
||||
function optimizeTask(opts) {
|
||||
const src = opts.src;
|
||||
const entryPoints = opts.entryPoints;
|
||||
const resources = opts.resources;
|
||||
const loaderConfig = opts.loaderConfig;
|
||||
const bundledFileHeader = opts.header || DEFAULT_FILE_HEADER;
|
||||
const bundleLoader = (typeof opts.bundleLoader === 'undefined' ? true : opts.bundleLoader);
|
||||
const out = opts.out;
|
||||
const fileContentMapper = opts.fileContentMapper || ((contents, _path) => contents);
|
||||
const sourcemaps = require('gulp-sourcemaps');
|
||||
const bundlesStream = es.through(); // this stream will contain the bundled files
|
||||
const resourcesStream = es.through(); // this stream will contain the resources
|
||||
const bundleInfoStream = es.through(); // this stream will contain bundleInfo.json
|
||||
bundle.bundle(entryPoints, loaderConfig, function (err, result) {
|
||||
if (err || !result) {
|
||||
return bundlesStream.emit('error', JSON.stringify(err));
|
||||
}
|
||||
toBundleStream(src, bundledFileHeader, result.files, fileContentMapper).pipe(bundlesStream);
|
||||
// Remove css inlined resources
|
||||
const filteredResources = resources.slice();
|
||||
result.cssInlinedResources.forEach(function (resource) {
|
||||
if (process.env['VSCODE_BUILD_VERBOSE']) {
|
||||
log('optimizer', 'excluding inlined: ' + resource);
|
||||
}
|
||||
filteredResources.push('!' + resource);
|
||||
});
|
||||
gulp.src(filteredResources, { base: `${src}`, allowEmpty: true }).pipe(resourcesStream);
|
||||
const bundleInfoArray = [];
|
||||
if (opts.bundleInfo) {
|
||||
bundleInfoArray.push(new VinylFile({
|
||||
path: 'bundleInfo.json',
|
||||
base: '.',
|
||||
contents: Buffer.from(JSON.stringify(result.bundleData, null, '\t'))
|
||||
}));
|
||||
}
|
||||
es.readArray(bundleInfoArray).pipe(bundleInfoStream);
|
||||
});
|
||||
const result = es.merge(loader(src, bundledFileHeader, false, opts.externalLoaderInfo), bundlesStream, resourcesStream, bundleInfoStream);
|
||||
return result
|
||||
.pipe(sourcemaps.write('./', {
|
||||
sourceRoot: undefined,
|
||||
addComment: true,
|
||||
includeContent: true
|
||||
}))
|
||||
.pipe(opts.languages && opts.languages.length ? (0, i18n_1.processNlsFiles)({
|
||||
fileHeader: bundledFileHeader,
|
||||
languages: opts.languages
|
||||
}) : es.through());
|
||||
}
|
||||
function optimizeCommonJSTask(opts) {
|
||||
const esbuild = require('esbuild');
|
||||
const src = opts.src;
|
||||
const entryPoints = opts.entryPoints;
|
||||
return gulp.src(entryPoints, { base: `${src}`, allowEmpty: true })
|
||||
.pipe(es.map((f, cb) => {
|
||||
esbuild.build({
|
||||
entryPoints: [f.path],
|
||||
bundle: true,
|
||||
platform: opts.platform,
|
||||
write: false,
|
||||
external: opts.external
|
||||
}).then(res => {
|
||||
const jsFile = res.outputFiles[0];
|
||||
f.contents = Buffer.from(jsFile.contents);
|
||||
cb(undefined, f);
|
||||
});
|
||||
}));
|
||||
}
|
||||
function optimizeLoaderTask(src, out, bundleLoader, bundledFileHeader = '', externalLoaderInfo) {
|
||||
return () => loader(src, bundledFileHeader, bundleLoader, externalLoaderInfo).pipe(gulp.dest(out));
|
||||
}
|
||||
exports.optimizeLoaderTask = optimizeLoaderTask;
|
||||
function optimizeTask(opts) {
|
||||
return function () {
|
||||
const optimizers = [optimizeAMDTask(opts.amd)];
|
||||
if (opts.commonJS) {
|
||||
optimizers.push(optimizeCommonJSTask(opts.commonJS));
|
||||
}
|
||||
return es.merge(...optimizers).pipe(gulp.dest(opts.out));
|
||||
const sourcemaps = require('gulp-sourcemaps');
|
||||
const bundlesStream = es.through(); // this stream will contain the bundled files
|
||||
const resourcesStream = es.through(); // this stream will contain the resources
|
||||
const bundleInfoStream = es.through(); // this stream will contain bundleInfo.json
|
||||
bundle.bundle(entryPoints, loaderConfig, function (err, result) {
|
||||
if (err || !result) {
|
||||
return bundlesStream.emit('error', JSON.stringify(err));
|
||||
}
|
||||
toBundleStream(src, bundledFileHeader, result.files, fileContentMapper).pipe(bundlesStream);
|
||||
// Remove css inlined resources
|
||||
const filteredResources = resources.slice();
|
||||
result.cssInlinedResources.forEach(function (resource) {
|
||||
if (process.env['VSCODE_BUILD_VERBOSE']) {
|
||||
log('optimizer', 'excluding inlined: ' + resource);
|
||||
}
|
||||
filteredResources.push('!' + resource);
|
||||
});
|
||||
gulp.src(filteredResources, { base: `${src}`, allowEmpty: true }).pipe(resourcesStream);
|
||||
const bundleInfoArray = [];
|
||||
if (opts.bundleInfo) {
|
||||
bundleInfoArray.push(new VinylFile({
|
||||
path: 'bundleInfo.json',
|
||||
base: '.',
|
||||
contents: Buffer.from(JSON.stringify(result.bundleData, null, '\t'))
|
||||
}));
|
||||
}
|
||||
es.readArray(bundleInfoArray).pipe(bundleInfoStream);
|
||||
});
|
||||
const result = es.merge(loader(src, bundledFileHeader, bundleLoader, opts.externalLoaderInfo), bundlesStream, resourcesStream, bundleInfoStream);
|
||||
return result
|
||||
.pipe(sourcemaps.write('./', {
|
||||
sourceRoot: undefined,
|
||||
addComment: true,
|
||||
includeContent: true
|
||||
}))
|
||||
.pipe(opts.languages && opts.languages.length ? (0, i18n_1.processNlsFiles)({
|
||||
fileHeader: bundledFileHeader,
|
||||
languages: opts.languages
|
||||
}) : es.through())
|
||||
.pipe(gulp.dest(out));
|
||||
};
|
||||
}
|
||||
exports.optimizeTask = optimizeTask;
|
||||
|
|
|
@ -153,7 +153,7 @@ function toBundleStream(src: string, bundledFileHeader: string, bundles: bundle.
|
|||
}));
|
||||
}
|
||||
|
||||
export interface IOptimizeAMDTaskOpts {
|
||||
export interface IOptimizeTaskOpts {
|
||||
/**
|
||||
* The folder to read files from.
|
||||
*/
|
||||
|
@ -184,7 +184,11 @@ export interface IOptimizeAMDTaskOpts {
|
|||
*/
|
||||
bundleInfo: boolean;
|
||||
/**
|
||||
* Language configuration.
|
||||
* (out folder name)
|
||||
*/
|
||||
out: string;
|
||||
/**
|
||||
* (out folder name)
|
||||
*/
|
||||
languages?: Language[];
|
||||
/**
|
||||
|
@ -201,125 +205,67 @@ const DEFAULT_FILE_HEADER = [
|
|||
' *--------------------------------------------------------*/'
|
||||
].join('\n');
|
||||
|
||||
function optimizeAMDTask(opts: IOptimizeAMDTaskOpts): NodeJS.ReadWriteStream {
|
||||
export function optimizeTask(opts: IOptimizeTaskOpts): () => NodeJS.ReadWriteStream {
|
||||
const src = opts.src;
|
||||
const entryPoints = opts.entryPoints;
|
||||
const resources = opts.resources;
|
||||
const loaderConfig = opts.loaderConfig;
|
||||
const bundledFileHeader = opts.header || DEFAULT_FILE_HEADER;
|
||||
const bundleLoader = (typeof opts.bundleLoader === 'undefined' ? true : opts.bundleLoader);
|
||||
const out = opts.out;
|
||||
const fileContentMapper = opts.fileContentMapper || ((contents: string, _path: string) => contents);
|
||||
|
||||
const sourcemaps = require('gulp-sourcemaps') as typeof import('gulp-sourcemaps');
|
||||
|
||||
const bundlesStream = es.through(); // this stream will contain the bundled files
|
||||
const resourcesStream = es.through(); // this stream will contain the resources
|
||||
const bundleInfoStream = es.through(); // this stream will contain bundleInfo.json
|
||||
|
||||
bundle.bundle(entryPoints, loaderConfig, function (err, result) {
|
||||
if (err || !result) { return bundlesStream.emit('error', JSON.stringify(err)); }
|
||||
|
||||
toBundleStream(src, bundledFileHeader, result.files, fileContentMapper).pipe(bundlesStream);
|
||||
|
||||
// Remove css inlined resources
|
||||
const filteredResources = resources.slice();
|
||||
result.cssInlinedResources.forEach(function (resource) {
|
||||
if (process.env['VSCODE_BUILD_VERBOSE']) {
|
||||
log('optimizer', 'excluding inlined: ' + resource);
|
||||
}
|
||||
filteredResources.push('!' + resource);
|
||||
});
|
||||
gulp.src(filteredResources, { base: `${src}`, allowEmpty: true }).pipe(resourcesStream);
|
||||
|
||||
const bundleInfoArray: VinylFile[] = [];
|
||||
if (opts.bundleInfo) {
|
||||
bundleInfoArray.push(new VinylFile({
|
||||
path: 'bundleInfo.json',
|
||||
base: '.',
|
||||
contents: Buffer.from(JSON.stringify(result.bundleData, null, '\t'))
|
||||
}));
|
||||
}
|
||||
es.readArray(bundleInfoArray).pipe(bundleInfoStream);
|
||||
});
|
||||
|
||||
const result = es.merge(
|
||||
loader(src, bundledFileHeader, false, opts.externalLoaderInfo),
|
||||
bundlesStream,
|
||||
resourcesStream,
|
||||
bundleInfoStream
|
||||
);
|
||||
|
||||
return result
|
||||
.pipe(sourcemaps.write('./', {
|
||||
sourceRoot: undefined,
|
||||
addComment: true,
|
||||
includeContent: true
|
||||
}))
|
||||
.pipe(opts.languages && opts.languages.length ? processNlsFiles({
|
||||
fileHeader: bundledFileHeader,
|
||||
languages: opts.languages
|
||||
}) : es.through());
|
||||
}
|
||||
|
||||
export interface IOptimizeCommonJSTaskOpts {
|
||||
/**
|
||||
* The paths to consider for optimizing.
|
||||
*/
|
||||
entryPoints: string[];
|
||||
/**
|
||||
* The folder to read files from.
|
||||
*/
|
||||
src: string;
|
||||
/**
|
||||
* ESBuild `platform` option: https://esbuild.github.io/api/#platform
|
||||
*/
|
||||
platform: 'browser' | 'node' | 'neutral';
|
||||
/**
|
||||
* ESBuild `external` option: https://esbuild.github.io/api/#external
|
||||
*/
|
||||
external: string[];
|
||||
}
|
||||
|
||||
function optimizeCommonJSTask(opts: IOptimizeCommonJSTaskOpts): NodeJS.ReadWriteStream {
|
||||
const esbuild = require('esbuild') as typeof import('esbuild');
|
||||
|
||||
const src = opts.src;
|
||||
const entryPoints = opts.entryPoints;
|
||||
|
||||
return gulp.src(entryPoints, { base: `${src}`, allowEmpty: true })
|
||||
.pipe(es.map((f: any, cb) => {
|
||||
esbuild.build({
|
||||
entryPoints: [f.path],
|
||||
bundle: true,
|
||||
platform: opts.platform,
|
||||
write: false,
|
||||
external: opts.external
|
||||
}).then(res => {
|
||||
const jsFile = res.outputFiles[0];
|
||||
f.contents = Buffer.from(jsFile.contents);
|
||||
|
||||
cb(undefined, f);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
export function optimizeLoaderTask(src: string, out: string, bundleLoader: boolean, bundledFileHeader = '', externalLoaderInfo?: any): () => NodeJS.ReadWriteStream {
|
||||
return () => loader(src, bundledFileHeader, bundleLoader, externalLoaderInfo).pipe(gulp.dest(out));
|
||||
}
|
||||
|
||||
export interface IOptimizeTaskOpts {
|
||||
out: string;
|
||||
amd: IOptimizeAMDTaskOpts;
|
||||
commonJS?: IOptimizeCommonJSTaskOpts;
|
||||
}
|
||||
|
||||
export function optimizeTask(opts: IOptimizeTaskOpts): () => NodeJS.ReadWriteStream {
|
||||
return function () {
|
||||
const optimizers = [optimizeAMDTask(opts.amd)];
|
||||
if (opts.commonJS) {
|
||||
optimizers.push(optimizeCommonJSTask(opts.commonJS));
|
||||
}
|
||||
const sourcemaps = require('gulp-sourcemaps') as typeof import('gulp-sourcemaps');
|
||||
|
||||
return es.merge(...optimizers).pipe(gulp.dest(opts.out));
|
||||
const bundlesStream = es.through(); // this stream will contain the bundled files
|
||||
const resourcesStream = es.through(); // this stream will contain the resources
|
||||
const bundleInfoStream = es.through(); // this stream will contain bundleInfo.json
|
||||
|
||||
bundle.bundle(entryPoints, loaderConfig, function (err, result) {
|
||||
if (err || !result) { return bundlesStream.emit('error', JSON.stringify(err)); }
|
||||
|
||||
toBundleStream(src, bundledFileHeader, result.files, fileContentMapper).pipe(bundlesStream);
|
||||
|
||||
// Remove css inlined resources
|
||||
const filteredResources = resources.slice();
|
||||
result.cssInlinedResources.forEach(function (resource) {
|
||||
if (process.env['VSCODE_BUILD_VERBOSE']) {
|
||||
log('optimizer', 'excluding inlined: ' + resource);
|
||||
}
|
||||
filteredResources.push('!' + resource);
|
||||
});
|
||||
gulp.src(filteredResources, { base: `${src}`, allowEmpty: true }).pipe(resourcesStream);
|
||||
|
||||
const bundleInfoArray: VinylFile[] = [];
|
||||
if (opts.bundleInfo) {
|
||||
bundleInfoArray.push(new VinylFile({
|
||||
path: 'bundleInfo.json',
|
||||
base: '.',
|
||||
contents: Buffer.from(JSON.stringify(result.bundleData, null, '\t'))
|
||||
}));
|
||||
}
|
||||
es.readArray(bundleInfoArray).pipe(bundleInfoStream);
|
||||
});
|
||||
|
||||
const result = es.merge(
|
||||
loader(src, bundledFileHeader, bundleLoader, opts.externalLoaderInfo),
|
||||
bundlesStream,
|
||||
resourcesStream,
|
||||
bundleInfoStream
|
||||
);
|
||||
|
||||
return result
|
||||
.pipe(sourcemaps.write('./', {
|
||||
sourceRoot: undefined,
|
||||
addComment: true,
|
||||
includeContent: true
|
||||
}))
|
||||
.pipe(opts.languages && opts.languages.length ? processNlsFiles({
|
||||
fileHeader: bundledFileHeader,
|
||||
languages: opts.languages
|
||||
}) : es.through())
|
||||
.pipe(gulp.dest(out));
|
||||
};
|
||||
}
|
||||
|
||||
|
|
7
src/bootstrap-amd.js
vendored
7
src/bootstrap-amd.js
vendored
|
@ -6,11 +6,6 @@
|
|||
//@ts-check
|
||||
'use strict';
|
||||
|
||||
// Store the node.js require function in a variable
|
||||
// before loading our AMD loader to avoid issues
|
||||
// when this file is bundled with other files.
|
||||
const nodeRequire = require;
|
||||
|
||||
const loader = require('./vs/loader');
|
||||
const bootstrap = require('./bootstrap');
|
||||
const performance = require('./vs/base/common/performance');
|
||||
|
@ -22,7 +17,7 @@ const nlsConfig = bootstrap.setupNLS();
|
|||
loader.config({
|
||||
baseUrl: bootstrap.fileUriFromPath(__dirname, { isWindows: process.platform === 'win32' }),
|
||||
catchError: true,
|
||||
nodeRequire,
|
||||
nodeRequire: require,
|
||||
'vs/nls': nlsConfig,
|
||||
amdModulesPattern: /^vs\//,
|
||||
recordStats: true
|
||||
|
|
|
@ -35,6 +35,7 @@ exports.base = [
|
|||
exclude: ['vs/nls'],
|
||||
prepend: [
|
||||
{ path: 'vs/loader.js' },
|
||||
{ path: 'vs/nls.js', amdModuleId: 'vs/nls' },
|
||||
{ path: 'vs/base/worker/workerMain.js' }
|
||||
],
|
||||
dest: 'vs/base/worker/workerMain.js'
|
||||
|
|
|
@ -34,7 +34,7 @@ bootstrap.enableASARSupport();
|
|||
|
||||
// Set userData path before app 'ready' event
|
||||
const args = parseCLIArgs();
|
||||
const userDataPath = getUserDataPath(args, product.nameShort ?? 'code-oss-dev');
|
||||
const userDataPath = getUserDataPath(args);
|
||||
app.setPath('userData', userDataPath);
|
||||
|
||||
// Resolve code cache path
|
||||
|
|
|
@ -15,7 +15,7 @@ export class NativeEnvironmentService extends AbstractNativeEnvironmentService {
|
|||
super(args, {
|
||||
homeDir: homedir(),
|
||||
tmpDir: tmpdir(),
|
||||
userDataDir: getUserDataPath(args, productService.nameShort)
|
||||
userDataDir: getUserDataPath(args)
|
||||
}, productService);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,4 +11,4 @@ import { NativeParsedArgs } from 'vs/platform/environment/common/argv';
|
|||
* - respect VSCODE_APPDATA environment variable
|
||||
* - respect --user-data-dir CLI argument
|
||||
*/
|
||||
export function getUserDataPath(args: NativeParsedArgs, productName: string): string;
|
||||
export function getUserDataPath(args: NativeParsedArgs): string;
|
||||
|
|
|
@ -14,18 +14,18 @@
|
|||
*
|
||||
* @param {typeof import('path')} path
|
||||
* @param {typeof import('os')} os
|
||||
* @param {string} productName
|
||||
* @param {string} cwd
|
||||
*/
|
||||
function factory(path, os, cwd) {
|
||||
function factory(path, os, productName, cwd) {
|
||||
|
||||
/**
|
||||
* @param {NativeParsedArgs} cliArgs
|
||||
* @param {string} productName
|
||||
*
|
||||
* @returns {string}
|
||||
*/
|
||||
function getUserDataPath(cliArgs, productName) {
|
||||
const userDataPath = doGetUserDataPath(cliArgs, productName);
|
||||
function getUserDataPath(cliArgs) {
|
||||
const userDataPath = doGetUserDataPath(cliArgs);
|
||||
const pathsToResolve = [userDataPath];
|
||||
|
||||
// If the user-data-path is not absolute, make
|
||||
|
@ -43,11 +43,10 @@
|
|||
|
||||
/**
|
||||
* @param {NativeParsedArgs} cliArgs
|
||||
* @param {string} productName
|
||||
*
|
||||
* @returns {string}
|
||||
*/
|
||||
function doGetUserDataPath(cliArgs, productName) {
|
||||
function doGetUserDataPath(cliArgs) {
|
||||
|
||||
// 0. Running out of sources has a fixed productName
|
||||
if (process.env['VSCODE_DEV']) {
|
||||
|
@ -107,18 +106,25 @@
|
|||
}
|
||||
|
||||
if (typeof define === 'function') {
|
||||
define(['path', 'os', 'vs/base/common/process'], function (
|
||||
define(['require', 'path', 'os', 'vs/base/common/network', 'vs/base/common/resources', 'vs/base/common/process'], function (
|
||||
require,
|
||||
/** @type {typeof import('path')} */ path,
|
||||
/** @type {typeof import('os')} */ os,
|
||||
/** @type {typeof import('../../../base/common/network')} */ network,
|
||||
/** @type {typeof import("../../../base/common/resources")} */ resources,
|
||||
/** @type {typeof import("../../../base/common/process")} */ process
|
||||
) {
|
||||
return factory(path, os, process.cwd()); // amd
|
||||
});
|
||||
const rootPath = resources.dirname(network.FileAccess.asFileUri('', require));
|
||||
const pkg = require.__$__nodeRequire(resources.joinPath(rootPath, 'package.json').fsPath);
|
||||
|
||||
return factory(path, os, pkg.name, process.cwd());
|
||||
}); // amd
|
||||
} else if (typeof module === 'object' && typeof module.exports === 'object') {
|
||||
const pkg = require('../../../../../package.json');
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
|
||||
module.exports = factory(path, os, process.env['VSCODE_CWD'] || process.cwd()); // commonjs
|
||||
module.exports = factory(path, os, pkg.name, process.env['VSCODE_CWD'] || process.cwd()); // commonjs
|
||||
} else {
|
||||
throw new Error('Unknown context');
|
||||
}
|
||||
|
|
|
@ -6,12 +6,11 @@
|
|||
import * as assert from 'assert';
|
||||
import { OPTIONS, parseArgs } from 'vs/platform/environment/node/argv';
|
||||
import { getUserDataPath } from 'vs/platform/environment/node/userDataPath';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
|
||||
suite('User data path', () => {
|
||||
|
||||
test('getUserDataPath - default', () => {
|
||||
const path = getUserDataPath(parseArgs(process.argv, OPTIONS), product.nameShort);
|
||||
const path = getUserDataPath(parseArgs(process.argv, OPTIONS));
|
||||
assert.ok(path.length > 0);
|
||||
});
|
||||
|
||||
|
@ -21,7 +20,7 @@ suite('User data path', () => {
|
|||
const portableDir = 'portable-dir';
|
||||
process.env['VSCODE_PORTABLE'] = portableDir;
|
||||
|
||||
const path = getUserDataPath(parseArgs(process.argv, OPTIONS), product.nameShort);
|
||||
const path = getUserDataPath(parseArgs(process.argv, OPTIONS));
|
||||
assert.ok(path.includes(portableDir));
|
||||
} finally {
|
||||
if (typeof origPortable === 'string') {
|
||||
|
@ -37,7 +36,7 @@ suite('User data path', () => {
|
|||
const args = parseArgs(process.argv, OPTIONS);
|
||||
args['user-data-dir'] = cliUserDataDir;
|
||||
|
||||
const path = getUserDataPath(args, product.nameShort);
|
||||
const path = getUserDataPath(args);
|
||||
assert.ok(path.includes(cliUserDataDir));
|
||||
});
|
||||
|
||||
|
@ -47,7 +46,7 @@ suite('User data path', () => {
|
|||
const appDataDir = 'appdata-dir';
|
||||
process.env['VSCODE_APPDATA'] = appDataDir;
|
||||
|
||||
const path = getUserDataPath(parseArgs(process.argv, OPTIONS), product.nameShort);
|
||||
const path = getUserDataPath(parseArgs(process.argv, OPTIONS));
|
||||
assert.ok(path.includes(appDataDir));
|
||||
} finally {
|
||||
if (typeof origAppData === 'string') {
|
||||
|
|
|
@ -32,6 +32,7 @@ else if (typeof require?.__$__nodeRequire === 'function') {
|
|||
const rootPath = dirname(FileAccess.asFileUri('', require));
|
||||
|
||||
product = require.__$__nodeRequire(joinPath(rootPath, 'product.json').fsPath);
|
||||
const pkg = require.__$__nodeRequire(joinPath(rootPath, 'package.json').fsPath) as { version: string };
|
||||
|
||||
// Running out of sources
|
||||
if (env['VSCODE_DEV']) {
|
||||
|
@ -43,16 +44,9 @@ else if (typeof require?.__$__nodeRequire === 'function') {
|
|||
});
|
||||
}
|
||||
|
||||
// Version is added during built time, but we still
|
||||
// want to have it running out of sources so we
|
||||
// read it from package.json only when we need it.
|
||||
if (!product.version) {
|
||||
const pkg = require.__$__nodeRequire(joinPath(rootPath, 'package.json').fsPath) as { version: string };
|
||||
|
||||
Object.assign(product, {
|
||||
version: pkg.version
|
||||
});
|
||||
}
|
||||
Object.assign(product, {
|
||||
version: pkg.version
|
||||
});
|
||||
}
|
||||
|
||||
// Web environment or unknown
|
||||
|
|
|
@ -84,7 +84,7 @@ export const TestNativeWindowConfiguration: INativeWindowConfiguration = {
|
|||
product,
|
||||
homeDir: homeDir,
|
||||
tmpDir: tmpdir(),
|
||||
userDataDir: getUserDataPath(args, product.nameShort),
|
||||
userDataDir: getUserDataPath(args),
|
||||
profiles: { profile: NULL_PROFILE, all: [NULL_PROFILE] },
|
||||
...args
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue