Skip to content

Commit bd03fbe

Browse files
committed
feat: update node-es result
1 parent 00776c4 commit bd03fbe

File tree

3 files changed

+722
-37
lines changed

3 files changed

+722
-37
lines changed

β€Žtests/node-es/README.mdβ€Ž

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
```js
44
{
55
"compilerOptions": {
6-
// implicitly true
7-
// "allowSyntheticDefaultImports": true,
86
"esModuleInterop": true,
97
"moduleResolution": "Node"
108
}
@@ -19,7 +17,7 @@ Depends on the test configuration, the way to consume a module are different.
1917

2018
In this section we describe each module and how they are consumed within this configuration.
2119

22-
`assert`: `module declaration` with `export =` as in DefinitelyTyped
20+
## [assert](../../README.md#assert)
2321

2422
```ts
2523
import assert from 'assert'
@@ -28,11 +26,7 @@ import * as assert from 'assert'
2826
assert(true)
2927
```
3028

31-
`assertron@7`: Written in TypeScript, compile to CJS.
32-
The type definition uses `export default` as performed by `tsc`.
33-
It also has a transient dependency on `assertion-error` which uses `export =` in the type definition.
34-
35-
It also expose `module` field in `package.json`, but that should not affect the test.
29+
## [assertron@7](../../README.md#assertron7)
3630

3731
```ts
3832
import assertron from 'assertron'
@@ -43,7 +37,7 @@ import * as assertron from 'assertron'
4337
assertron.default.truthy(1)
4438
```
4539

46-
`param-case@1`: is a CJS with `export =` in the typing file. It does not use `declare module`.
40+
## [param-case@1](../../README.md#param-case1)
4741

4842
```ts
4943
// export =
@@ -55,7 +49,7 @@ import * as paramCase from 'param-case'
5549
paramCase.default('hello world')
5650
```
5751

58-
`cjs`: is a local package that expose `main` in CJS format. It does not contain `module` field.
52+
## [cjs](../../README.md#cjs)
5953

6054
```ts
6155
import m from 'cjs'
@@ -66,8 +60,7 @@ import * as m from 'cjs'
6660
m.default(1)
6761
```
6862

69-
`es-cjs`: is a local package that expose `main` in CJS and `module` in `ES*` format.
70-
It should behaves identical to `cjs`. Adding just for reference.
63+
## [es-cjs](../../README.md#es-cjs)
7164

7265
```ts
7366
import m from 'es-cjs'
@@ -78,12 +71,7 @@ import * as m from 'es-cjs'
7871
m.default(1)
7972
```
8073

81-
`esm`: is a local package that expose `ESM` with `exports` field. It does not contain `main` field.
82-
83-
It is not supported in this test configuration as `moduleResolution` set to `Node16` or `NodeNext` is required.
84-
85-
`esm-cjs`: is a local package that expose `ESM` with `exports` field and `main` in CJS format.
86-
It should behaves identical to `cjs` in this configuration. Adding just for reference.
74+
## [esm-cjs](../../README.md#esm-cjs)
8775

8876
```ts
8977
import m from 'esm-cjs'
@@ -97,7 +85,7 @@ m.default(1)
9785
## Legends
9886

9987
- 🟒: both compile and runtime are working correctly
100-
- 🟑: for compile, it means there is an error, but can be supressed (e.g. with `skipLibCheck`)\
88+
- 🟑: for compile, it means there is an error, but can be suppressed (e.g. with `skipLibCheck`)\
10189
for runtime, it means the compile fails, but runtime is working
10290
- πŸ”΄: both compile and runtime fails
10391
- ❌: compile success, but runtime fails. Potentially a TypeScript bug.
@@ -113,12 +101,12 @@ Import Syntax:
113101

114102
| module | Package | Type | import: default as | import: default | import: * as |
115103
| -------- | ---------- | --------- | ------------------ | ----------------- | ----------------- |
116-
| CommonJS | assert | πŸ’» Compile | πŸ”΄ TS1259-e | πŸ”΄ TS1259-e | 🟒 |
117-
| | | πŸƒ Runtime | πŸ”΄ not-fn | πŸ”΄ not-fn | 🟒 |
118-
| | assertron | πŸ’» Compile | 🟑 TS1259-t | 🟑 TS1259-t | 🟑 TS1259-t |
119-
| | | πŸƒ Runtime | 🟑 | 🟑 | 🟑 |
120-
| | param-case | πŸ’» Compile | πŸ”΄ TS1259-e | πŸ”΄ TS1259-e | πŸ”΄ TS2497-e TS2339 |
121-
| | | πŸƒ Runtime | πŸ”΄ not-fn | πŸ”΄ not-fn | 🟑 |
104+
| CommonJS | assert | πŸ’» Compile | 🟒 | 🟒 | 🟒 |
105+
| | | πŸƒ Runtime | 🟒 | 🟒 | ❌ not-fn |
106+
| | assertron | πŸ’» Compile | 🟒 | 🟒 | 🟒 |
107+
| | | πŸƒ Runtime | 🟒 | 🟒 | 🟒 |
108+
| | param-case | πŸ’» Compile | 🟒 | 🟒 | πŸ”΄ TS2497-e TS2339 |
109+
| | | πŸƒ Runtime | 🟒 | 🟒 | 🟑 |
122110
| | cjs | πŸ’» Compile | 🟒 | 🟒 | 🟒 |
123111
| | | πŸƒ Runtime | 🟒 | 🟒 | 🟒 |
124112
| | es-cjs | πŸ’» Compile | 🟒 | 🟒 | 🟒 |
@@ -127,16 +115,16 @@ Import Syntax:
127115
| | | πŸƒ Runtime | βž– | βž– | βž– |
128116
| | esm-cjs | πŸ’» Compile | 🟒 | 🟒 | 🟒 |
129117
| | | πŸƒ Runtime | 🟒 | 🟒 | 🟒 |
130-
| ES* | assert | πŸ’» Compile | πŸ”΄ TS1259-a | πŸ”΄ TS1259-a | 🟒 |
131-
| | | πŸƒ Runtime | 🟑 | 🟑 | πŸ”΄ not-fn |
132-
| | assertron | πŸ’» Compile | 🟑 TS1259-t | 🟑 TS1259-t | 🟑 TS1259-t |
133-
| | | πŸƒ Runtime | πŸ”΄ not-fn | πŸ”΄ not-fn | πŸ”΄ not-fn |
134-
| | param-case | πŸ’» Compile | πŸ”΄ TS1259-a | πŸ”΄ TS1259-a | πŸ”΄ TS2497-a TS2339 |
135-
| | | πŸƒ Runtime | 🟑 | 🟑 | πŸ”΄ not-fn |
118+
| ES* | assert | πŸ’» Compile | 🟒 | 🟒 | 🟒 |
119+
| | | πŸƒ Runtime | 🟒 | 🟒 | ❌ not-fn |
120+
| | assertron | πŸ’» Compile | 🟒 | 🟒 | 🟒 |
121+
| | | πŸƒ Runtime | ❌ not-fn | ❌ not-fn | ❌ not-fn |
122+
| | param-case | πŸ’» Compile | 🟒 | 🟒 | πŸ”΄ TS2497-a TS2339 |
123+
| | | πŸƒ Runtime | 🟒 | 🟒 | 🟑 |
136124
| | cjs | πŸ’» Compile | 🟒 | 🟒 | 🟒 |
137-
| | | πŸƒ Runtime | 🟒 | 🟒 | 🟒 |
125+
| | | πŸƒ Runtime | ❌ not-fn | ❌ not-fn | ❌ not-fn |
138126
| | es-cjs | πŸ’» Compile | 🟒 | 🟒 | 🟒 |
139-
| | | πŸƒ Runtime | 🟒 | 🟒 | 🟒 |
127+
| | | πŸƒ Runtime | ❌ not-fn | ❌ not-fn | ❌ not-fn |
140128
| | esm | πŸ’» Compile | βž– | βž– | βž– |
141129
| | | πŸƒ Runtime | βž– | βž– | βž– |
142130
| | esm-cjs | πŸ’» Compile | 🟒 | 🟒 | 🟒 |
@@ -170,6 +158,9 @@ Import Syntax:
170158

171159
## Conclusion
172160

173-
- `module: CommonJS` is the only "barely usable" one.
174-
- Cannot support `export =` type definition
161+
- `module: CommonJS` works on most cases.
162+
This is expected as that is the majority case for many years.
163+
- for `* as assert` case, while `esModuleInterop` tries to solve that problem,
164+
and the consumer should use the other forms. The compiler passing it is a bug IMO.
165+
- ❌ `module: ES*` fails with CJS is suprising, and if the test is correct, it's disturbing.
175166
- ❌ `module: Node*` compiled to CJS incorrectly

0 commit comments

Comments
Β (0)