Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.53.0-dev-20241119 #21

Open
wants to merge 10 commits into
base: feat/monaco-core-0.53.x-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/gulpfile.compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function makeCompileBuildTask(disableMangle) {
util.rimraf('out-build'),
date.writeISODate('out-build'),
compilation.compileApiProposalNamesTask,
compilation.compileTask('src', 'out-build', true, { disableMangle })
compilation.compileTask('src', 'out-build', true, { disableMangle, extractConstEnum: true })
);
}

Expand Down
60 changes: 57 additions & 3 deletions build/gulpfile.editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ const extractEditorSrcTask = task.define('extract-editor-src', () => {

// Disable mangling for the editor, as it complicates debugging & quite a few users rely on private/protected fields.
// Disable NLS task to remove english strings to preserve backwards compatibility when we removed the `vs/nls!` AMD plugin.
const compileEditorAMDTask = task.define('compile-editor-amd', compilation.compileTask('out-editor-src', 'out-editor-build', true, { disableMangle: true, preserveEnglish: true }));
const compileEditorAMDTask = task.define('compile-editor-amd', compilation.compileTask('out-editor-src', 'out-editor-build', true, { disableMangle: true, preserveEnglish: true, extractConstEnum: true }, false));
const compileEditorEsmTask = task.define('compile-editor-esm-core', compilation.compileTask('out-editor-esm', 'out-monaco-editor-core/esm', true, { disableMangle: true, extractConstEnum: true }, true, 1 /** CommonJS */));

const bundleEditorAMDTask = task.define('bundle-editor-amd', optimize.bundleTask(
{
Expand All @@ -110,6 +111,20 @@ const createESMSourcesAndResourcesTask = task.define('extract-editor-esm', () =>
ignores: [
'inlineEntryPoint:0.ts',
'inlineEntryPoint:1.ts',
'inlineEntryPoint:0.js',
'inlineEntryPoint:1.js',
'inlineEntryPoint:0.js.map',
'inlineEntryPoint:1.js.map',
'inlineEntryPoint:0.d.ts',
'inlineEntryPoint:1.d.ts',
'inlineEntryPoint.0.ts',
'inlineEntryPoint.1.ts',
'inlineEntryPoint.0.js',
'inlineEntryPoint.1.js',
'inlineEntryPoint.0.js.map',
'inlineEntryPoint.1.js.map',
'inlineEntryPoint.0.d.ts',
'inlineEntryPoint.1.d.ts',
'vs/loader.js',
'vs/base/worker/workerMain.ts',
],
Expand Down Expand Up @@ -345,6 +360,13 @@ gulp.task('extract-editor-src',
)
);

const monacodtsTask = task.define('monacodts', () => {
const result = monacoapi.execute();
fs.writeFileSync(result.filePath, result.content);
fs.writeFileSync(path.join(root, 'src/vs/editor/common/standalone/standaloneEnums.ts'), result.enums);
return Promise.resolve(true);
});

gulp.task('editor-distro',
task.series(
task.parallel(
Expand All @@ -356,21 +378,53 @@ gulp.task('editor-distro',
util.rimraf('out-editor-min')
),
extractEditorSrcTask,
monacodtsTask,
task.parallel(
task.series(
compileEditorAMDTask,
bundleEditorAMDTask,
minifyEditorAMDTask
// minifyEditorAMDTask
),
task.series(
createESMSourcesAndResourcesTask,
compileEditorESMTask,
compileEditorEsmTask
)
),
finalEditorResourcesTask
)
);

const bundleEditorESMTask = task.define('editor-esm-bundle-webpack', () => {
const webpack = require('webpack');
const webpackGulp = require('webpack-stream');

const result = es.through();

const webpackConfigPath = path.join(root, 'build/monaco/monaco.webpack.config.js');

const webpackConfig = {
...require(webpackConfigPath),
...{ mode: 'production' }
};

const webpackDone = (err, stats) => {
if (err) {
result.emit('error', err);
return;
}
const { compilation } = stats;
if (compilation.errors.length > 0) {
result.emit('error', compilation.errors.join('\n'));
}
if (compilation.warnings.length > 0) {
result.emit('data', compilation.warnings.join('\n'));
}
};

return webpackGulp(webpackConfig, webpack, webpackDone)
.pipe(gulp.dest('out-editor-esm-bundle'));
});

gulp.task('editor-esm',
task.series(
task.parallel(
Expand Down
5 changes: 5 additions & 0 deletions build/hygiene.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const copyrightHeaderLines = [
' * Licensed under the MIT License. See License.txt in the project root for license information.',
' *--------------------------------------------------------------------------------------------*/',
];
const skipCopyrightFiles = ['src/vs/base/browser/settings.ts'];

function hygiene(some, linting = true) {
const eslint = require('./gulp-eslint');
Expand Down Expand Up @@ -98,6 +99,10 @@ function hygiene(some, linting = true) {
});

const copyrights = es.through(function (file) {
if (skipCopyrightFiles.includes(file.relative)) {
this.emit('data', file);
return;
}
const lines = file.__lines;

for (let i = 0; i < copyrightHeaderLines.length; i++) {
Expand Down
21 changes: 17 additions & 4 deletions build/lib/compilation.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 20 additions & 5 deletions build/lib/compilation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ const watch = require('./watch');

const reporter = createReporter();

function getTypeScriptCompilerOptions(src: string): ts.CompilerOptions {
function getTypeScriptCompilerOptions(src: string, module?: ts.ModuleKind): ts.CompilerOptions {
const rootDir = path.join(__dirname, `../../${src}`);
const options: ts.CompilerOptions = {};
options.verbose = false;
options.sourceMap = true;
if (module) {
options.module = module;
}
if (process.env['VSCODE_NO_SOURCEMAP']) { // To be used by developers in a hurry
options.sourceMap = false;
}
Expand All @@ -47,17 +50,19 @@ interface ICompileTaskOptions {
readonly emitError: boolean;
readonly transpileOnly: boolean | { esbuild: boolean };
readonly preserveEnglish: boolean;
readonly module?: ts.ModuleKind;
}

function createCompile(src: string, { build, emitError, transpileOnly, preserveEnglish }: ICompileTaskOptions) {
function createCompile(src: string, { build, emitError, transpileOnly, preserveEnglish, module }: ICompileTaskOptions) {
const tsb = require('./tsb') as typeof import('./tsb');
const sourcemaps = require('gulp-sourcemaps') as typeof import('gulp-sourcemaps');


const projectPath = path.join(__dirname, '../../', src, 'tsconfig.json');
const overrideOptions = { ...getTypeScriptCompilerOptions(src), inlineSources: Boolean(build) };
const overrideOptions = { ...getTypeScriptCompilerOptions(src, module), inlineSources: Boolean(build) };
if (!build) {
overrideOptions.inlineSourceMap = true;
overrideOptions.noEmitOnError = false;
}

const compilation = tsb.create(projectPath, overrideOptions, {
Expand Down Expand Up @@ -121,15 +126,15 @@ export function transpileTask(src: string, out: string, esbuild: boolean): task.
return task;
}

export function compileTask(src: string, out: string, build: boolean, options: { disableMangle?: boolean; preserveEnglish?: boolean } = {}): task.StreamTask {
export function compileTask(src: string, out: string, build: boolean, options: { disableMangle?: boolean; preserveEnglish?: boolean, extractConstEnum?: boolean, module?: ts.ModuleKind } = {}): task.StreamTask {

const task = () => {

if (os.totalmem() < 4_000_000_000) {
throw new Error('compilation requires 4GB of RAM');
}

const compile = createCompile(src, { build, emitError: true, transpileOnly: false, preserveEnglish: !!options.preserveEnglish });
const compile = createCompile(src, { build, emitError: false, transpileOnly: false, preserveEnglish: !!options.preserveEnglish, module: options.module });
const srcPipe = gulp.src(`${src}/**`, { base: `${src}` });
const generator = new MonacoGenerator(false);
if (src === 'src') {
Expand Down Expand Up @@ -163,13 +168,23 @@ export function compileTask(src: string, out: string, build: boolean, options: {
.pipe(mangleStream)
.pipe(generator.stream)
.pipe(compile())
.pipe(options.extractConstEnum ? doExtractConstEnum() : es.through())
.pipe(gulp.dest(out));
};

task.taskName = `compile-${path.basename(src)}`;
return task;
}

function doExtractConstEnum() {
return es.map((file: File, cb: any) => {
if (/\.ts$/.test(file.path)) {
file.contents = Buffer.from(file.contents.toString().replace(/const enum/g, 'enum'));
}
cb(null, file);
});
}

export function watchTask(out: string, build: boolean, srcPath: string = 'src'): task.StreamTask {

const task = () => {
Expand Down
45 changes: 43 additions & 2 deletions build/lib/i18n.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading