Commit c0e7b5f
authored
fix(iife):
### Description
closes #2255
The main improvements include adding a check for `hasExports` and
altering some of the structural writing, which makes the code clearer.
The following are the conditions for warning in `Rollup`.
```ts
if (hasExports && !name) {
log(LOGLEVEL_WARN, logMissingNameOptionForIifeExport());
}
```
At present, there is no clue about `reexports`.
```ts
const renderedExports = exportMode === 'none' ? [] : this.getChunkExportDeclarations(format);
let hasExports = renderedExports.length > 0;
let hasDefaultExport = false;
for (const renderedDependence of renderedDependencies) {
const { reexports } = renderedDependence;
if (reexports?.length) {
hasExports = true;
if (!hasDefaultExport && reexports.some(reexport => reexport.reexported === 'default')) {
hasDefaultExport = true;
}
if (format === 'es') {
renderedDependence.reexports = reexports.filter(
// eslint-disable-next-line unicorn/prefer-array-some
({ reexported }) => !renderedExports.find(({ exported }) => exported === reexported)
);
}
}
}
```MISSING_NAME_OPTION_FOR_IIFE_EXPORT is output even if nothing is exported from the entrypoint (#2256)1 parent d2fc33a commit c0e7b5f
3 files changed
Lines changed: 67 additions & 41 deletions
File tree
- crates/rolldown
- src/ecmascript/format/utils
- tests/rolldown/function/extend/iife
- no_name_default
- no_name_named
Lines changed: 51 additions & 41 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
107 | 71 | | |
108 | 72 | | |
109 | 73 | | |
110 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
111 | 121 | | |
112 | 122 | | |
113 | 123 | | |
| |||
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
4 | 12 | | |
5 | 13 | | |
6 | 14 | | |
| |||
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
4 | 12 | | |
5 | 13 | | |
6 | 14 | | |
| |||
0 commit comments