Files
vscode-extension-samples/wasm-component-model-resource/bin/esbuild.js
Dirk Bäumer 209ce0e81b Add wasm based examples (#1018)
* WIP

* Add custom add request

* Update package.json

* Component model resource example

* Update to latest wit-bindgen

* WIP

* Minor example updates

* Update wasm-lsp example

* Added some minor comments

* Minor renames

* Change lsp server to count files

* More model resource work

* WIP

* Make the example work

* Update examples to latest

* Update sample to latest tooling

* Update sample to latest wit2ts tooling

* WIP

* Carry over https://github.com/microsoft/vscode-docs/pull/7234/files

* Code cleanup

* Remove dist folder

* Remove another dist folder
2024-05-07 16:12:01 +02:00

71 lines
1.7 KiB
JavaScript

/*---------------------------------------------------------------------------------------------
* 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 esbuild = require('esbuild');
/**
* @typedef {import('esbuild').BuildOptions} BuildOptions
*/
/** @type BuildOptions */
const sharedWebOptions = {
bundle: true,
external: ['vscode'],
target: 'es2020',
platform: 'browser',
sourcemap: true,
};
/** @type BuildOptions */
const webOptions = {
entryPoints: ['src/extension.ts'],
outfile: 'dist/web/extension.js',
format: 'cjs',
...sharedWebOptions,
};
/** @type BuildOptions */
const sharedDesktopOptions = {
bundle: true,
external: ['vscode'],
target: 'es2020',
platform: 'node',
sourcemap: true,
};
/** @type BuildOptions */
const desktopOptions = {
entryPoints: ['src/extension.ts'],
outfile: 'dist/desktop/extension.js',
format: 'cjs',
...sharedDesktopOptions,
};
function createContexts() {
return Promise.all([
esbuild.context(webOptions),
esbuild.context(desktopOptions),
]);
}
createContexts().then(contexts => {
if (process.argv[2] === '--watch') {
const promises = [];
for (const context of contexts) {
promises.push(context.watch());
}
return Promise.all(promises).then(() => { return undefined; });
} else {
const promises = [];
for (const context of contexts) {
promises.push(context.rebuild());
}
Promise.all(promises).then(async () => {
for (const context of contexts) {
await context.dispose();
}
}).then(() => { return undefined; }).catch(console.error);
}
}).catch(console.error);