diff --git a/common/web/es-bundling/src/common-bundle.mts b/common/web/es-bundling/src/common-bundle.mts index fb3dfb95a4..856d08ec05 100644 --- a/common/web/es-bundling/src/common-bundle.mts +++ b/common/web/es-bundling/src/common-bundle.mts @@ -3,6 +3,7 @@ import esbuild from 'esbuild'; import { esmConfiguration, forES6, iifeConfiguration } from './configuration.mjs'; import { prepareTslibTreeshaking } from './tslibTreeshaking.mjs'; +let CHARSET = 'ascii'; let FORMAT = 'iife'; let MINIFY = false; @@ -28,6 +29,8 @@ Parameters: Options: --help Shows this script's documentation + --charset= Sets the charset type for esbuild to emit. Defaults to 'ascii' + but may also be 'utf8'. --format= Sets the format type to use for the generated bundle. Should be 'iife' or 'esm'. @@ -49,15 +52,28 @@ if(process.argv.length > 2) { case '--help': doHelp(); break; - case '--format': // bc TS uses this exact flag. esbuild... uses sourcemap (in the JS config) - let input = process.argv[++i]; - switch(input) { - case 'iife': - case 'esm': - FORMAT = input; + case '--charset': + let charsetOption = process.argv[++i]; + switch(charsetOption) { + case 'ascii': + case 'utf8': + CHARSET = charsetOption; break; default: - console.error(`Invalid bundling format specified: ${input}. Must be 'iife' or 'esm'.`); + console.error(`Invalid bundling format specified: ${charsetOption}. Must be 'ascii' or 'utf8'.`); + doHelp(1); + break; + } + break; + case '--format': // bc TS uses this exact flag. esbuild... uses sourcemap (in the JS config) + let formatOption = process.argv[++i]; + switch(formatOption) { + case 'iife': + case 'esm': + FORMAT = formatOption; + break; + default: + console.error(`Invalid bundling format specified: ${formatOption}. Must be 'iife' or 'esm'.`); doHelp(1); break; } @@ -128,6 +144,7 @@ const baseConfig = FORMAT == 'iife' ? iifeConfiguration : esmConfiguration; const config: esbuild.BuildOptions = { ...jsVersionTarget == 'es6' ? forES6(baseConfig) : baseConfig, entryPoints: [sourceFile], + charset: CHARSET as 'ascii' | 'utf8', outfile: destFile, minify: MINIFY, metafile: !!profilePath, diff --git a/web/src/app/browser/build.sh b/web/src/app/browser/build.sh index 1d757e264a..8774deec46 100755 --- a/web/src/app/browser/build.sh +++ b/web/src/app/browser/build.sh @@ -55,11 +55,13 @@ compile_and_copy() { $BUNDLE_CMD "${SRC_ROOT}/debug-main.js" \ --out "${BUILD_ROOT}/debug/keymanweb.js" \ + --charset "utf8" \ --sourceRoot "@keymanapp/keyman/web/build/app/browser/debug" \ --target "es6" $BUNDLE_CMD "${SRC_ROOT}/release-main.js" \ --out "${BUILD_ROOT}/release/keymanweb.js" \ + --charset "utf8" \ --profile "${BUILD_ROOT}/filesize-profile.log" \ --sourceRoot "@keymanapp/keyman/web/build/app/browser/release" \ --minify \ @@ -67,6 +69,7 @@ compile_and_copy() { $BUNDLE_CMD "${BUILD_ROOT}/obj/test-index.js" \ --out "${BUILD_ROOT}/lib/index.mjs" \ + --charset "utf8" \ --sourceRoot "@keymanapp/keyman/web/build/app/browser/lib" \ --format esm diff --git a/web/src/app/webview/build.sh b/web/src/app/webview/build.sh index e22e1b470e..371c9325f2 100755 --- a/web/src/app/webview/build.sh +++ b/web/src/app/webview/build.sh @@ -45,11 +45,13 @@ compile_and_copy() { $BUNDLE_CMD "${SRC_ROOT}/debug-main.js" \ --out "${BUILD_ROOT}/debug/keymanweb-webview.js" \ + --charset "utf8" \ --sourceRoot "@keymanapp/keyman/web/build/app/webview/debug" \ --target "es6" $BUNDLE_CMD "${SRC_ROOT}/release-main.js" \ --out "${BUILD_ROOT}/release/keymanweb-webview.js" \ + --charset "utf8" \ --profile "${BUILD_ROOT}/filesize-profile.log" \ --sourceRoot "@keymanapp/keyman/web/build/app/webview/release" \ --minify \ diff --git a/web/src/engine/predictive-text/worker-thread/build.sh b/web/src/engine/predictive-text/worker-thread/build.sh index 8c6a4ca001..a77e863c73 100755 --- a/web/src/engine/predictive-text/worker-thread/build.sh +++ b/web/src/engine/predictive-text/worker-thread/build.sh @@ -64,6 +64,7 @@ function do_build() { # The ES6 target needs no polyfills - we go straight to the wrapped version. $bundle_cmd src/main/worker-main.ts \ --out $INTERMEDIATE/worker-main.js \ + --charset "utf8" \ --target "es6" \ --sourceRoot '@keymanapp/keyman/web/src/engine/predictive-text/worker-thread/src/main' @@ -75,6 +76,7 @@ function do_build() { $bundle_cmd src/main/worker-main.ts \ --out $INTERMEDIATE/worker-main.min.js \ --minify \ + --charset "utf8" \ --profile build/filesize-profile.log \ --target "es6" \ --sourceRoot '@keymanapp/keyman/web/src/engine/predictive-text/worker-thread/src/main'