Skip to content

Commit 6ac41d1

Browse files
committed
Add include/exclude/entrypoints tests
1 parent aef8c09 commit 6ac41d1

20 files changed

+310
-15
lines changed

packages/cli/test/snapshots.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ const tests = [
2323
2424
2525
26+
27+
["[email protected]", "--entrypoints vue"],
28+
["[email protected]", "--entrypoints . jsx-runtime"],
29+
["[email protected]", "--exclude-entrypoints macros -f ascii"],
30+
["[email protected]", "--include-entrypoints ./foo -f ascii"],
2631
];
2732

2833
const defaultOpts = "-f table-flipped";
@@ -57,7 +62,7 @@ describe("snapshots", async () => {
5762
stdout = (error as SpawnSyncReturns<string>).stdout;
5863
exitCode = (error as SpawnSyncReturns<string>).status ?? 1;
5964
}
60-
const snapshotURL = new URL(`../snapshots/${fixture}.md`, import.meta.url);
65+
const snapshotURL = new URL(`../snapshots/${fixture.replace(/\//g, "")}.md`, import.meta.url);
6166
// prettier-ignore
6267
const expectedSnapshot = [
6368
`# ${fixture}`,

packages/cli/test/snapshots/@apollo__client-3.7.16.tgz.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# @apollo__client-3.7.16.tgz
22

33
```
4-
$ attw @apollo__client-3.7.16.tgz
4+
$ attw @apollo__client-3.7.16.tgz -f table-flipped
55
66
77
👺 Import resolved to an ESM type declaration file, but a CommonJS JavaScript file. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseESM.md

packages/cli/test/snapshots/@[email protected]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
22

33
```
4-
4+
$ attw @[email protected] -f table-flipped
55
66
77
⚠️ A require call resolved to an ESM JavaScript file, which is an error in Node and some bundlers. CommonJS consumers will need to use a dynamic import. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/CJSResolvesToESM.md

packages/cli/test/snapshots/@[email protected]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
22

33
```
4-
4+
$ attw @[email protected] -f table-flipped
55
66
77
🎭 Import resolved to a CommonJS type declaration file, but an ESM JavaScript file. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseCJS.md

packages/cli/test/snapshots/@[email protected]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
22

33
```
4-
4+
$ attw @[email protected] -f table-flipped
55
66
77
🎭 Import resolved to a CommonJS type declaration file, but an ESM JavaScript file. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseCJS.md

packages/cli/test/snapshots/[email protected]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
22

33
```
4-
4+
$ attw [email protected] -f table-flipped
55
66
77
❗️ The resolved types use export default where the JavaScript file appears to use module.exports =. This will cause TypeScript under the node16 module mode to think an extra .default property access is required, but that will likely fail at runtime. These types should use export = instead of export default. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseExportDefault.md

packages/cli/test/snapshots/[email protected]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
22

33
```
4-
4+
$ attw [email protected] -f table-flipped
55
66
77
🎭 Import resolved to a CommonJS type declaration file, but an ESM JavaScript file. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseCJS.md

packages/cli/test/snapshots/[email protected]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
22

33
```
4-
4+
$ attw [email protected] -f table-flipped
55
66
77
❓ Wildcard subpaths cannot yet be analyzed by this tool. https://github.com/arethetypeswrong/arethetypeswrong.github.io/issues/40

packages/cli/test/snapshots/[email protected]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
22

33
```
4-
4+
$ attw [email protected] -f table-flipped
55
66
77
This package does not contain types.

packages/cli/test/snapshots/[email protected]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
22

33
```
4-
4+
$ attw [email protected] -f table-flipped
55
66
77
❗️ The resolved types use export default where the JavaScript file appears to use module.exports =. This will cause TypeScript under the node16 module mode to think an extra .default property access is required, but that will likely fail at runtime. These types should use export = instead of export default. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseExportDefault.md

packages/cli/test/snapshots/[email protected]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
22

33
```
4-
4+
$ attw [email protected] -f table-flipped
55
66
77
🤨 CommonJS module simulates a default export with exports.default and exports.__esModule, but does not also set module.exports for compatibility with Node. Node, and some bundlers under certain conditions (https://andrewbranch.github.io/interop-test/#synthesizing-default-exports-for-cjs-modules), do not respect the __esModule marker, so accessing the intended default export will require a .default property access on the default import. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/CJSOnlyExportsDefault.md

packages/cli/test/snapshots/[email protected]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
22

33
```
4-
4+
$ attw [email protected] -f table-flipped
55
66
77
🎭 Import resolved to a CommonJS type declaration file, but an ESM JavaScript file. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseCJS.md

packages/cli/test/snapshots/[email protected]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
22

33
```
4-
4+
$ attw [email protected] -f table-flipped
55
66
77
👺 Import resolved to an ESM type declaration file, but a CommonJS JavaScript file. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseESM.md

packages/cli/test/snapshots/[email protected]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
22

33
```
4-
4+
$ attw [email protected] -f table-flipped
55
66
77
❌ Import resolved to JavaScript files, but no type declarations were found. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/UntypedResolution.md
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# [email protected] --entrypoints . jsx-runtime
2+
3+
```
4+
$ attw [email protected] --entrypoints . jsx-runtime
5+
6+
7+
🎭 Import resolved to a CommonJS type declaration file, but an ESM JavaScript file. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseCJS.md
8+
9+
🥴 Import found in a type declaration file failed to resolve. Either this indicates that runtime resolution errors will occur, or (more likely) the types misrepresent the contents of the JavaScript files. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/InternalResolutionError.md
10+
11+
12+
┌────────────────────┬───────────────────────────────────┬───────────────────────────────────┐
13+
│ │ "vue" │ "vue/jsx-runtime" │
14+
├────────────────────┼───────────────────────────────────┼───────────────────────────────────┤
15+
│ node10 │ 🟢 │ 🟢 │
16+
├────────────────────┼───────────────────────────────────┼───────────────────────────────────┤
17+
│ node16 (from CJS) │ 🟢 (CJS) │ 🟢 (CJS) │
18+
├────────────────────┼───────────────────────────────────┼───────────────────────────────────┤
19+
│ node16 (from ESM) │ 🥴 Internal resolution error │ 🎭 Masquerading as CJS │
20+
├────────────────────┼───────────────────────────────────┼───────────────────────────────────┤
21+
│ bundler │ 🟢 │ 🟢 │
22+
└────────────────────┴───────────────────────────────────┴───────────────────────────────────┘
23+
24+
25+
```
26+
27+
Exit code: 1
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# [email protected] --entrypoints vue
2+
3+
```
4+
$ attw [email protected] --entrypoints vue
5+
6+
7+
🥴 Import found in a type declaration file failed to resolve. Either this indicates that runtime resolution errors will occur, or (more likely) the types misrepresent the contents of the JavaScript files. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/InternalResolutionError.md
8+
9+
10+
┌────────────────────┬───────────────────────────────────┐
11+
│ │ "vue" │
12+
├────────────────────┼───────────────────────────────────┤
13+
│ node10 │ 🟢 │
14+
├────────────────────┼───────────────────────────────────┤
15+
│ node16 (from CJS) │ 🟢 (CJS) │
16+
├────────────────────┼───────────────────────────────────┤
17+
│ node16 (from ESM) │ 🥴 Internal resolution error │
18+
├────────────────────┼───────────────────────────────────┤
19+
│ bundler │ 🟢 │
20+
└────────────────────┴───────────────────────────────────┘
21+
22+
23+
```
24+
25+
Exit code: 1
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# [email protected] --exclude-entrypoints macros -f ascii
2+
3+
```
4+
$ attw [email protected] --exclude-entrypoints macros -f ascii
5+
6+
7+
🎭 Import resolved to a CommonJS type declaration file, but an ESM JavaScript file. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseCJS.md
8+
9+
💀 Import failed to resolve to type declarations or JavaScript files. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/NoResolution.md
10+
11+
❓ Wildcard subpaths cannot yet be analyzed by this tool. https://github.com/arethetypeswrong/arethetypeswrong.github.io/issues/40
12+
13+
🥴 Import found in a type declaration file failed to resolve. Either this indicates that runtime resolution errors will occur, or (more likely) the types misrepresent the contents of the JavaScript files. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/InternalResolutionError.md
14+
15+
16+
"vue"
17+
18+
node10: 🟢
19+
node16 (from CJS): 🟢 (CJS)
20+
node16 (from ESM): 🥴 Internal resolution error
21+
bundler: 🟢
22+
23+
***********************************
24+
25+
"vue/server-renderer"
26+
27+
node10: 🟢
28+
node16 (from CJS): 🟢 (CJS)
29+
node16 (from ESM): 🟢 (ESM)
30+
bundler: 🟢
31+
32+
***********************************
33+
34+
"vue/compiler-sfc"
35+
36+
node10: 🟢
37+
node16 (from CJS): 🟢 (CJS)
38+
node16 (from ESM): 🟢 (ESM)
39+
bundler: 🟢
40+
41+
***********************************
42+
43+
"vue/jsx-runtime"
44+
45+
node10: 🟢
46+
node16 (from CJS): 🟢 (CJS)
47+
node16 (from ESM): 🎭 Masquerading as CJS
48+
bundler: 🟢
49+
50+
***********************************
51+
52+
"vue/jsx-dev-runtime"
53+
54+
node10: 💀 Resolution failed
55+
node16 (from CJS): 🟢 (CJS)
56+
node16 (from ESM): 🎭 Masquerading as CJS
57+
bundler: 🟢
58+
59+
***********************************
60+
61+
"vue/jsx"
62+
63+
node10: 🟢
64+
node16 (from CJS): 🟢 (CJS)
65+
node16 (from ESM): 🟢 (CJS)
66+
bundler: 🟢
67+
68+
***********************************
69+
70+
"vue/dist/*"
71+
72+
node10: ❓ Unable to check
73+
node16 (from CJS): ❓ Unable to check
74+
node16 (from ESM): ❓ Unable to check
75+
bundler: ❓ Unable to check
76+
77+
***********************************
78+
79+
"vue/package.json"
80+
81+
node10: 🟢 (JSON)
82+
node16 (from CJS): 🟢 (JSON)
83+
node16 (from ESM): 🟢 (JSON)
84+
bundler: 🟢 (JSON)
85+
86+
***********************************
87+
88+
"vue/macros-global"
89+
90+
node10: 🟢
91+
node16 (from CJS): 🟢 (CJS)
92+
node16 (from ESM): 🟢 (CJS)
93+
bundler: 🟢
94+
95+
***********************************
96+
97+
"vue/ref-macros"
98+
99+
node10: 🟢
100+
node16 (from CJS): 🟢 (CJS)
101+
node16 (from ESM): 🟢 (CJS)
102+
bundler: 🟢
103+
104+
***********************************
105+
106+
107+
```
108+
109+
Exit code: 1

0 commit comments

Comments
 (0)