From f5920b80a323c1d18f24b5176931d0d1675b43b5 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Thu, 15 Aug 2024 15:08:49 +0200 Subject: [PATCH] esm - add `yarn watch-esm` and `watch-client-esm` --- build/gulpfile.js | 4 ++++ build/lib/compilation.js | 8 ++++---- build/lib/compilation.ts | 8 ++++---- migrate.mjs | 5 +++-- package.json | 2 ++ 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/build/gulpfile.js b/build/gulpfile.js index e945c06eed4..785719d3e14 100644 --- a/build/gulpfile.js +++ b/build/gulpfile.js @@ -34,11 +34,15 @@ gulp.task(compileClientTask); const watchClientTask = task.define('watch-client', task.series(util.rimraf('out'), util.buildWebNodePaths('out'), task.parallel(watchTask('out', false), watchApiProposalNamesTask))); gulp.task(watchClientTask); +const watchClientESMTask = task.define('watch-client-esm', task.series(util.rimraf('out'), util.buildWebNodePaths('out'), task.parallel(watchTask('out', false, 'src2'), watchApiProposalNamesTask))); +gulp.task(watchClientESMTask); + // All const _compileTask = task.define('compile', task.parallel(monacoTypecheckTask, compileClientTask, compileExtensionsTask, compileExtensionMediaTask)); gulp.task(_compileTask); gulp.task(task.define('watch', task.parallel(/* monacoTypecheckWatchTask, */ watchClientTask, watchExtensionsTask))); +gulp.task(task.define('watch-esm', task.parallel(/* monacoTypecheckWatchTask, */ watchClientESMTask, watchExtensionsTask))); // Default gulp.task('default', _compileTask); diff --git a/build/lib/compilation.js b/build/lib/compilation.js index cafca34a0d8..e6fe4b592a6 100644 --- a/build/lib/compilation.js +++ b/build/lib/compilation.js @@ -139,11 +139,11 @@ function compileTask(src, out, build, options = {}) { task.taskName = `compile-${path.basename(src)}`; return task; } -function watchTask(out, build) { +function watchTask(out, build, srcPath = 'src') { const task = () => { - const compile = createCompile('src', { build, emitError: false, transpileOnly: false, preserveEnglish: false }); - const src = gulp.src('src/**', { base: 'src' }); - const watchSrc = watch('src/**', { base: 'src', readDelay: 200 }); + const compile = createCompile(srcPath, { build, emitError: false, transpileOnly: false, preserveEnglish: false }); + const src = gulp.src(`${srcPath}/**`, { base: srcPath }); + const watchSrc = watch(`${srcPath}/**`, { base: srcPath, readDelay: 200 }); const generator = new MonacoGenerator(true); generator.execute(); return watchSrc diff --git a/build/lib/compilation.ts b/build/lib/compilation.ts index 8c3614b4c13..978fb15df9e 100644 --- a/build/lib/compilation.ts +++ b/build/lib/compilation.ts @@ -170,13 +170,13 @@ export function compileTask(src: string, out: string, build: boolean, options: { return task; } -export function watchTask(out: string, build: boolean): task.StreamTask { +export function watchTask(out: string, build: boolean, srcPath: string = 'src'): task.StreamTask { const task = () => { - const compile = createCompile('src', { build, emitError: false, transpileOnly: false, preserveEnglish: false }); + const compile = createCompile(srcPath, { build, emitError: false, transpileOnly: false, preserveEnglish: false }); - const src = gulp.src('src/**', { base: 'src' }); - const watchSrc = watch('src/**', { base: 'src', readDelay: 200 }); + const src = gulp.src(`${srcPath}/**`, { base: srcPath }); + const watchSrc = watch(`${srcPath}/**`, { base: srcPath, readDelay: 200 }); const generator = new MonacoGenerator(true); generator.execute(); diff --git a/migrate.mjs b/migrate.mjs index aa58c726bad..1d559c81084 100644 --- a/migrate.mjs +++ b/migrate.mjs @@ -31,7 +31,7 @@ const binaryFileExtensions = new Set([ function migrate() { console.log(`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`); - console.log(`STARTING MIGRATION of src to src2.`); + console.log(`STARTING AMD->ESM MIGRATION of src to src2.`); // installing watcher quickly to avoid missing early events const watchSrc = enableWatching ? watch('src/**', { base: 'src', readDelay: 200 }) : undefined; @@ -49,7 +49,8 @@ function migrate() { writeFileSync(join(dstFolder, '.gitignore'), `*`); console.log(`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`); - console.log(`COMPLETED MIGRATION of src to src2. You can now launch yarn watch or yarn watch-client`); + console.log(`COMPLETED AMD->ESM MIGRATION of src to src2. You can now launch yarn watch-esm or yarn watch-client-esm`); + console.log(`Make sure to set the environment variable VSCODE_BUILD_ESM to a string of value 'true' if you want to build VS Code`); if (watchSrc) { console.log(`WATCHING src for changes...`); diff --git a/package.json b/package.json index c975c9875dc..b777a8e9edb 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "postinstall": "node build/npm/postinstall.js", "compile": "node --max-old-space-size=4095 ./node_modules/gulp/bin/gulp.js compile", "watch": "npm-run-all -lp watch-client watch-extensions", + "watch-esm": "npm-run-all -lp watch-client-esm watch-extensions", "watchd": "deemon yarn watch", "watch-webd": "deemon yarn watch-web", "kill-watchd": "deemon --kill yarn watch", @@ -25,6 +26,7 @@ "restart-watchd": "deemon --restart yarn watch", "restart-watch-webd": "deemon --restart yarn watch-web", "watch-client": "node --max-old-space-size=4095 ./node_modules/gulp/bin/gulp.js watch-client", + "watch-client-esm": "node --max-old-space-size=4095 ./node_modules/gulp/bin/gulp.js watch-client-esm", "watch-clientd": "deemon yarn watch-client", "kill-watch-clientd": "deemon --kill yarn watch-client", "watch-extensions": "node --max-old-space-size=4095 ./node_modules/gulp/bin/gulp.js watch-extensions watch-extension-media",