@@ -196,45 +196,43 @@ function setup(pluginInfo, options) {
196196
197197 let htmlbarsOptions = buildOptions ( projectConfig , templateCompilerPath , pluginInfo ) ;
198198 let { templateCompiler } = htmlbarsOptions ;
199-
200- let templatePrecompile = templateCompiler . precompile ;
201-
202- let precompile = ( template , _options ) => {
203- // we have to reverse these for reasons that are a bit bonkers. the initial
204- // version of this system used `registeredPlugin` from
205- // `ember-template-compiler.js` to set up these plugins (because Ember ~ 1.13
206- // only had `registerPlugin`, and there was no way to pass plugins directly
207- // to the call to `compile`/`precompile`). calling `registerPlugin`
208- // unfortunately **inverted** the order of plugins (it essentially did
209- // `PLUGINS = [plugin, ...PLUGINS]`).
210- //
211- // sooooooo...... we are forced to maintain that **absolutely bonkers** ordering
212- let astPlugins = [ ...pluginInfo . plugins ] . reverse ( ) ;
213-
214- let options = {
215- plugins : {
216- ast : astPlugins ,
217- } ,
218-
219- ..._options ,
199+ if ( options . requiresModuleApiPolyfill ) {
200+ let templatePrecompile = templateCompiler . precompile ;
201+
202+ let precompile = ( template , _options ) => {
203+ // we have to reverse these for reasons that are a bit bonkers. the initial
204+ // version of this system used `registeredPlugin` from
205+ // `ember-template-compiler.js` to set up these plugins (because Ember ~ 1.13
206+ // only had `registerPlugin`, and there was no way to pass plugins directly
207+ // to the call to `compile`/`precompile`). calling `registerPlugin`
208+ // unfortunately **inverted** the order of plugins (it essentially did
209+ // `PLUGINS = [plugin, ...PLUGINS]`).
210+ //
211+ // sooooooo...... we are forced to maintain that **absolutely bonkers** ordering
212+ let astPlugins = [ ...pluginInfo . plugins ] . reverse ( ) ;
213+
214+ let options = {
215+ plugins : {
216+ ast : astPlugins ,
217+ } ,
218+
219+ ..._options ,
220+ } ;
221+
222+ return templatePrecompile ( template , options ) ;
220223 } ;
221224
222- return templatePrecompile ( template , options ) ;
223- } ;
224-
225- precompile . baseDir = ( ) => path . resolve ( __dirname , '..' ) ;
225+ precompile . baseDir = ( ) => path . resolve ( __dirname , '..' ) ;
226226
227- let cacheKey ;
228- precompile . cacheKey = ( ) => {
229- if ( cacheKey === undefined ) {
230- cacheKey = makeCacheKey ( templateCompilerPath , pluginInfo ) ;
231- }
232- cacheKey ;
233- } ;
227+ let cacheKey ;
228+ precompile . cacheKey = ( ) => {
229+ if ( cacheKey === undefined ) {
230+ cacheKey = makeCacheKey ( templateCompilerPath , pluginInfo ) ;
231+ }
232+ cacheKey ;
233+ } ;
234234
235- let plugin ;
236- if ( options . requiresModuleApiPolyfill ) {
237- plugin = [
235+ return [
238236 require . resolve ( 'babel-plugin-htmlbars-inline-precompile' ) ,
239237 {
240238 precompile,
@@ -245,10 +243,12 @@ function setup(pluginInfo, options) {
245243 'ember-cli-htmlbars:inline-precompile' ,
246244 ] ;
247245 } else {
248- plugin = [
246+ return [
249247 require . resolve ( 'babel-plugin-ember-template-compilation' ) ,
250248 {
251- precompile,
249+ // As above, we present the AST transforms in reverse order
250+ transforms : [ ...pluginInfo . plugins ] . reverse ( ) ,
251+ compilerPath : require . resolve ( templateCompilerPath ) ,
252252 enableLegacyModules : [
253253 'ember-cli-htmlbars' ,
254254 'ember-cli-htmlbars-inline-precompile' ,
@@ -258,8 +258,6 @@ function setup(pluginInfo, options) {
258258 'ember-cli-htmlbars:inline-precompile' ,
259259 ] ;
260260 }
261-
262- return plugin ;
263261}
264262
265263function getTemplateCompilerCacheKey ( templateCompilerPath ) {
0 commit comments