@@ -21,12 +21,16 @@ function writeImportStatement(j, root) {
2121
2222 // if any imports from 'htmlbars-inline-precompile' exists, remove it and replace with a new import
2323 if ( inlinePrecompileImportStatement . length !== 0 ) {
24- inlinePrecompileImportStatement . remove ( ) ;
24+ // setting up import information
25+ let namedIdentifier = inlinePrecompileImportStatement . find ( j . Identifier ) . get ( 0 ) . node . name ;
26+ if ( namedIdentifier !== 'hbs' ) {
27+ namedIdentifier = `hbs as ${ namedIdentifier } ` ;
28+ }
29+ const identifier = j . identifier ( namedIdentifier ) ;
30+ const variableId = j . importSpecifier ( identifier ) ;
2531
26- // setting up 'hbs' as an identifier for import statement
27- const hbs = 'hbs' ;
28- const hbsAsIdentifier = j . identifier ( hbs ) ;
29- const variableId = j . importSpecifier ( hbsAsIdentifier ) ;
32+ // remove imports from 'htmlbars-inline-precompile'
33+ inlinePrecompileImportStatement . remove ( ) ;
3034
3135 // finding all 'ember-cli-htmlbars' import statements
3236 const emberCliImportStatement = root . find ( j . ImportDeclaration , {
@@ -35,15 +39,15 @@ function writeImportStatement(j, root) {
3539 } ,
3640 } ) ;
3741
38- // if no imports from 'ember-cli-htmlbars' exists, write import { hbs } from 'ember-cli-htmlbars' ;
42+ // if no imports from 'ember-cli-htmlbars' exists, write one ;
3943 if ( emberCliImportStatement . length === 0 ) {
4044 const importStatement = j . importDeclaration ( [ variableId ] , j . literal ( 'ember-cli-htmlbars' ) ) ;
4145 body . unshift ( importStatement ) ;
4246 }
4347 // if any imports from 'ember-cli-htmlbars' already exists, include hbs
4448 else {
4549 let existingSpecifiers = emberCliImportStatement . get ( 'specifiers' ) ;
46- if ( existingSpecifiers . filter ( exSp => exSp . value . imported . name === hbs ) . length === 0 ) {
50+ if ( existingSpecifiers . filter ( exSp => exSp . value . imported . name === ' hbs' ) . length === 0 ) {
4751 existingSpecifiers . push ( variableId ) ;
4852 }
4953 }
0 commit comments