Skip to content

Commit 2edb9bc

Browse files
committed
Reapply parcel/watcher adoption
Revert "Revert e7fffbf" This reverts commit 6786b0a. Two changes: - Lazy import parcel/watcher - Add `@parcel/watcher` as a dev dep in extensions folder so that we pull in correct version for build os
1 parent fc9e85e commit 2edb9bc

File tree

7 files changed

+168
-93
lines changed

7 files changed

+168
-93
lines changed

extensions/markdown-language-features/esbuild-notebook.js

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright (c) Microsoft Corporation. All rights reserved.
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
5+
// @ts-check
56
const path = require('path');
67
const esbuild = require('esbuild');
78

@@ -15,19 +16,30 @@ if (outputRootIndex >= 0) {
1516
outputRoot = args[outputRootIndex + 1];
1617
}
1718

19+
const srcDir = path.join(__dirname, 'notebook');
1820
const outDir = path.join(outputRoot, 'notebook-out');
1921

20-
esbuild.build({
21-
entryPoints: [
22-
path.join(__dirname, 'notebook', 'index.ts'),
23-
],
24-
bundle: true,
25-
minify: true,
26-
sourcemap: false,
27-
format: 'esm',
28-
outdir: outDir,
29-
platform: 'browser',
30-
target: ['es2020'],
31-
watch: isWatch,
32-
incremental: isWatch,
33-
}).catch(() => process.exit(1));
22+
function build() {
23+
return esbuild.build({
24+
entryPoints: [
25+
path.join(__dirname, 'notebook', 'index.ts'),
26+
],
27+
bundle: true,
28+
minify: true,
29+
sourcemap: false,
30+
format: 'esm',
31+
outdir: outDir,
32+
platform: 'browser',
33+
target: ['es2020'],
34+
});
35+
}
36+
37+
38+
build().catch(() => process.exit(1));
39+
40+
if (isWatch) {
41+
const watcher = require('@parcel/watcher');
42+
watcher.subscribe(srcDir, () => {
43+
return build();
44+
});
45+
}

extensions/markdown-language-features/esbuild-preview.js

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright (c) Microsoft Corporation. All rights reserved.
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
5+
// @ts-check
56
const path = require('path');
67
const esbuild = require('esbuild');
78

@@ -15,20 +16,30 @@ if (outputRootIndex >= 0) {
1516
outputRoot = args[outputRootIndex + 1];
1617
}
1718

19+
const srcDir = path.join(__dirname, 'preview-src');
1820
const outDir = path.join(outputRoot, 'media');
1921

20-
esbuild.build({
21-
entryPoints: [
22-
path.join(__dirname, 'preview-src', 'index.ts'),
23-
path.join(__dirname, 'preview-src', 'pre'),
24-
],
25-
bundle: true,
26-
minify: true,
27-
sourcemap: false,
28-
format: 'esm',
29-
outdir: outDir,
30-
platform: 'browser',
31-
target: ['es2020'],
32-
watch: isWatch,
33-
incremental: isWatch,
34-
}).catch(() => process.exit(1));
22+
function build() {
23+
return esbuild.build({
24+
entryPoints: [
25+
path.join(srcDir, 'index.ts'),
26+
path.join(srcDir, 'pre'),
27+
],
28+
bundle: true,
29+
minify: true,
30+
sourcemap: false,
31+
format: 'esm',
32+
outdir: outDir,
33+
platform: 'browser',
34+
target: ['es2020'],
35+
});
36+
}
37+
38+
build().catch(() => process.exit(1));
39+
40+
if (isWatch) {
41+
const watcher = require('@parcel/watcher');
42+
watcher.subscribe(srcDir, () => {
43+
return build();
44+
});
45+
}

extensions/markdown-math/esbuild.js

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,45 @@ if (outputRootIndex >= 0) {
1818
outputRoot = args[outputRootIndex + 1];
1919
}
2020

21+
const srcDir = path.join(__dirname, 'notebook');
2122
const outDir = path.join(outputRoot, 'notebook-out');
22-
esbuild.build({
23-
entryPoints: [
24-
path.join(__dirname, 'notebook', 'katex.ts'),
25-
],
26-
bundle: true,
27-
minify: true,
28-
sourcemap: false,
29-
format: 'esm',
30-
outdir: outDir,
31-
platform: 'browser',
32-
target: ['es2020'],
33-
watch: isWatch,
34-
incremental: isWatch,
35-
}).catch(() => process.exit(1));
36-
37-
fse.copySync(
38-
path.join(__dirname, 'node_modules', 'katex', 'dist', 'katex.min.css'),
39-
path.join(outDir, 'katex.min.css'));
40-
41-
42-
const fontsDir = path.join(__dirname, 'node_modules', 'katex', 'dist', 'fonts');
43-
const fontsOutDir = path.join(outDir, 'fonts/');
44-
45-
fse.mkdirSync(fontsOutDir, { recursive: true });
46-
47-
for (const file of fse.readdirSync(fontsDir)) {
48-
if (file.endsWith('.woff2')) {
49-
fse.copyFileSync(path.join(fontsDir, file), path.join(fontsOutDir, file));
23+
24+
async function build() {
25+
await esbuild.build({
26+
entryPoints: [
27+
path.join(srcDir, 'katex.ts'),
28+
],
29+
bundle: true,
30+
minify: true,
31+
sourcemap: false,
32+
format: 'esm',
33+
outdir: outDir,
34+
platform: 'browser',
35+
target: ['es2020'],
36+
});
37+
38+
fse.copySync(
39+
path.join(__dirname, 'node_modules', 'katex', 'dist', 'katex.min.css'),
40+
path.join(outDir, 'katex.min.css'));
41+
42+
const fontsDir = path.join(__dirname, 'node_modules', 'katex', 'dist', 'fonts');
43+
const fontsOutDir = path.join(outDir, 'fonts/');
44+
45+
fse.mkdirSync(fontsOutDir, { recursive: true });
46+
47+
for (const file of fse.readdirSync(fontsDir)) {
48+
if (file.endsWith('.woff2')) {
49+
fse.copyFileSync(path.join(fontsDir, file), path.join(fontsOutDir, file));
50+
}
5051
}
5152
}
53+
54+
55+
build().catch(() => process.exit(1));
56+
57+
if (isWatch) {
58+
const watcher = require('@parcel/watcher');
59+
watcher.subscribe(srcDir, () => {
60+
return build();
61+
});
62+
}

extensions/notebook-renderers/esbuild.js

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright (c) Microsoft Corporation. All rights reserved.
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
5+
// @ts-check
56
const path = require('path');
67
const esbuild = require('esbuild');
78

@@ -15,19 +16,29 @@ if (outputRootIndex >= 0) {
1516
outputRoot = args[outputRootIndex + 1];
1617
}
1718

19+
const srcDir = path.join(__dirname, 'src');
1820
const outDir = path.join(outputRoot, 'renderer-out');
1921

20-
esbuild.build({
21-
entryPoints: [
22-
path.join(__dirname, 'src', 'index.ts'),
23-
],
24-
bundle: true,
25-
minify: false,
26-
sourcemap: false,
27-
format: 'esm',
28-
outdir: outDir,
29-
platform: 'browser',
30-
target: ['es2020'],
31-
watch: isWatch,
32-
incremental: isWatch,
33-
}).catch(() => process.exit(1));
22+
function build() {
23+
return esbuild.build({
24+
entryPoints: [
25+
path.join(srcDir, 'index.ts'),
26+
],
27+
bundle: true,
28+
minify: false,
29+
sourcemap: false,
30+
format: 'esm',
31+
outdir: outDir,
32+
platform: 'browser',
33+
target: ['es2020'],
34+
});
35+
}
36+
37+
build().catch(() => process.exit(1));
38+
39+
if (isWatch) {
40+
const watcher = require('@parcel/watcher');
41+
watcher.subscribe(srcDir, () => {
42+
return build();
43+
});
44+
}

extensions/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"postinstall": "node ./postinstall.mjs"
1111
},
1212
"devDependencies": {
13+
"@parcel/watcher": "2.0.5",
1314
"esbuild": "^0.11.12",
1415
"vscode-grammar-updater": "^1.0.4"
1516
}

extensions/simple-browser/esbuild-preview.js

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright (c) Microsoft Corporation. All rights reserved.
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
5+
// @ts-check
56
const path = require('path');
67
const fs = require('fs');
78
const esbuild = require('esbuild');
@@ -16,27 +17,37 @@ if (outputRootIndex >= 0) {
1617
outputRoot = args[outputRootIndex + 1];
1718
}
1819

20+
const srcDir = path.join(__dirname, 'preview-src');
1921
const outDir = path.join(outputRoot, 'media');
2022

21-
fs.copyFileSync(
22-
path.join(__dirname, 'node_modules', 'vscode-codicons', 'dist', 'codicon.css'),
23-
path.join(outDir, 'codicon.css'));
24-
25-
fs.copyFileSync(
26-
path.join(__dirname, 'node_modules', 'vscode-codicons', 'dist', 'codicon.ttf'),
27-
path.join(outDir, 'codicon.ttf'));
28-
29-
esbuild.build({
30-
entryPoints: [
31-
path.join(__dirname, 'preview-src', 'index.ts')
32-
],
33-
bundle: true,
34-
minify: true,
35-
sourcemap: false,
36-
format: 'esm',
37-
outdir: outDir,
38-
platform: 'browser',
39-
target: ['es2020'],
40-
watch: isWatch,
41-
incremental: isWatch,
42-
}).catch(() => process.exit(1));
23+
async function build() {
24+
fs.copyFileSync(
25+
path.join(__dirname, 'node_modules', 'vscode-codicons', 'dist', 'codicon.css'),
26+
path.join(outDir, 'codicon.css'));
27+
28+
fs.copyFileSync(
29+
path.join(__dirname, 'node_modules', 'vscode-codicons', 'dist', 'codicon.ttf'),
30+
path.join(outDir, 'codicon.ttf'));
31+
32+
await esbuild.build({
33+
entryPoints: [
34+
path.join(srcDir, 'index.ts')
35+
],
36+
bundle: true,
37+
minify: true,
38+
sourcemap: false,
39+
format: 'esm',
40+
outdir: outDir,
41+
platform: 'browser',
42+
target: ['es2020'],
43+
});
44+
}
45+
46+
build().catch(() => process.exit(1));
47+
48+
if (isWatch) {
49+
const watcher = require('@parcel/watcher');
50+
watcher.subscribe(srcDir, () => {
51+
return build();
52+
});
53+
}

extensions/yarn.lock

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
# yarn lockfile v1
33

44

5+
6+
version "2.0.5"
7+
resolved "https://registry.yarnpkg.com/@parcel/watcher/-/watcher-2.0.5.tgz#f913a54e1601b0aac972803829b0eece48de215b"
8+
integrity sha512-x0hUbjv891omnkcHD7ZOhiyyUqUUR6MNjq89JhEI3BxppeKWAm6NPQsqqRrAkCJBogdT/o/My21sXtTI9rJIsw==
9+
dependencies:
10+
node-addon-api "^3.2.1"
11+
node-gyp-build "^4.3.0"
12+
513
coffee-script@^1.10.0:
614
version "1.12.7"
715
resolved "https://registry.yarnpkg.com/coffee-script/-/coffee-script-1.12.7.tgz#c05dae0cb79591d05b3070a8433a98c9a89ccc53"
@@ -24,6 +32,16 @@ [email protected]:
2432
resolved "https://registry.yarnpkg.com/fast-plist/-/fast-plist-0.1.2.tgz#a45aff345196006d406ca6cdcd05f69051ef35b8"
2533
integrity sha1-pFr/NFGWAG1AbKbNzQX2kFHvNbg=
2634

35+
node-addon-api@^3.2.1:
36+
version "3.2.1"
37+
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-3.2.1.tgz#81325e0a2117789c0128dab65e7e38f07ceba161"
38+
integrity sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==
39+
40+
node-gyp-build@^4.3.0:
41+
version "4.3.0"
42+
resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.3.0.tgz#9f256b03e5826150be39c764bf51e993946d71a3"
43+
integrity sha512-iWjXZvmboq0ja1pUGULQBexmxq8CV4xBhX7VDOTbL7ZR4FOowwY/VOtRxBN/yKxmdGoIp4j5ysNT4u3S2pDQ3Q==
44+
2745
2846
version "4.6.2"
2947
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.2.tgz#fe12d2727b708f4eef40f51598b3398baa9611d4"

0 commit comments

Comments
 (0)