Skip to content

Commit

Permalink
change(web): remove support for es5
Browse files Browse the repository at this point in the history
Fixes: #11878
  • Loading branch information
ermshiperete committed Jun 26, 2024
1 parent 07a2cb5 commit b283ea1
Show file tree
Hide file tree
Showing 24 changed files with 24 additions and 221 deletions.
2 changes: 1 addition & 1 deletion common/tools/sourcemap-path-remapper/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"inlineSources": true,
"sourceRoot": "/common/tools/sourcemap-path-remapper/src",
"lib": ["dom", "es6"],
"target": "es5",
"target": "es6",
"types": ["node"],
"downlevelIteration": true,
"baseUrl": "./",
Expand Down
3 changes: 1 addition & 2 deletions common/web/es-bundling/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
################################ Main script ################################

builder_describe "Builds KMW's esbuild-oriented common configuration & tooling" \
"@/common/web/tslib" \
"clean" \
"configure" \
"build"
Expand All @@ -24,4 +23,4 @@ builder_parse "$@"

builder_run_action configure verify_npm_setup
builder_run_action clean rm -rf build/
builder_run_action build tsc -b tsconfig.json
builder_run_action build tsc -b tsconfig.json
4 changes: 2 additions & 2 deletions common/web/es-bundling/src/common-bundle.mts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let profilePath;
let sourceRoot;
let platform;

let jsVersionTarget='es5';
let jsVersionTarget='es6';

function doHelp(errCode?: number) {
console.log(`
Expand Down Expand Up @@ -141,4 +141,4 @@ const results = await esbuild.build(config);
if(results.metafile) {
let filesizeProfile = await esbuild.analyzeMetafile(results.metafile, { verbose: true });
fs.writeFileSync(profilePath, filesizeProfile);
}
}
7 changes: 2 additions & 5 deletions common/web/es-bundling/src/configuration.mts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ import type * as esbuild from 'esbuild';
import { pluginForDowncompiledClassTreeshaking } from './classTreeshaker.mjs';

export const esmConfiguration: esbuild.BuildOptions = {
alias: {
'tslib': '@keymanapp/tslib'
},
bundle: true,
format: "esm",
outExtension: { '.js': '.mjs'},
plugins: [ pluginForDowncompiledClassTreeshaking ],
sourcemap: true,
sourcesContent: true,
target: "es5"
target: "es6"
};

export const iifeConfiguration: esbuild.BuildOptions = {
Expand Down Expand Up @@ -70,4 +67,4 @@ export function bundleObjEntryPoints(configFolder: 'lib' | 'debug' | 'release',
entryPoints: path,
outdir: mappedRoot
};
}
}
9 changes: 4 additions & 5 deletions common/web/keyboard-processor/src/text/stringDivergence.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Future TODO: import from @keymanapp/common-types... once we no longer need to support ES5.
import { Uni_IsSurrogate1, Uni_IsSurrogate2 } from '@keymanapp/web-utils';
import { util } from '@keymanapp/common-types';

/**
* Returns the index for the code point divergence point between two strings, as measured in code
Expand Down Expand Up @@ -73,8 +72,8 @@ export function findCommonSubstringEndIndex(str1: string, str2: string, commonSu
const divergentChar1 = str1.charCodeAt(index);
const divergentChar2 = str2.charCodeAt(index + offset);

const commonSurrogateChecker = commonSuffix ? Uni_IsSurrogate2 : Uni_IsSurrogate1;
const divergentSurrogateChecker = commonSuffix ? Uni_IsSurrogate1 : Uni_IsSurrogate2;
const commonSurrogateChecker = commonSuffix ? util.Uni_IsSurrogate2 : util.Uni_IsSurrogate1;
const divergentSurrogateChecker = commonSuffix ? util.Uni_IsSurrogate1 : util.Uni_IsSurrogate2;

// If the last common character if of the direction-appropriate surrogate type (for
// comprising a potential split surrogate pair representing a non-BMP char)...
Expand All @@ -90,4 +89,4 @@ export function findCommonSubstringEndIndex(str1: string, str2: string, commonSu
}

return index;
}
}
2 changes: 1 addition & 1 deletion common/web/keyman-version/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"compilerOptions": {
"outDir": "./build",
"target": "es5",
"target": "es6",
"rootDir": "."
},

Expand Down
2 changes: 1 addition & 1 deletion common/web/lm-message-types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"outDir": "build/",
"sourceMap": true,
"lib": ["es6"],
"target": "es5"
"target": "es6"
},
"include": ["./*.ts"],
"exclude": ["test.ts"]
Expand Down
4 changes: 2 additions & 2 deletions common/web/lm-worker/build-polyfiller.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,6 @@ await esbuild.build({
// Do NOT enable - will break under Android 5.0 / Chrome 35 environments, likely through Chrome 42.
// https://caniuse.com/mdn-javascript_builtins_function_name_configurable_true
keepNames: false,
target: 'es5',
target: 'es6',
outfile: minDestFile
});
});
34 changes: 1 addition & 33 deletions common/web/lm-worker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,6 @@ function do_configure() {
}

function do_build() {
# Build worker with tsc first
tsc -b $builder_verbose || builder_die "Could not build worker."

$bundle_cmd build/obj/worker-main.js \
--out $INTERMEDIATE/worker-main.es5.js \
--sourceRoot '@keymanapp/keyman/common/web/lm-worker/src/main'

$SRCMAP_CLEANER \
$INTERMEDIATE/worker-main.es5.js.map \
$INTERMEDIATE/worker-main.es5.js.map \
--clean

$bundle_cmd build/obj/worker-main.js \
--out $INTERMEDIATE/worker-main.min.es5.js \
--minify \
--profile build/filesize-profile.es5.log \
--sourceRoot '@keymanapp/keyman/common/web/lm-worker/src/main'

$SRCMAP_CLEANER \
$INTERMEDIATE/worker-main.min.es5.js.map \
$INTERMEDIATE/worker-main.min.es5.js.map \
--clean

EXT_FLAGS=
if builder_has_option --ci; then
EXT_FLAGS=--ci
Expand All @@ -78,16 +55,7 @@ function do_build() {
# Declaration bundling.
tsc --emitDeclarationOnly --outFile $INTERMEDIATE/worker-main.d.ts

echo "Preparing the polyfills + worker for script-embedding"
node build-polyfiller.js $INTERMEDIATE/worker-main.es5.js \
--out $INTERMEDIATE/worker-main.polyfilled.es5.js

mkdir -p $LIB
node build-wrapper.js $INTERMEDIATE/worker-main.polyfilled.es5.js \
--out $LIB/worker-main.wrapped.es5.js \
--sourceMap
node build-wrapper.js $INTERMEDIATE/worker-main.polyfilled.es5.min.js \
--out $LIB/worker-main.wrapped.es5.min.js


# The ES6 target needs no polyfills - we go straight to the wrapped version.
Expand Down Expand Up @@ -142,4 +110,4 @@ function do_test() {
builder_run_action configure do_configure
builder_run_action clean rm -rf build/ intermediate/
builder_run_action build do_build
builder_run_action test do_test
builder_run_action test do_test
6 changes: 2 additions & 4 deletions common/web/lm-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
"main": "./build/lib/worker-main.wrapped.js",
"exports": {
"./worker-main.wrapped.js": {
"es6-bundling": "./build/lib/worker-main.wrapped.js",
"types": "./build/lib/worker-main.wrapped.d.ts",
"default": "./build/lib/worker-main.wrapped.es5.js"
"default": "./build/lib/worker-main.wrapped.js"
},
"./worker-main.wrapped.min.js": {
"es6-bundling": "./build/lib/worker-main.wrapped.min.js",
"types": "./build/lib/worker-main.wrapped.d.ts",
"default": "./build/lib/worker-main.wrapped.es5.min.js"
"default": "./build/lib/worker-main.wrapped.min.js"
}
},
"imports": {
Expand Down
7 changes: 2 additions & 5 deletions common/web/sentry-manager/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ export class KeymanSentryManager {
static STANDARD_ALIASABLE_FILES = {
'keymanweb.js': 'keymanweb.js',
'keymanweb-webview.js': 'keymanweb-webview.js',
'keymanweb.es5.js': 'keymanweb.es5.js',
'keymanweb-webview.es5.js': 'keymanweb-webview.es5.js',
'kmwuibutton.js': 'kmwuibutton.js',
'kmwuifloat.js': 'kmwuifloat.js',
'kmwuitoggle.js': 'kmwuitoggle.js',
Expand Down Expand Up @@ -186,8 +184,7 @@ export class KeymanSentryManager {
* Capture errors and warnings logged to Console in order to get
* stack traces. We can't use CaptureConsole integration until we
* upgrade to a newer version of Sentry, which has a bit of a cascade
* of changes required, in particular a change of module type and
* transpiling down to ES5.
* of changes required, in particular a change of module type.
*
* https://stackoverflow.com/a/53214615/1836776
*/
Expand Down Expand Up @@ -262,4 +259,4 @@ export class KeymanSentryManager {

// Publish to the window.
// @ts-ignore
window['KeymanSentryManager'] = KeymanSentryManager;
window['KeymanSentryManager'] = KeymanSentryManager;
15 changes: 0 additions & 15 deletions common/web/tslib/README.md

This file was deleted.

25 changes: 0 additions & 25 deletions common/web/tslib/build.sh

This file was deleted.

28 changes: 0 additions & 28 deletions common/web/tslib/package.json

This file was deleted.

3 changes: 0 additions & 3 deletions common/web/tslib/src/index.ts

This file was deleted.

16 changes: 0 additions & 16 deletions common/web/tslib/tsconfig.json

This file was deleted.

6 changes: 3 additions & 3 deletions common/web/types/src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,22 +249,22 @@ const Uni_PUA_16_END = 0x10FFFD;
* @brief True if a lead surrogate
* \def Uni_IsSurrogate1
*/
function Uni_IsSurrogate1(ch : number) {
export function Uni_IsSurrogate1(ch : number) {
return ((ch) >= Uni_LEAD_SURROGATE_START && (ch) <= Uni_LEAD_SURROGATE_END);
}
/**
* @brief True if a trail surrogate
* \def Uni_IsSurrogate2
*/
function Uni_IsSurrogate2(ch : number) {
export function Uni_IsSurrogate2(ch : number) {
return ((ch) >= Uni_TRAIL_SURROGATE_START && (ch) <= Uni_TRAIL_SURROGATE_END);
}

/**
* @brief True if any surrogate
* \def UniIsSurrogate
*/
function Uni_IsSurrogate(ch : number) {
export function Uni_IsSurrogate(ch : number) {
return (Uni_IsSurrogate1(ch) || Uni_IsSurrogate2(ch));
}

Expand Down
4 changes: 1 addition & 3 deletions common/web/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ export { default as extendString } from "./kmwstring.js";
export { default as ManagedPromise } from "./managedPromise.js";
export { default as TimeoutPromise, timedPromise } from "./timeoutPromise.js";

export { Uni_IsSurrogate1, Uni_IsSurrogate2 } from "./surrogates.js";

// // Uncomment the following line and run the bundled output to verify successful
// // esbuild bundling of this submodule:
// console.log(Version.CURRENT.toString());
// console.log(Version.CURRENT.toString());
27 changes: 0 additions & 27 deletions common/web/utils/src/surrogates.ts

This file was deleted.

Loading

0 comments on commit b283ea1

Please sign in to comment.