Reapply parcel/watcher adoption

Revert "Revert e7fffbf1c9169087f1098aedfe54c59c079fa3ac"

This reverts commit 6786b0ad7d.

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
pull/145944/head^2
Matt Bierner 2022-03-24 14:13:18 -07:00
parent fc9e85ea3e
commit 2edb9bc9ca
No known key found for this signature in database
GPG Key ID: 099C331567E11888
7 changed files with 161 additions and 86 deletions

View File

@ -2,6 +2,7 @@
* 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');
@ -15,19 +16,30 @@ 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) {
const watcher = require('@parcel/watcher');
watcher.subscribe(srcDir, () => {
return build();
});
}

View File

@ -2,6 +2,7 @@
* 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');
@ -15,20 +16,30 @@ 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) {
const watcher = require('@parcel/watcher');
watcher.subscribe(srcDir, () => {
return build();
});
}

View File

@ -18,34 +18,45 @@ 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) {
const watcher = require('@parcel/watcher');
watcher.subscribe(srcDir, () => {
return build();
});
}

View File

@ -2,6 +2,7 @@
* 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');
@ -15,19 +16,29 @@ 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) {
const watcher = require('@parcel/watcher');
watcher.subscribe(srcDir, () => {
return build();
});
}

View File

@ -10,6 +10,7 @@
"postinstall": "node ./postinstall.mjs"
},
"devDependencies": {
"@parcel/watcher": "2.0.5",
"esbuild": "^0.11.12",
"vscode-grammar-updater": "^1.0.4"
}

View File

@ -2,6 +2,7 @@
* 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');
@ -16,27 +17,37 @@ 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) {
const watcher = require('@parcel/watcher');
watcher.subscribe(srcDir, () => {
return build();
});
}

View File

@ -2,6 +2,14 @@
# yarn lockfile v1
"@parcel/watcher@2.0.5":
version "2.0.5"
resolved "https://registry.yarnpkg.com/@parcel/watcher/-/watcher-2.0.5.tgz#f913a54e1601b0aac972803829b0eece48de215b"
integrity sha512-x0hUbjv891omnkcHD7ZOhiyyUqUUR6MNjq89JhEI3BxppeKWAm6NPQsqqRrAkCJBogdT/o/My21sXtTI9rJIsw==
dependencies:
node-addon-api "^3.2.1"
node-gyp-build "^4.3.0"
coffee-script@^1.10.0:
version "1.12.7"
resolved "https://registry.yarnpkg.com/coffee-script/-/coffee-script-1.12.7.tgz#c05dae0cb79591d05b3070a8433a98c9a89ccc53"
@ -24,6 +32,16 @@ fast-plist@0.1.2:
resolved "https://registry.yarnpkg.com/fast-plist/-/fast-plist-0.1.2.tgz#a45aff345196006d406ca6cdcd05f69051ef35b8"
integrity sha1-pFr/NFGWAG1AbKbNzQX2kFHvNbg=
node-addon-api@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-3.2.1.tgz#81325e0a2117789c0128dab65e7e38f07ceba161"
integrity sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==
node-gyp-build@^4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.3.0.tgz#9f256b03e5826150be39c764bf51e993946d71a3"
integrity sha512-iWjXZvmboq0ja1pUGULQBexmxq8CV4xBhX7VDOTbL7ZR4FOowwY/VOtRxBN/yKxmdGoIp4j5ysNT4u3S2pDQ3Q==
typescript@4.6.2:
version "4.6.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.2.tgz#fe12d2727b708f4eef40f51598b3398baa9611d4"