-
-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
change(web): remove support for es5 #11881
base: refactor/web/typescript
Are you sure you want to change the base?
Conversation
User Test ResultsTest specification and instructions User tests are not required Test Artifacts
|
b283ea1
to
d4e63a4
Compare
d4e63a4
to
5a80dbf
Compare
68a1330
to
a1bdce0
Compare
…'s version Node's version has special behavior for events named 'error' - if no handler, it auto-throws. EventEmitter3 does not include this.
This fixes building all dependencies, e.g. when running `./build.sh test` which previously failed because it didn't build all necessary targets.
c2f69cc
to
2d9d847
Compare
@@ -45,21 +45,26 @@ function do_build() { | |||
tsc --build "$THIS_SCRIPT_PATH/tsconfig.all.json" | |||
|
|||
# Base product - the main keyboard processor | |||
$BUNDLE_CMD "${KEYMAN_ROOT}/common/web/keyboard-processor/build/obj/index.js" \ | |||
${BUNDLE_CMD} "${KEYMAN_ROOT}/common/web/keyboard-processor/build/obj/src/index.js" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the change in path here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, just to be clear - be very careful when changing the build-output paths like this - it has a tendency to have unwanted side effects in the end-result sourcemap files, often causing the pathing structure shown when debugging via Chrome to become very messy and thus more difficult to utilize.
Part of the reason the /src/
bit wasn't in there to begin with is that omitting it allows the compiled *.js files to be at the same depth as their source counterparts, and that seriously simplifies the sourcemap-editing operations that we apply during top-level compilation. (I forget some of the details; the main reason it was so helpful might be fully in the past, but there's a chance it could be something that would still apply even now.)
if(window['KeymanWeb' as any]) { | ||
(window['KeymanWeb' as any] as any).uninstall(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try using this at the file's top:
declare let KeymanWeb: KeyboardInterface
It's possible to declare globals with type, after which you won't need the as any
stuff.
We already use this pattern in a few places, such as the spot below:
keyman/web/src/app/ui/kmwuitoggle.ts
Line 9 in b15dcef
declare var keyman: KeymanEngine |
With that in place, it doesn't fix the window['keyman']
pattern, but it does allow us to just assume that keyman
exists as a global, which achieves what we're really after anyway.
@@ -21,7 +21,7 @@ export default { | |||
concurrency: 10, | |||
nodeResolve: true, | |||
files: [ | |||
'**/*.spec.ts' | |||
'build/lib/**/*.spec.mjs' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would strongly prefer a specific build folder for tests, then a specific folder for each test set.
Something like build/test/dom/**/*.spec.mjs
- this pattern is being maintained for /web/src/test/auto/dom/
tests, so why not be consistent with the pattern and reuse it here?
(While this module's headless tests aren't yet in TS, they could then go under build/test/headless/**
.)
A general pattern is for lib
folders to hold bundled / fully-compiled outputs, not testing files... right? Or am I just mistaken about that? Either way, that's a pattern I've held to strongly with the lower-level packages; test file outputs do not belong in that folder, in my opinion. Too messy.
'src/test/auto/dom/cases/attachment/**/*.spec.html', | ||
'src/test/auto/dom/cases/attachment/**/*.spec.ts' | ||
'build/test/dom/cases/attachment/**/*.spec.html', | ||
'build/test/dom/cases/attachment/**/*.spec.mjs' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To compare with the comment I made for keyboard-processor tests: note how the build/test/dom/**
pattern is being used here, with minimal changes to boot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this file exists to polyfill for things that would be otherwise missing with ES5, etc. There's a strong chance we should be able to eliminate this script entirely, though it'd take a bit of extra work.
(To be clear, that "extra work" could be done later; just make a tracking issue if so.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh, it would be nice to drop this if viable. I'll want to double-check the outputs to ensure that we aren't getting duplicated/triplicated tslib helper functions due to it, just to be sure, but the comments originally at the top here suggest that we should be fine.
The Web filesize-increase reporter should signal a significant spike in filesize if it's not resolving the helpers properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... Hmm. We went from +32 bytes from the prior PR to +4619 bytes in this one. It's definitely worth double-checking the build output for duplicated helpers, then.
if(this.listenerCount('error') > 0) { | ||
this.emit('error', err); | ||
} else { | ||
throw err; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For other reviewers, just in case:
We use eventemitter3
so that Web can safely compile against common/web/types; events
is a Node-specific package that won't exist in the browser. There is one particular point of divergence between the two types:
- In
events
,.emit('error')
will actuallythrow
the error if there are no registered listeners. - In
eventemitter3
, this specialized behavior is omitted. It will neverthrow
on.emit('error')
regardless of listener count.
This is the one spot in xml2js
that uses .emit('error')
, so we opted for a precise adjustment to accommodate for the difference between the two implementations that will replicate the behavior of the original. One of the common/web/types
unit tests fails otherwise due to reliance on the pattern.
configure "/node_modules" \ | ||
build "/web/build/test/dom/cases/attachment/outputTargetForElement.spec.html" \ | ||
build:app/browser "/web/build/app/browser/lib/index.mjs" \ | ||
build:app/WebViews "/web/build/app/webview/${config}/keymanweb-webview.js" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
build:app/WebViews "/web/build/app/webview/${config}/keymanweb-webview.js" \ | |
build:app/webview "/web/build/app/webview/${config}/keymanweb-webview.js" \ |
Fixes: #11878
@keymanapp-test-bot skip