Adopt new style gulp tasks for the editor (#67863)
This commit is contained in:
parent
add9437982
commit
c9352c4ca9
3 changed files with 86 additions and 88 deletions
|
@ -63,7 +63,7 @@ var BUNDLED_FILE_HEADER = [
|
|||
|
||||
const languages = i18n.defaultLanguages.concat([]); // i18n.defaultLanguages.concat(process.env.VSCODE_QUALITY !== 'stable' ? i18n.extraLanguages : []);
|
||||
|
||||
gulp.task('extract-editor-src', util.task.series(util.rimraf('out-editor-src'), function () {
|
||||
const extractEditorSrcTask = function () {
|
||||
console.log(`If the build fails, consider tweaking shakeLevel below to a lower value.`);
|
||||
const apiusages = monacoapi.execute().usageContent;
|
||||
const extrausages = fs.readFileSync(path.join(root, 'build', 'monaco', 'monaco.usage.recipe')).toString();
|
||||
|
@ -98,14 +98,13 @@ gulp.task('extract-editor-src', util.task.series(util.rimraf('out-editor-src'),
|
|||
importIgnorePattern: /(^vs\/css!)|(promise-polyfill\/polyfill)/,
|
||||
destRoot: path.join(root, 'out-editor-src')
|
||||
});
|
||||
}));
|
||||
};
|
||||
extractEditorSrcTask.displayName = 'extract-editor-src';
|
||||
|
||||
// Full compile, including nls and inline sources in sourcemaps, for build
|
||||
gulp.task('clean-editor-build', util.rimraf('out-editor-build'));
|
||||
gulp.task('compile-editor-build', ['clean-editor-build', 'extract-editor-src'], compilation.compileTask('out-editor-src', 'out-editor-build', true));
|
||||
const compileEditorAMDTask = compilation.compileTask('out-editor-src', 'out-editor-build', true);
|
||||
compileEditorAMDTask.displayName = 'compile-editor-amd';
|
||||
|
||||
gulp.task('clean-optimized-editor', util.rimraf('out-editor'));
|
||||
gulp.task('optimize-editor', ['clean-optimized-editor', 'compile-editor-build'], common.optimizeTask({
|
||||
const optimizeEditorAMDTask = common.optimizeTask({
|
||||
src: 'out-editor-build',
|
||||
entryPoints: editorEntryPoints,
|
||||
otherSources: editorOtherSources,
|
||||
|
@ -123,13 +122,13 @@ gulp.task('optimize-editor', ['clean-optimized-editor', 'compile-editor-build'],
|
|||
bundleInfo: true,
|
||||
out: 'out-editor',
|
||||
languages: languages
|
||||
}));
|
||||
});
|
||||
optimizeEditorAMDTask.displayName = 'optimize-editor-amd';
|
||||
|
||||
gulp.task('clean-minified-editor', util.rimraf('out-editor-min'));
|
||||
gulp.task('minify-editor', ['clean-minified-editor', 'optimize-editor'], common.minifyTask('out-editor'));
|
||||
const minifyEditorAMDTask = common.minifyTask('out-editor');
|
||||
minifyEditorAMDTask.displayName = 'minify-editor-amd';
|
||||
|
||||
gulp.task('clean-editor-esm', util.rimraf('out-editor-esm'));
|
||||
gulp.task('extract-editor-esm', ['clean-editor-esm', 'clean-editor-distro', 'extract-editor-src'], function () {
|
||||
const createESMSourcesAndResourcesTask = function () {
|
||||
standalone.createESMSourcesAndResources2({
|
||||
srcFolder: './out-editor-src',
|
||||
outFolder: './out-editor-esm',
|
||||
|
@ -150,8 +149,10 @@ gulp.task('extract-editor-esm', ['clean-editor-esm', 'clean-editor-distro', 'ext
|
|||
'vs/nls.mock.ts': 'vs/nls.ts'
|
||||
}
|
||||
});
|
||||
});
|
||||
gulp.task('compile-editor-esm', ['extract-editor-esm', 'clean-editor-distro'], function () {
|
||||
};
|
||||
createESMSourcesAndResourcesTask.displayName = 'extract-editor-esm';
|
||||
|
||||
const compileEditorESMTask = function () {
|
||||
if (process.platform === 'win32') {
|
||||
const result = cp.spawnSync(`..\\node_modules\\.bin\\tsc.cmd`, {
|
||||
cwd: path.join(__dirname, '../out-editor-esm')
|
||||
|
@ -165,7 +166,8 @@ gulp.task('compile-editor-esm', ['extract-editor-esm', 'clean-editor-distro'], f
|
|||
console.log(result.stdout.toString());
|
||||
console.log(result.stderr.toString());
|
||||
}
|
||||
});
|
||||
};
|
||||
compileEditorESMTask.displayName = 'compile-editor-esm';
|
||||
|
||||
function toExternalDTS(contents) {
|
||||
let lines = contents.split('\n');
|
||||
|
@ -202,8 +204,16 @@ function toExternalDTS(contents) {
|
|||
return lines.join('\n');
|
||||
}
|
||||
|
||||
gulp.task('clean-editor-distro', util.rimraf('out-monaco-editor-core'));
|
||||
gulp.task('editor-distro', ['clean-editor-distro', 'compile-editor-esm', 'minify-editor', 'optimize-editor'], function () {
|
||||
function filterStream(testFunc) {
|
||||
return es.through(function (data) {
|
||||
if (!testFunc(data.relative)) {
|
||||
return;
|
||||
}
|
||||
this.emit('data', data);
|
||||
});
|
||||
}
|
||||
|
||||
const finalEditorResourcesTask = function () {
|
||||
return es.merge(
|
||||
// other assets
|
||||
es.merge(
|
||||
|
@ -280,61 +290,34 @@ gulp.task('editor-distro', ['clean-editor-distro', 'compile-editor-esm', 'minify
|
|||
return /\.js\.map$/.test(path);
|
||||
})).pipe(gulp.dest('out-monaco-editor-core/min-maps'))
|
||||
);
|
||||
});
|
||||
|
||||
gulp.task('analyze-editor-distro', function () {
|
||||
// @ts-ignore
|
||||
var bundleInfo = require('../out-editor/bundleInfo.json');
|
||||
var graph = bundleInfo.graph;
|
||||
var bundles = bundleInfo.bundles;
|
||||
|
||||
var inverseGraph = {};
|
||||
Object.keys(graph).forEach(function (module) {
|
||||
var dependencies = graph[module];
|
||||
dependencies.forEach(function (dep) {
|
||||
inverseGraph[dep] = inverseGraph[dep] || [];
|
||||
inverseGraph[dep].push(module);
|
||||
});
|
||||
});
|
||||
|
||||
var detailed = {};
|
||||
Object.keys(bundles).forEach(function (entryPoint) {
|
||||
var included = bundles[entryPoint];
|
||||
var includedMap = {};
|
||||
included.forEach(function (included) {
|
||||
includedMap[included] = true;
|
||||
});
|
||||
|
||||
var explanation = [];
|
||||
included.map(function (included) {
|
||||
if (included.indexOf('!') >= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var reason = (inverseGraph[included] || []).filter(function (mod) {
|
||||
return !!includedMap[mod];
|
||||
});
|
||||
explanation.push({
|
||||
module: included,
|
||||
reason: reason
|
||||
});
|
||||
});
|
||||
|
||||
detailed[entryPoint] = explanation;
|
||||
});
|
||||
|
||||
console.log(JSON.stringify(detailed, null, '\t'));
|
||||
});
|
||||
|
||||
function filterStream(testFunc) {
|
||||
return es.through(function (data) {
|
||||
if (!testFunc(data.relative)) {
|
||||
return;
|
||||
}
|
||||
this.emit('data', data);
|
||||
});
|
||||
}
|
||||
};
|
||||
finalEditorResourcesTask.displayName = 'final-editor-resources';
|
||||
|
||||
gulp.task('editor-distro',
|
||||
util.task.series(
|
||||
util.task.parallel(
|
||||
util.rimraf('out-editor-src'),
|
||||
util.rimraf('out-editor-build'),
|
||||
util.rimraf('out-editor-esm'),
|
||||
util.rimraf('out-monaco-editor-core'),
|
||||
util.rimraf('out-editor'),
|
||||
util.rimraf('out-editor-min')
|
||||
),
|
||||
extractEditorSrcTask,
|
||||
util.task.parallel(
|
||||
util.task.series(
|
||||
compileEditorAMDTask,
|
||||
optimizeEditorAMDTask,
|
||||
minifyEditorAMDTask
|
||||
),
|
||||
util.task.series(
|
||||
createESMSourcesAndResourcesTask,
|
||||
compileEditorESMTask
|
||||
)
|
||||
),
|
||||
finalEditorResourcesTask
|
||||
)
|
||||
);
|
||||
|
||||
//#region monaco type checking
|
||||
|
||||
|
|
|
@ -209,21 +209,28 @@ var task;
|
|||
async function _execute(task) {
|
||||
// Always invoke as if it were a callback task
|
||||
return new Promise((resolve, reject) => {
|
||||
const taskResult = task((err) => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
if (task.length === 1) {
|
||||
// this is a calback task
|
||||
task((err) => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
return;
|
||||
}
|
||||
const taskResult = task();
|
||||
if (typeof taskResult === 'undefined') {
|
||||
// this was a callback task
|
||||
// this is a sync task
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
if (_isPromise(taskResult)) {
|
||||
// this was a promise returning task
|
||||
// this is a promise returning task
|
||||
taskResult.then(resolve, reject);
|
||||
return;
|
||||
}
|
||||
// this is a stream returning task
|
||||
taskResult.on('end', _ => resolve());
|
||||
taskResult.on('error', err => reject(err));
|
||||
});
|
||||
|
|
|
@ -254,7 +254,7 @@ export function primraf(dir: string): Promise<void> {
|
|||
|
||||
export type PromiseTask = () => Promise<void>;
|
||||
export type StreamTask = () => NodeJS.ReadWriteStream;
|
||||
export type CallbackTask = (cb: (err?: any) => void) => void;
|
||||
export type CallbackTask = (cb?: (err?: any) => void) => void;
|
||||
export type Task = PromiseTask | StreamTask | CallbackTask;
|
||||
|
||||
export namespace task {
|
||||
|
@ -269,24 +269,32 @@ export namespace task {
|
|||
async function _execute(task: Task): Promise<void> {
|
||||
// Always invoke as if it were a callback task
|
||||
return new Promise((resolve, reject) => {
|
||||
const taskResult = task((err) => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
if (task.length === 1) {
|
||||
// this is a calback task
|
||||
task((err) => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const taskResult = task();
|
||||
|
||||
if (typeof taskResult === 'undefined') {
|
||||
// this was a callback task
|
||||
// this is a sync task
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (_isPromise(taskResult)) {
|
||||
// this was a promise returning task
|
||||
// this is a promise returning task
|
||||
taskResult.then(resolve, reject);
|
||||
return;
|
||||
}
|
||||
|
||||
// this is a stream returning task
|
||||
taskResult.on('end', _ => resolve());
|
||||
taskResult.on('error', err => reject(err));
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue