mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
Use parcel for watching esbuild build files
Seeing small but consistent cpu usage when using esbuild's watcher. Switch to parcel to avoid this
This commit is contained in:
@@ -2,8 +2,10 @@
|
|||||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
// @ts-check
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const esbuild = require('esbuild');
|
const esbuild = require('esbuild');
|
||||||
|
const watcher = require('@parcel/watcher');
|
||||||
|
|
||||||
const args = process.argv.slice(2);
|
const args = process.argv.slice(2);
|
||||||
|
|
||||||
@@ -15,19 +17,29 @@ if (outputRootIndex >= 0) {
|
|||||||
outputRoot = args[outputRootIndex + 1];
|
outputRoot = args[outputRootIndex + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const srcDir = path.join(__dirname, 'notebook');
|
||||||
const outDir = path.join(outputRoot, 'notebook-out');
|
const outDir = path.join(outputRoot, 'notebook-out');
|
||||||
|
|
||||||
esbuild.build({
|
function build() {
|
||||||
entryPoints: [
|
return esbuild.build({
|
||||||
path.join(__dirname, 'notebook', 'index.ts'),
|
entryPoints: [
|
||||||
],
|
path.join(__dirname, 'notebook', 'index.ts'),
|
||||||
bundle: true,
|
],
|
||||||
minify: true,
|
bundle: true,
|
||||||
sourcemap: false,
|
minify: true,
|
||||||
format: 'esm',
|
sourcemap: false,
|
||||||
outdir: outDir,
|
format: 'esm',
|
||||||
platform: 'browser',
|
outdir: outDir,
|
||||||
target: ['es2020'],
|
platform: 'browser',
|
||||||
watch: isWatch,
|
target: ['es2020'],
|
||||||
incremental: isWatch,
|
});
|
||||||
}).catch(() => process.exit(1));
|
}
|
||||||
|
|
||||||
|
|
||||||
|
build().catch(() => process.exit(1));
|
||||||
|
|
||||||
|
if (isWatch) {
|
||||||
|
watcher.subscribe(srcDir, () => {
|
||||||
|
return build();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,8 +2,10 @@
|
|||||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
// @ts-check
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const esbuild = require('esbuild');
|
const esbuild = require('esbuild');
|
||||||
|
const watcher = require('@parcel/watcher');
|
||||||
|
|
||||||
const args = process.argv.slice(2);
|
const args = process.argv.slice(2);
|
||||||
|
|
||||||
@@ -15,20 +17,29 @@ if (outputRootIndex >= 0) {
|
|||||||
outputRoot = args[outputRootIndex + 1];
|
outputRoot = args[outputRootIndex + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const srcDir = path.join(__dirname, 'preview-src');
|
||||||
const outDir = path.join(outputRoot, 'media');
|
const outDir = path.join(outputRoot, 'media');
|
||||||
|
|
||||||
esbuild.build({
|
function build() {
|
||||||
entryPoints: [
|
return esbuild.build({
|
||||||
path.join(__dirname, 'preview-src', 'index.ts'),
|
entryPoints: [
|
||||||
path.join(__dirname, 'preview-src', 'pre'),
|
path.join(srcDir, 'index.ts'),
|
||||||
],
|
path.join(srcDir, 'pre'),
|
||||||
bundle: true,
|
],
|
||||||
minify: true,
|
bundle: true,
|
||||||
sourcemap: false,
|
minify: true,
|
||||||
format: 'esm',
|
sourcemap: false,
|
||||||
outdir: outDir,
|
format: 'esm',
|
||||||
platform: 'browser',
|
outdir: outDir,
|
||||||
target: ['es2020'],
|
platform: 'browser',
|
||||||
watch: isWatch,
|
target: ['es2020'],
|
||||||
incremental: isWatch,
|
});
|
||||||
}).catch(() => process.exit(1));
|
}
|
||||||
|
|
||||||
|
build().catch(() => process.exit(1));
|
||||||
|
|
||||||
|
if (isWatch) {
|
||||||
|
watcher.subscribe(srcDir, () => {
|
||||||
|
return build();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fse = require('fs-extra');
|
const fse = require('fs-extra');
|
||||||
const esbuild = require('esbuild');
|
const esbuild = require('esbuild');
|
||||||
|
const watcher = require('@parcel/watcher');
|
||||||
|
|
||||||
const args = process.argv.slice(2);
|
const args = process.argv.slice(2);
|
||||||
|
|
||||||
@@ -18,34 +19,44 @@ if (outputRootIndex >= 0) {
|
|||||||
outputRoot = args[outputRootIndex + 1];
|
outputRoot = args[outputRootIndex + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const srcDir = path.join(__dirname, 'notebook');
|
||||||
const outDir = path.join(outputRoot, 'notebook-out');
|
const outDir = path.join(outputRoot, 'notebook-out');
|
||||||
esbuild.build({
|
|
||||||
entryPoints: [
|
|
||||||
path.join(__dirname, 'notebook', 'katex.ts'),
|
|
||||||
],
|
|
||||||
bundle: true,
|
|
||||||
minify: true,
|
|
||||||
sourcemap: false,
|
|
||||||
format: 'esm',
|
|
||||||
outdir: outDir,
|
|
||||||
platform: 'browser',
|
|
||||||
target: ['es2020'],
|
|
||||||
watch: isWatch,
|
|
||||||
incremental: isWatch,
|
|
||||||
}).catch(() => process.exit(1));
|
|
||||||
|
|
||||||
fse.copySync(
|
async function build() {
|
||||||
path.join(__dirname, 'node_modules', 'katex', 'dist', 'katex.min.css'),
|
await esbuild.build({
|
||||||
path.join(outDir, 'katex.min.css'));
|
entryPoints: [
|
||||||
|
path.join(srcDir, 'katex.ts'),
|
||||||
|
],
|
||||||
|
bundle: true,
|
||||||
|
minify: true,
|
||||||
|
sourcemap: false,
|
||||||
|
format: 'esm',
|
||||||
|
outdir: outDir,
|
||||||
|
platform: 'browser',
|
||||||
|
target: ['es2020'],
|
||||||
|
});
|
||||||
|
|
||||||
|
fse.copySync(
|
||||||
|
path.join(__dirname, 'node_modules', 'katex', 'dist', 'katex.min.css'),
|
||||||
|
path.join(outDir, 'katex.min.css'));
|
||||||
|
|
||||||
const fontsDir = path.join(__dirname, 'node_modules', 'katex', 'dist', 'fonts');
|
const fontsDir = path.join(__dirname, 'node_modules', 'katex', 'dist', 'fonts');
|
||||||
const fontsOutDir = path.join(outDir, 'fonts/');
|
const fontsOutDir = path.join(outDir, 'fonts/');
|
||||||
|
|
||||||
fse.mkdirSync(fontsOutDir, { recursive: true });
|
fse.mkdirSync(fontsOutDir, { recursive: true });
|
||||||
|
|
||||||
for (const file of fse.readdirSync(fontsDir)) {
|
for (const file of fse.readdirSync(fontsDir)) {
|
||||||
if (file.endsWith('.woff2')) {
|
if (file.endsWith('.woff2')) {
|
||||||
fse.copyFileSync(path.join(fontsDir, file), path.join(fontsOutDir, file));
|
fse.copyFileSync(path.join(fontsDir, file), path.join(fontsOutDir, file));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
build().catch(() => process.exit(1));
|
||||||
|
|
||||||
|
if (isWatch) {
|
||||||
|
watcher.subscribe(srcDir, () => {
|
||||||
|
return build();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,8 +2,10 @@
|
|||||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
// @ts-check
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const esbuild = require('esbuild');
|
const esbuild = require('esbuild');
|
||||||
|
const watcher = require('@parcel/watcher');
|
||||||
|
|
||||||
const args = process.argv.slice(2);
|
const args = process.argv.slice(2);
|
||||||
|
|
||||||
@@ -15,19 +17,28 @@ if (outputRootIndex >= 0) {
|
|||||||
outputRoot = args[outputRootIndex + 1];
|
outputRoot = args[outputRootIndex + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const srcDir = path.join(__dirname, 'src');
|
||||||
const outDir = path.join(outputRoot, 'renderer-out');
|
const outDir = path.join(outputRoot, 'renderer-out');
|
||||||
|
|
||||||
esbuild.build({
|
function build() {
|
||||||
entryPoints: [
|
return esbuild.build({
|
||||||
path.join(__dirname, 'src', 'index.ts'),
|
entryPoints: [
|
||||||
],
|
path.join(srcDir, 'index.ts'),
|
||||||
bundle: true,
|
],
|
||||||
minify: false,
|
bundle: true,
|
||||||
sourcemap: false,
|
minify: false,
|
||||||
format: 'esm',
|
sourcemap: false,
|
||||||
outdir: outDir,
|
format: 'esm',
|
||||||
platform: 'browser',
|
outdir: outDir,
|
||||||
target: ['es2020'],
|
platform: 'browser',
|
||||||
watch: isWatch,
|
target: ['es2020'],
|
||||||
incremental: isWatch,
|
});
|
||||||
}).catch(() => process.exit(1));
|
}
|
||||||
|
|
||||||
|
build().catch(() => process.exit(1));
|
||||||
|
|
||||||
|
if (isWatch) {
|
||||||
|
watcher.subscribe(srcDir, () => {
|
||||||
|
return build();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,9 +2,11 @@
|
|||||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
// @ts-check
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const esbuild = require('esbuild');
|
const esbuild = require('esbuild');
|
||||||
|
const watcher = require('@parcel/watcher');
|
||||||
|
|
||||||
const args = process.argv.slice(2);
|
const args = process.argv.slice(2);
|
||||||
|
|
||||||
@@ -16,27 +18,36 @@ if (outputRootIndex >= 0) {
|
|||||||
outputRoot = args[outputRootIndex + 1];
|
outputRoot = args[outputRootIndex + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const srcDir = path.join(__dirname, 'preview-src');
|
||||||
const outDir = path.join(outputRoot, 'media');
|
const outDir = path.join(outputRoot, 'media');
|
||||||
|
|
||||||
fs.copyFileSync(
|
async function build() {
|
||||||
path.join(__dirname, 'node_modules', 'vscode-codicons', 'dist', 'codicon.css'),
|
fs.copyFileSync(
|
||||||
path.join(outDir, 'codicon.css'));
|
path.join(__dirname, 'node_modules', 'vscode-codicons', 'dist', 'codicon.css'),
|
||||||
|
path.join(outDir, 'codicon.css'));
|
||||||
|
|
||||||
fs.copyFileSync(
|
fs.copyFileSync(
|
||||||
path.join(__dirname, 'node_modules', 'vscode-codicons', 'dist', 'codicon.ttf'),
|
path.join(__dirname, 'node_modules', 'vscode-codicons', 'dist', 'codicon.ttf'),
|
||||||
path.join(outDir, 'codicon.ttf'));
|
path.join(outDir, 'codicon.ttf'));
|
||||||
|
|
||||||
esbuild.build({
|
await esbuild.build({
|
||||||
entryPoints: [
|
entryPoints: [
|
||||||
path.join(__dirname, 'preview-src', 'index.ts')
|
path.join(srcDir, 'index.ts')
|
||||||
],
|
],
|
||||||
bundle: true,
|
bundle: true,
|
||||||
minify: true,
|
minify: true,
|
||||||
sourcemap: false,
|
sourcemap: false,
|
||||||
format: 'esm',
|
format: 'esm',
|
||||||
outdir: outDir,
|
outdir: outDir,
|
||||||
platform: 'browser',
|
platform: 'browser',
|
||||||
target: ['es2020'],
|
target: ['es2020'],
|
||||||
watch: isWatch,
|
});
|
||||||
incremental: isWatch,
|
}
|
||||||
}).catch(() => process.exit(1));
|
|
||||||
|
build().catch(() => process.exit(1));
|
||||||
|
|
||||||
|
if (isWatch) {
|
||||||
|
watcher.subscribe(srcDir, () => {
|
||||||
|
return build();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user