Skip to content

Commit

Permalink
Continued removing unnecessary guards with improved typing
Browse files Browse the repository at this point in the history
  • Loading branch information
kristoferbaxter committed Jan 8, 2020
1 parent be1e31a commit 551bbdb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
5 changes: 1 addition & 4 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ export const ERROR_WARNINGS_ENABLED_LANGUAGE_OUT_INVALID =
* @param format
* @return boolean
*/
export const isESMFormat = (format?: ModuleFormat): boolean => {
// TODO: remove `| 'esm'` when rollup upgrades its typings
return format === 'esm' || format === 'es';
};
export const isESMFormat = (format?: ModuleFormat): boolean => format === 'esm' || format === 'es';

/**
* Throw Errors if compile options will result in unexpected behaviour.
Expand Down
12 changes: 2 additions & 10 deletions src/transformers/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,7 @@ export default class ExportTransform extends Transform implements TransformInter
* @return modified input source with window scoped references.
*/
public async preCompilation(code: string): Promise<TransformSourceDescription> {
if (this.outputOptions === null) {
this.context.warn(
'Rollup Plugin Closure Compiler, OutputOptions not known before Closure Compiler invocation.',
);
} else if (isESMFormat(this.outputOptions.format)) {
if (isESMFormat(this.outputOptions.format)) {
await this.deriveExports(code);
const source = new MagicString(code);

Expand Down Expand Up @@ -171,11 +167,7 @@ export default class ExportTransform extends Transform implements TransformInter
* @return Promise containing the repaired source
*/
public async postCompilation(code: string): Promise<TransformSourceDescription> {
if (this.outputOptions === null) {
this.context.warn(
'Rollup Plugin Closure Compiler, OutputOptions not known before Closure Compiler invocation.',
);
} else if (isESMFormat(this.outputOptions.format)) {
if (isESMFormat(this.outputOptions.format)) {
const source = new MagicString(code);
const program = parse(code);
let collectedExportsToAppend: Map<string | null, Array<string>> = new Map();
Expand Down

0 comments on commit 551bbdb

Please sign in to comment.