From 88fda657f477f0ddff7565b689ad5ea02e39affe Mon Sep 17 00:00:00 2001 From: Nicolas HENRY Date: Thu, 19 Apr 2018 19:52:26 +0200 Subject: [PATCH] chore(build): fix v5 imports (#2465) --- scripts/build/transformers/imports.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/build/transformers/imports.ts b/scripts/build/transformers/imports.ts index 974165a41..9e8059e6a 100644 --- a/scripts/build/transformers/imports.ts +++ b/scripts/build/transformers/imports.ts @@ -19,7 +19,9 @@ function transformImports(file: ts.SourceFile, ctx: ts.TransformationContext, ng const decoratorRegex: RegExp = /@([a-zA-Z]+)\(/g; - const ignored: string [] = ['Plugin', 'Component']; + const ignored: string [] = ['Plugin', 'Component', 'Injectable']; + + const keep: string [] = ['getPromise']; let m; @@ -37,15 +39,18 @@ function transformImports(file: ts.SourceFile, ctx: ts.TransformationContext, ng importStatement.importClause.namedBindings.elements = [ ts.createIdentifier('IonicNativePlugin'), - ...methods.map(m => ts.createIdentifier(m)) + ...methods.map(m => ts.createIdentifier(m)), + ...importStatement.importClause.namedBindings.elements.filter(el => keep.indexOf(el.name.text) !== -1) ]; if (ngcBuild) { importStatement.importClause.namedBindings.elements = importStatement.importClause.namedBindings.elements.map( binding => { - binding.name = { - text: binding.escapedText - }; + if (binding.escapedText) { + binding.name = { + text: binding.escapedText + }; + } return binding; } );