@@ -86,6 +86,43 @@ dBabelVersion: ${hasValidBabelVersion};`
8686 if ( type === 'parent' ) {
8787 this . parentRegistry = registry ;
8888 }
89+
90+ let legacyInlinePrecompileAddon = this . parent . addons . find (
91+ a => a . name === 'ember-cli-htmlbars-inline-precompile'
92+ ) ;
93+ if ( legacyInlinePrecompileAddon !== undefined ) {
94+ let heirarchy = [ 'ember-cli-htmlbars-inline-precompile' ] ;
95+ let pointer = this ;
96+ while ( pointer . parent ) {
97+ heirarchy . push ( pointer . pkg . name ) ;
98+ pointer = pointer . parent ;
99+ }
100+
101+ this . ui . writeDeprecateLine (
102+ `${ heirarchy
103+ . reverse ( )
104+ . join (
105+ ' > '
106+ ) } is no longer needed with ember-cli-htmlbars versions 4.0.0 and higher, please remove it from \`${
107+ this . parent . root
108+ } /package.json\``
109+ ) ;
110+
111+ // overwrite the `included` method on the
112+ // ember-cli-htmlbars-inline-precompile instance this prevents issues
113+ // when using ember-cli-htmlbars-inline-precompile < 3.0.1 (where both
114+ // this addon and ember-cli-htmlbars-inline-precompile use the same
115+ // babel-plugin-htmlbars-inline-precompile version and get confused about
116+ // whether or not it registers its replacements)
117+ //
118+ // this only mutates the local addon _instance_ (not **all** instances of
119+ // the addon) because we _know_ that this instance of ember-cli-htmlbars
120+ // will take care of the precompilation of:
121+ //
122+ // import hbs from 'htmlbars-inline-precompile';
123+ // import hbs from 'ember-cli-htmlbars-inline-precompile';
124+ legacyInlinePrecompileAddon . included = function ( ) { } ;
125+ }
89126 } ,
90127
91128 included ( ) {
@@ -104,16 +141,10 @@ dBabelVersion: ${hasValidBabelVersion};`
104141
105142 let modules = {
106143 'ember-cli-htmlbars' : 'hbs' ,
144+ 'ember-cli-htmlbars-inline-precompile' : 'default' ,
145+ 'htmlbars-inline-precompile' : 'default' ,
107146 } ;
108147
109- // TODO: add deprecation to migrate import paths to use
110- // ember-cli-htmlbars instead of htmlbars-inline-precompile or
111- // ember-cli-htmlbars-inline-precompile
112- if ( ! this . parent . addons . find ( a => a . name === 'ember-cli-htmlbars-inline-precompile' ) ) {
113- modules [ 'ember-cli-htmlbars-inline-precompile' ] = 'default' ;
114- modules [ 'htmlbars-inline-precompile' ] = 'default' ;
115- }
116-
117148 if ( pluginInfo . canParallelize ) {
118149 logger . debug ( 'using parallel API with for babel inline precompilation plugin' ) ;
119150
@@ -164,7 +195,7 @@ dBabelVersion: ${hasValidBabelVersion};`
164195 } ,
165196
166197 /**
167- * This function checks if 'ember-cli -htmlbars-inline-precompile' is already present in babelPlugins.
198+ * This function checks if 'babel-plugin -htmlbars-inline-precompile' is already present in babelPlugins.
168199 * The plugin object will be different for non parallel API and parallel API.
169200 * For parallel api, check the `baseDir` of a plugin to see if it has current dirname
170201 * For non parallel api, check the 'modules' to see if it contains the babel plugin
@@ -173,14 +204,24 @@ dBabelVersion: ${hasValidBabelVersion};`
173204 _isInlinePrecompileBabelPluginRegistered ( plugins ) {
174205 return plugins . some ( plugin => {
175206 if ( Array . isArray ( plugin ) ) {
176- return plugin [ 0 ] === require . resolve ( 'babel-plugin-htmlbars-inline-precompile' ) ;
207+ let [ pluginPathOrInstance , options ] = plugin ;
208+
209+ return (
210+ pluginPathOrInstance === require . resolve ( 'babel-plugin-htmlbars-inline-precompile' ) &&
211+ typeof options . modules === 'object' &&
212+ options . modules [ 'ember-cli-htmlbars' ] === 'hbs'
213+ ) ;
177214 } else if (
178215 plugin !== null &&
179216 typeof plugin === 'object' &&
180217 plugin . _parallelBabel !== undefined
181218 ) {
182219 return (
183- plugin . _parallelBabel . requireFile === path . resolve ( __dirname , 'lib/require-from-worker' )
220+ plugin . _parallelBabel . requireFile ===
221+ path . resolve ( __dirname , 'lib/require-from-worker' ) &&
222+ typeof plugin . _parallelBabel . params === 'object' &&
223+ typeof plugin . _parallelBabel . params . modules === 'object' &&
224+ plugin . _parallelBabel . params . modules [ 'ember-cli-htmlbars' ] === 'hbs'
184225 ) ;
185226 } else {
186227 return false ;
0 commit comments