From 551bbdb7bf229b2779e3fbb71aa96c9f913217eb Mon Sep 17 00:00:00 2001 From: Kristofer Baxter Date: Tue, 7 Jan 2020 17:36:22 -0800 Subject: [PATCH] Continued removing unnecessary guards with improved typing --- src/options.ts | 5 +---- src/transformers/exports.ts | 12 ++---------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/options.ts b/src/options.ts index 0a888c83..8f634ccd 100644 --- a/src/options.ts +++ b/src/options.ts @@ -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. diff --git a/src/transformers/exports.ts b/src/transformers/exports.ts index eda4e6e5..d58b5f6d 100644 --- a/src/transformers/exports.ts +++ b/src/transformers/exports.ts @@ -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 { - 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); @@ -171,11 +167,7 @@ export default class ExportTransform extends Transform implements TransformInter * @return Promise containing the repaired source */ public async postCompilation(code: string): Promise { - 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> = new Map();