Skip to content

Commit

Permalink
Only publish an extern from exports if there are exported members
Browse files Browse the repository at this point in the history
  • Loading branch information
kristoferbaxter committed Jan 7, 2020
1 parent 5d1e829 commit fc22ced
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/transformers/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
Identifier,
Node,
} from 'estree';
import { TransformSourceDescription, OutputOptions } from 'rollup';
import { TransformSourceDescription } from 'rollup';
import { NamedDeclaration, DefaultDeclaration } from './parsing-utilities';
import { isESMFormat } from '../options';
import {
Expand Down Expand Up @@ -102,17 +102,21 @@ export default class ExportTransform extends Transform implements TransformInter
});
}

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

for (const key of this.originalExports.keys()) {
const value: ExportDetails = this.originalExports.get(key) as ExportDetails;
if (value.source !== null) {
output += `function ${value.closureName}(){};\n`;
for (const key of this.originalExports.keys()) {
const value: ExportDetails = this.originalExports.get(key) as ExportDetails;
if (value.source !== null) {
output += `function ${value.closureName}(){};\n`;
}
}

return output;
}

return output;
return '';
}

/**
Expand Down

0 comments on commit fc22ced

Please sign in to comment.