Skip to content

Commit fc22ced

Browse files
Only publish an extern from exports if there are exported members
1 parent 5d1e829 commit fc22ced

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/transformers/exports.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
Identifier,
2222
Node,
2323
} from 'estree';
24-
import { TransformSourceDescription, OutputOptions } from 'rollup';
24+
import { TransformSourceDescription } from 'rollup';
2525
import { NamedDeclaration, DefaultDeclaration } from './parsing-utilities';
2626
import { isESMFormat } from '../options';
2727
import {
@@ -102,17 +102,21 @@ export default class ExportTransform extends Transform implements TransformInter
102102
});
103103
}
104104

105-
public extern(options: OutputOptions): string {
106-
let output = EXTERN_OVERVIEW;
105+
public extern(): string {
106+
if (Array.from(this.originalExports.keys()).length > 0) {
107+
let output = EXTERN_OVERVIEW;
107108

108-
for (const key of this.originalExports.keys()) {
109-
const value: ExportDetails = this.originalExports.get(key) as ExportDetails;
110-
if (value.source !== null) {
111-
output += `function ${value.closureName}(){};\n`;
109+
for (const key of this.originalExports.keys()) {
110+
const value: ExportDetails = this.originalExports.get(key) as ExportDetails;
111+
if (value.source !== null) {
112+
output += `function ${value.closureName}(){};\n`;
113+
}
112114
}
115+
116+
return output;
113117
}
114118

115-
return output;
119+
return '';
116120
}
117121

118122
/**

0 commit comments

Comments
 (0)