diff options
| author | Orkun Tokdemir <orkun.tokdemir@qt.io> | 2024-08-22 15:49:33 +0200 |
|---|---|---|
| committer | Orkun Tokdemir <orkun.tokdemir@qt.io> | 2024-08-28 07:58:34 +0000 |
| commit | 9153f975f97a9b35c1c6ad58e9ffa6f486ea1635 (patch) | |
| tree | c39488ed37a2765496757648b0769f8d9bfd9b45 /qt-qml/esbuild.mjs | |
| parent | d3534cb559043d80b822b356789049e96454f3a1 (diff) | |
qt-official: Separate into qt-cpp & qt-qml
Amends c45fc76944f8a280ccc9483cc47236fd98275fb6
* Update github actions
* Update ci-scripts
* Remove unused test folder
* Remove unused dependencies & update `ThirdPartyNotices.txt`s
* Remove unused activation events
Fixes: VSCODEEXT-79
Fixes: VSCODEEXT-80
Change-Id: I450fefdde5209454ef11e1b9cd12162753d4fa36
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Diffstat (limited to 'qt-qml/esbuild.mjs')
| -rw-r--r-- | qt-qml/esbuild.mjs | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/qt-qml/esbuild.mjs b/qt-qml/esbuild.mjs new file mode 100644 index 0000000..c7c9eab --- /dev/null +++ b/qt-qml/esbuild.mjs @@ -0,0 +1,78 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only + +import { exec } from 'child_process'; +import { build, context } from 'esbuild'; + +/** @type BuildOptions */ +const baseConfig = { + bundle: true, + minify: process.env.NODE_ENV === 'production', + sourcemap: process.env.NODE_ENV !== 'production' +}; + +// Config for extension source code (to be run in a Node-based context) +/** @type BuildOptions */ +const extensionConfig = { + ...baseConfig, + platform: 'node', + mainFields: ['module', 'main'], + tsconfig: './tsconfig.json', + format: 'cjs', + entryPoints: ['./src/extension.ts'], + outfile: './out/extension.js', + external: ['vscode'] +}; + +async function execCmd(command) { + return new Promise((resolve, reject) => { + exec(command, (error, stdout, stderr) => { + if (error) { + reject([error, stdout, stderr]); + return; + } + resolve(stdout); + }); + }); +} + +await execCmd('npx tsc --noEmit').then( + (stdout) => { + if (stdout.length > 0) { + console.log(stdout); + } + }, + ([error, stdout, stderr]) => { + console.error(error.message); + if (stderr.length > 0) { + console.error(stderr); + } + + if (stdout.length > 0) { + console.error(stdout); + } + + process.exit(1); + } +); + +// Build script +(async () => { + const args = process.argv.slice(2); + try { + if (args.includes('--watch')) { + const extCtx = await context({ + ...extensionConfig + }); + await extCtx.watch(); + await extCtx.dispose(); + console.log('[watch] build finished'); + } else { + await build(extensionConfig); + console.log('build complete'); + } + } catch (err) { + process.stderr.write(err.stderr); + process.exit(1); + } +})(); |
