Repository navigation
Commit 5798eda
authored
feat: add interop hint for object externals (#21371)
A non-ESM external (amd/umd/commonjs/...) is a dynamic module, so importing
its default from a strict ES module (package "type": "module") yields the
whole exports object instead of the unboxed default, while a non-strict
importer unboxes it. This importer-dependent behavior matches Node.js and
esbuild but leaves no way to pin the interop for a specific external.
Add an `interop` hint on the object form of an external, mirroring Rollup's
`output.interop`:
- "esModule": treat the external as an ES module namespace, so `default`
unboxes to `.default` regardless of the importer's strictness.
- "default": treat the external as CommonJS, so `default` is the whole
exports (Node.js semantics).
Closes #203831 parent 243396c commit 5798eda
11 files changed
Lines changed: 402 additions & 18 deletions
File tree
- .changeset
- declarations
- lib
- schemas
- test
- configCases/externals/interop-amd
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
878 | 878 | | |
879 | 879 | | |
880 | 880 | | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
881 | 885 | | |
882 | 886 | | |
883 | 887 | | |
884 | 888 | | |
885 | 889 | | |
886 | 890 | | |
887 | 891 | | |
888 | | - | |
889 | | - | |
890 | | - | |
| 892 | + | |
891 | 893 | | |
892 | 894 | | |
893 | 895 | | |
| |||
4421 | 4423 | | |
4422 | 4424 | | |
4423 | 4425 | | |
| 4426 | + | |
| 4427 | + | |
| 4428 | + | |
| 4429 | + | |
| 4430 | + | |
| 4431 | + | |
| 4432 | + | |
| 4433 | + | |
| 4434 | + | |
| 4435 | + | |
| 4436 | + | |
| 4437 | + | |
| 4438 | + | |
| 4439 | + | |
| 4440 | + | |
| 4441 | + | |
| 4442 | + | |
| 4443 | + | |
4424 | 4444 | | |
4425 | 4445 | | |
4426 | 4446 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
72 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
| |||
829 | 830 | | |
830 | 831 | | |
831 | 832 | | |
| 833 | + | |
832 | 834 | | |
833 | | - | |
| 835 | + | |
834 | 836 | | |
835 | 837 | | |
836 | 838 | | |
| |||
846 | 848 | | |
847 | 849 | | |
848 | 850 | | |
| 851 | + | |
| 852 | + | |
849 | 853 | | |
850 | 854 | | |
851 | 855 | | |
| |||
917 | 921 | | |
918 | 922 | | |
919 | 923 | | |
| 924 | + | |
920 | 925 | | |
921 | 926 | | |
922 | 927 | | |
| |||
1050 | 1055 | | |
1051 | 1056 | | |
1052 | 1057 | | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
1053 | 1072 | | |
1054 | 1073 | | |
1055 | 1074 | | |
| |||
1427 | 1446 | | |
1428 | 1447 | | |
1429 | 1448 | | |
| 1449 | + | |
1430 | 1450 | | |
1431 | 1451 | | |
1432 | 1452 | | |
| |||
1439 | 1459 | | |
1440 | 1460 | | |
1441 | 1461 | | |
1442 | | - | |
| 1462 | + | |
| 1463 | + | |
1443 | 1464 | | |
1444 | 1465 | | |
1445 | 1466 | | |
| |||
1456 | 1477 | | |
1457 | 1478 | | |
1458 | 1479 | | |
| 1480 | + | |
| 1481 | + | |
1459 | 1482 | | |
1460 | | - | |
| 1483 | + | |
1461 | 1484 | | |
1462 | 1485 | | |
1463 | 1486 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
161 | 162 | | |
162 | 163 | | |
163 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
164 | 182 | | |
165 | 183 | | |
166 | 184 | | |
| |||
239 | 257 | | |
240 | 258 | | |
241 | 259 | | |
242 | | - | |
| 260 | + | |
| 261 | + | |
243 | 262 | | |
244 | 263 | | |
245 | 264 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1446 | 1446 | | |
1447 | 1447 | | |
1448 | 1448 | | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
1449 | 1453 | | |
1450 | 1454 | | |
1451 | 1455 | | |
| |||
1466 | 1470 | | |
1467 | 1471 | | |
1468 | 1472 | | |
1469 | | - | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
1470 | 1497 | | |
1471 | 1498 | | |
1472 | 1499 | | |
| |||
0 commit comments