Commit 9a6f1b1
feat: compile as ES Module (#431)
* feat: compile as ES Module
* update CI workflows to newer node
* release workflow to newer node
* update yarn version to 3.3.1
* explicitly set yarnPath
* fix: frozen-lockfile to immutable
* replace isomorphic-fetch with cross-fetch
* fix: done() called only once
* update jest + fix a few tests
* Add .js to local imports as per https://github.com/microsoft/TypeScript/issues/16577\#issuecomment-754941937
* prettier write
* example for adding it in the browser
* github workflows to one version (hashes may change when changing node version, due to yarn patches)
* update package.json
* Update yarn lock
* fix: graphql subscription tests don't leak handles
* Node tests for graphql subscriptions are now working
* Don't try to make WebSocket tests work in two environments
After struggling for a long while with trying to "shim" isomorphic-ws
to work normally in a jest environment, it is easier to just run this
test only in a Node environment.
Here are the issues why this test fails in JSDOM:
1. Imports fail
The statement `import WebSocket from 'isomorphic-ws';` is passed to the
Jest module resolver, which utilises `ts-jest-resolver` (in our case) to
find the right file to load. Sadly, it will always load the "main"
module of a node package.
2. isomorphic-ws "browser" option is ESM for some reason
If we use jest.config.cjs "resolver" field [1] to define a custom script,
we will be able to modify the "main" field by patching package.json in
memory. This works fine, however isomorphic-ws's browser version is an
ES Module for some reason, even if the package.json > "type" is
"commonjs".
3. Something inside jest doesn't want me to hack it to support ESM
If I override the package.json even harder to also change the "type" to
"module" just for isomorphic-ws, Jest doesn't respect it
4. ts-jest doesn't want to change the ESM imports to CJS imports
Since... we told it to not change ESM imports to CJS imports, it will
not.
[1]: https://jestjs.io/docs/configuration#resolver-string
* prettier write
* follow flags in tsconfig
---------
Co-authored-by: karl <[email protected]>1 parent 1484a11 commit 9a6f1b1
File tree
29 files changed
+9901
-6384
lines changed- .github/workflows
- .yarn/releases
- examples/browser
- scripts
- src
- model
- services
- test/unit
29 files changed
+9901
-6384
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
6 | 13 | | |
| 14 | + | |
7 | 15 | | |
8 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
9 | 27 | | |
10 | 28 | | |
11 | | - | |
| 29 | + | |
12 | 30 | | |
13 | | - | |
| 31 | + | |
| 32 | + | |
14 | 33 | | |
15 | 34 | | |
16 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
| 5 | + | |
9 | 6 | | |
10 | 7 | | |
11 | 8 | | |
12 | 9 | | |
13 | 10 | | |
14 | | - | |
| 11 | + | |
| 12 | + | |
15 | 13 | | |
16 | | - | |
| 14 | + | |
17 | 15 | | |
18 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
19 | 28 | | |
20 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
21 | 41 | | |
22 | 42 | | |
23 | 43 | | |
24 | 44 | | |
25 | | - | |
| 45 | + | |
26 | 46 | | |
27 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
28 | 52 | | |
29 | 53 | | |
30 | | - | |
| 54 | + | |
31 | 55 | | |
32 | 56 | | |
33 | 57 | | |
34 | 58 | | |
35 | 59 | | |
36 | | - | |
| 60 | + | |
37 | 61 | | |
38 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
39 | 67 | | |
40 | 68 | | |
41 | | - | |
| 69 | + | |
42 | 70 | | |
43 | 71 | | |
44 | 72 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | | - | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
0 commit comments