diff --git a/web/src/app/browser/build.sh b/web/src/app/browser/build.sh index 54fae132d9..43c80cf75b 100755 --- a/web/src/app/browser/build.sh +++ b/web/src/app/browser/build.sh @@ -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 diff --git a/web/src/app/ui/build-bundler.js b/web/src/app/ui/build-bundler.js deleted file mode 100644 index 209edc8aed..0000000000 --- a/web/src/app/ui/build-bundler.js +++ /dev/null @@ -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/', -}); \ No newline at end of file diff --git a/web/src/app/ui/build.sh b/web/src/app/ui/build.sh index 7d9b2664b5..7f4b5ce0d4 100755 --- a/web/src/app/ui/build.sh +++ b/web/src/app/ui/build.sh @@ -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/" diff --git a/web/src/app/webview/build-bundler.js b/web/src/app/webview/build-bundler.js deleted file mode 100644 index f7d67fd523..0000000000 --- a/web/src/app/webview/build-bundler.js +++ /dev/null @@ -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/' -}); \ No newline at end of file diff --git a/web/src/app/webview/build.sh b/web/src/app/webview/build.sh index 19faef691f..26eecaee55 100755 --- a/web/src/app/webview/build.sh +++ b/web/src/app/webview/build.sh @@ -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/"