Skip to content

Commit

Permalink
Update packages and build
Browse files Browse the repository at this point in the history
Signed-off-by: Afonso Fernandes <[email protected]>
  • Loading branch information
afonsonf committed May 19, 2023
1 parent 8446a6d commit 0e16f40
Show file tree
Hide file tree
Showing 6 changed files with 673 additions and 290 deletions.
5 changes: 3 additions & 2 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
node_modules/
out/src/
out/tests/
out/main.browser.js.map
out/*.map
# include out/check-result-view.css
# include out/check-result-view.js
# include out/main.browser.js
out/main.js.map
# include out/main.js
resources/images/screencast.gif
# include resources/
Expand Down
42 changes: 11 additions & 31 deletions esbuild.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable no-undef */
const { build } = require('esbuild');
const { build, context } = require('esbuild');

//@ts-check
/** @typedef {import('esbuild').BuildOptions} BuildOptions **/
Expand All @@ -27,7 +27,7 @@ const extensionConfig = {

// Config for extension source code (to be run in a Web-based context)
/** @type BuildOptions */
const extensionWebConfig = {
const extensionBrowserConfig = {
...baseConfig,
platform: 'browser',
format: 'cjs',
Expand All @@ -36,45 +36,25 @@ const extensionWebConfig = {
external: ['vscode'],
};

// This watch config adheres to the conventions of the esbuild-problem-matchers
// extension (https://github.com/connor4312/esbuild-problem-matchers#esbuild-via-js)
/** @type BuildOptions */
const watchConfig = {
watch: {
onRebuild(error) {
console.log('[watch] build started');
if (error) {
error.errors.forEach((error) =>
console.error(
`> ${error.location.file}:${error.location.line}:${error.location.column}: error: ${error.text}`
)
);
} else {
console.log('[watch] build finished');
}
},
const watchPlugin = (name) => [{
name: 'watch-plugin',
setup(build) {
build.onStart(() => console.log(`[watch] build started - ${name}`));
build.onEnd(() => console.log(`[watch] build finished - ${name}`));
},
};
}];

// Build script
(async () => {
try {
if (args.includes('--watch')) {
// Build and watch extension
console.log('[watch] build started');
await build({
...extensionConfig,
...watchConfig,
});
await build({
...extensionWebConfig,
...watchConfig,
});
console.log('[watch] build finished');
(await context({...extensionConfig, plugins: watchPlugin('extensionConfig')})).watch();
(await context({...extensionBrowserConfig, plugins: watchPlugin('extensionBrowserConfig')})).watch();
} else {
// Build extension
await build(extensionConfig);
await build(extensionWebConfig);
await build(extensionBrowserConfig);
console.log('build complete');
}
} catch (err) {
Expand Down
Loading

0 comments on commit 0e16f40

Please sign in to comment.