Summary: Update jest now that we've updated typescript. Only minor changes required to make it work as expected.
Reviewed By: quark-zju
Differential Revision: D56205373
fbshipit-source-id: 9f89d901c76f1d3671545a8a089dad9aaa7ddf82
Summary:
Reorganize a bunch of the syntax highlighting stuff to happen in a WebWorker instead of synchronously.
We were seeing some perf issues when syntax highlighting a large file. Notably, the Split UI syntax highlights the entire file, not each hunk, and it does this on every file change. Some files saw 500ms highlight times, which meant each time pressing the left/right arrow on a line would take at least 500ms, usually 1000ms because you'd move the line to the right and it would be visible again, causing another round of highlighting.
Perhaps we can make the actual highlighting more efficient, but putting it in a web worker means the highlighting is purely visual and has no effect on clicking buttons in the UI.
This is a somewhat consequential change, with more changes needed afterwards:
- jest tests broke because import.meta.url is not defined
- I updated our transformer to give a file name
- jest tests broke because Workers are not supported
- I disabled highlighting tests. We'll want to make syntax highlighting first try web worker, but otherwise fall back to synchronously highlighting, so we can use that in tests.
- I broke the cancellation tokens. We need special new support to have cancelling send a cancel message over to the web worker. Currently, if you spam arrows in split, the highlights basically queue up and finish one by one
note: this won't work as-is in all build modes and platforms.
- In production isl-server, need some changes for the server to find the webworker file
- in vscode, we need some different importing strategy, both for dev and prouction. This is because vscode won't import the worker code properly without using a blob.
Reviewed By: quark-zju
Differential Revision: D55668617
fbshipit-source-id: 34e5937697d4b55ab2af5e76807c7756e26836c1
Summary:
Without this, `jest` stops working with upcoming changes:
isl/src/serverAPIState.ts:40
}), import.meta.hot);
^^^^
SyntaxError: Cannot use 'import.meta' outside a module
This `import` is a keyword so it cannot be fooled by setting a `import` global variable.
I also tried configuring jest to use ESM (https://kulshekhar.github.io/ts-jest/docs/guides/esm-support)
but it does not seem to take effect. From the doc that might mean all
jest-defined globals are gone and tests need change too.
Besides, moving `import.meta.hot` to a utility module is not a choice, since
that affects the utility module, not the callsite. I believe the existing code
`declineHotReload.ts` disables hot-reloading for `declineHotReload.ts`, not for
the callsite.
So I ended up with this transformer hack. Ideally Jest just supports ESM
somehow but for now this is what unblocks next changes.
Reviewed By: evangrayk
Differential Revision: D53074125
fbshipit-source-id: 486eb1932f2836ae5afaf48dabf3f13d9e69ed89