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