change(web): also does app/webview, app/ui

This commit is contained in:
Joshua A. Horton 2023-12-15 15:13:36 +07:00
parent 435bfec4e5
commit 61a7fb5c52
5 changed files with 29 additions and 70 deletions

View file

@ -66,7 +66,7 @@ compile_and_copy() {
--minify
$BUNDLE_CMD "${BUILD_ROOT}/obj/test-index.js" \
--out "${BUILD_ROOT}/lib/index.js" \
--out "${BUILD_ROOT}/lib/index.mjs" \
--sourceRoot "@keymanapp/keyman/web/build/app/browser/lib" \
--format esm

View file

@ -1,31 +0,0 @@
/*
* Note: while this file is not meant to exist long-term, it provides a nice
* low-level proof-of-concept for esbuild bundling of the various Web submodules.
*
* Add some extra code at the end of src/index.ts and run it to verify successful bundling!
*/
import esbuild from 'esbuild';
import { bundleObjEntryPoints, iifeConfiguration } from '../../../../common/web/es-bundling/build/index.mjs';
const moduleNames = ['kmwuibutton', 'kmwuifloat', 'kmwuitoggle', 'kmwuitoolbar'];
const modules = moduleNames.map((name) => `../../../build/app/ui/obj/${name}.js`);
await esbuild.build({
...iifeConfiguration,
...bundleObjEntryPoints('debug', ...modules),
// `esbuild`'s sourcemap output puts relative paths to the original sources from the
// directory of the build output. The following keeps repo structure intact and
// puts our code under a common 'namespace' of sorts.
sourceRoot: '@keymanapp/keyman/web/build/app/ui/debug/',
});
await esbuild.build({
...iifeConfiguration,
...bundleObjEntryPoints('release', ...modules),
minify: true,
// `esbuild`'s sourcemap output puts relative paths to the original sources from the
// directory of the build output. The following keeps repo structure intact and
// puts our code under a common 'namespace' of sorts.
sourceRoot: '@keymanapp/keyman/web/build/app/ui/debug/',
});

View file

@ -48,6 +48,22 @@ do_clean() {
compile_and_copy() {
compile $SUBPROJECT_NAME
BUILD_ROOT="${KEYMAN_ROOT}/web/build/app/ui"
types=(button float toggle toolbar)
for type in ${types[@]}
do
filename="kmwui${type}"
$BUNDLE_CMD "${BUILD_ROOT}/obj/$filename.js" \
--out "${BUILD_ROOT}/debug/$filename.js" \
--sourceRoot "@keymanapp/keyman/web/build/app/ui/debug"
$BUNDLE_CMD "${BUILD_ROOT}/obj/$filename.js" \
--out "${BUILD_ROOT}/release/$filename.js" \
--sourceRoot "@keymanapp/keyman/web/build/app/ui/release" \
--minify
done
mkdir -p "$KEYMAN_ROOT/web/build/app/resources/ui"
cp -R "$KEYMAN_ROOT/web/src/resources/ui/." "$KEYMAN_ROOT/web/build/app/resources/ui/"

View file

@ -1,38 +0,0 @@
/*
* Note: while this file is not meant to exist long-term, it provides a nice
* low-level proof-of-concept for esbuild bundling of the various Web submodules.
*
* Add some extra code at the end of src/index.ts and run it to verify successful bundling!
*/
import esbuild from 'esbuild';
import { iifeConfiguration, prepareTslibTreeshaking } from '../../../../common/web/es-bundling/build/index.mjs';
const commonConfig = {
...iifeConfiguration,
entryPoints: {
'index': '../../../build/app/webview/obj/debug-main.js',
},
outfile: '../../../build/app/webview/debug/keymanweb-webview.js',
// `esbuild`'s sourcemap output puts relative paths to the original sources from the
// directory of the build output. The following keeps repo structure intact and
// puts our code under a common 'namespace' of sorts.
sourceRoot: '@keymanapp/keyman/web/build/app/webview/debug/'
};
await prepareTslibTreeshaking(commonConfig, /worker-main\.wrapped(?:\.min)?\.js/);
await esbuild.build(commonConfig);
await esbuild.build({
...commonConfig,
entryPoints: {
'index': '../../../build/app/webview/obj/release-main.js',
},
minify: true,
outfile: '../../../build/app/webview/release/keymanweb-webview.js',
// `esbuild`'s sourcemap output puts relative paths to the original sources from the
// directory of the build output. The following keeps repo structure intact and
// puts our code under a common 'namespace' of sorts.
sourceRoot: '@keymanapp/keyman/web/build/app/webview/debug/'
});

View file

@ -43,6 +43,18 @@ builder_describe_outputs \
compile_and_copy() {
compile $SUBPROJECT_NAME
BUILD_ROOT="${KEYMAN_ROOT}/web/build/app/webview"
$BUNDLE_CMD "${BUILD_ROOT}/obj/debug-main.js" \
--out "${BUILD_ROOT}/debug/keymanweb-webview.js" \
--sourceRoot "@keymanapp/keyman/web/build/app/webview/debug"
$BUNDLE_CMD "${BUILD_ROOT}/obj/release-main.js" \
--out "${BUILD_ROOT}/release/keymanweb-webview.js" \
--profile "${BUILD_ROOT}/filesize-profile.log" \
--sourceRoot "@keymanapp/keyman/web/build/app/webview/release" \
--minify
mkdir -p "$KEYMAN_ROOT/web/build/app/resources/osk"
cp -R "$KEYMAN_ROOT/web/src/resources/osk/." "$KEYMAN_ROOT/web/build/app/resources/osk/"