File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -184,13 +184,8 @@ dBabelVersion: ${hasValidBabelVersion};`
184184 }
185185 }
186186
187- if ( this . _shouldColocateTemplates ( ) ) {
188- const { hasPlugin, addPlugin } = require ( 'ember-cli-babel-plugin-helpers' ) ;
189- let colocatedPluginPath = require . resolve ( './colocated-babel-plugin' ) ;
190-
191- if ( ! hasPlugin ( babelPlugins , colocatedPluginPath ) ) {
192- addPlugin ( babelPlugins , colocatedPluginPath ) ;
193- }
187+ if ( this . _shouldColocateTemplates ( ) && ! utils . isColocatedBabelPluginRegistered ( babelPlugins ) ) {
188+ babelPlugins . push ( require . resolve ( './colocated-babel-plugin' ) ) ;
194189 }
195190 } ,
196191
Original file line number Diff line number Diff line change @@ -34,6 +34,12 @@ function isInlinePrecompileBabelPluginRegistered(plugins) {
3434 } ) ;
3535}
3636
37+ function isColocatedBabelPluginRegistered ( plugins ) {
38+ return plugins . some (
39+ plugin => typeof plugin === 'string' && plugin === require . resolve ( './colocated-babel-plugin' )
40+ ) ;
41+ }
42+
3743function buildOptions ( projectConfig , templateCompilerPath , pluginInfo ) {
3844 let EmberENV = projectConfig . EmberENV || { } ;
3945
@@ -248,5 +254,6 @@ module.exports = {
248254 setup,
249255 makeCacheKey,
250256 setupPlugins,
257+ isColocatedBabelPluginRegistered,
251258 isInlinePrecompileBabelPluginRegistered,
252259} ;
Original file line number Diff line number Diff line change @@ -166,4 +166,18 @@ describe('utils', function() {
166166 assert . strictEqual ( utils . isInlinePrecompileBabelPluginRegistered ( plugins ) , true ) ;
167167 } ) ;
168168 } ) ;
169+
170+ describe ( 'isColocatedBabelPluginRegistered' , function ( ) {
171+ it ( 'is false when no plugins exist' , function ( ) {
172+ let plugins = [ ] ;
173+
174+ assert . strictEqual ( utils . isColocatedBabelPluginRegistered ( plugins ) , false ) ;
175+ } ) ;
176+
177+ it ( 'detects when the plugin exists' , function ( ) {
178+ let plugins = [ require . resolve ( '../lib/colocated-babel-plugin' ) ] ;
179+
180+ assert . strictEqual ( utils . isColocatedBabelPluginRegistered ( plugins ) , true ) ;
181+ } ) ;
182+ } ) ;
169183} ) ;
You can’t perform that action at this time.
0 commit comments