@@ -458,6 +458,289 @@ describe('ember-cli-babel', function() {
458458          } ) ; 
459459        } ) ) ; 
460460
461+         it ( "when transpiling with compileModules: false it should use Ember global for previously 'fake' imports even on Ember 3.27+" ,  co . wrap ( function *  ( )  { 
462+           process . env . EMBER_ENV  =  'development' ; 
463+ 
464+           dependencies [ 
465+             "ember-source" 
466+           ]  =  POST_EMBER_MODULE_IMPORTS_VERSION ; 
467+           input . write ( 
468+             buildEmberSourceFixture ( POST_EMBER_MODULE_IMPORTS_VERSION ) 
469+           ) ; 
470+ 
471+           input . write ( { 
472+             app : { 
473+               "foo.js" : stripIndent ` 
474+                 import Component from '@ember/component'; 
475+ 
476+                 export default class extends Component {} 
477+               ` , 
478+             } , 
479+           } ) ; 
480+ 
481+           this . addon . project . targets  =  { 
482+             browsers : [ 'last 2 chrome versions' ] 
483+           } ; 
484+ 
485+           subject  =  this . addon . transpileTree ( input . path ( 'app' ) ,  { 
486+             'ember-cli-babel' : { 
487+               compileModules : false , 
488+             } 
489+           } ) ; 
490+           output  =  createBuilder ( subject ) ; 
491+ 
492+           yield  output . build ( ) ; 
493+ 
494+           expect ( 
495+             output . read ( ) 
496+           ) . to . deep . equal ( { 
497+             "foo.js" : `export default class extends Ember.Component {}` , 
498+           } ) ; 
499+         } ) ) ; 
500+ 
501+         it ( "when transpiling with compileModules: false, disableEmberModulesAPIPolyfill: true it should not use Ember global for previously 'fake' imports" ,  co . wrap ( function *  ( )  { 
502+           process . env . EMBER_ENV  =  'development' ; 
503+ 
504+           dependencies [ 
505+             "ember-source" 
506+           ]  =  POST_EMBER_MODULE_IMPORTS_VERSION ; 
507+           input . write ( 
508+             buildEmberSourceFixture ( POST_EMBER_MODULE_IMPORTS_VERSION ) 
509+           ) ; 
510+ 
511+           input . write ( { 
512+             app : { 
513+               "foo.js" : stripIndent ` 
514+                 import Component from '@ember/component'; 
515+ 
516+                 export default class extends Component {} 
517+               ` , 
518+             } , 
519+           } ) ; 
520+ 
521+           this . addon . project . targets  =  { 
522+             browsers : [ 'last 2 chrome versions' ] 
523+           } ; 
524+ 
525+           subject  =  this . addon . transpileTree ( input . path ( 'app' ) ,  { 
526+             'ember-cli-babel' : { 
527+               compileModules : false , 
528+               disableEmberModulesAPIPolyfill : true , 
529+             } 
530+           } ) ; 
531+           output  =  createBuilder ( subject ) ; 
532+ 
533+           yield  output . build ( ) ; 
534+ 
535+           expect ( 
536+             output . read ( ) 
537+           ) . to . deep . equal ( { 
538+             "foo.js" : `import Component from '@ember/component';\nexport default class extends Component {}` , 
539+           } ) ; 
540+         } ) ) ; 
541+ 
542+         it ( "when transpiling with compileModules: false, disableEmberModulesAPIPolyfill: false it should use global for Ember < 3.27" ,  co . wrap ( function *  ( )  { 
543+           process . env . EMBER_ENV  =  'development' ; 
544+ 
545+           dependencies [ 
546+             "ember-source" 
547+           ]  =  PRE_EMBER_MODULE_IMPORTS_VERSION ; 
548+           input . write ( 
549+             buildEmberSourceFixture ( PRE_EMBER_MODULE_IMPORTS_VERSION ) 
550+           ) ; 
551+ 
552+           input . write ( { 
553+             app : { 
554+               "foo.js" : stripIndent ` 
555+                 import Component from '@ember/component'; 
556+ 
557+                 export default class extends Component {} 
558+               ` , 
559+             } , 
560+           } ) ; 
561+ 
562+           this . addon . project . targets  =  { 
563+             browsers : [ 'last 2 chrome versions' ] 
564+           } ; 
565+ 
566+           subject  =  this . addon . transpileTree ( input . path ( 'app' ) ,  { 
567+             'ember-cli-babel' : { 
568+               compileModules : false , 
569+               disableEmberModulesAPIPolyfill : false , 
570+             } 
571+           } ) ; 
572+           output  =  createBuilder ( subject ) ; 
573+ 
574+           yield  output . build ( ) ; 
575+ 
576+           expect ( 
577+             output . read ( ) 
578+           ) . to . deep . equal ( { 
579+             "foo.js" : `export default class extends Ember.Component {}` , 
580+           } ) ; 
581+         } ) ) ; 
582+ 
583+         it ( "when transpiling with compileModules: false, disableEmberModulesAPIPolyfill: false it should use global for Ember > 3.27" ,  co . wrap ( function *  ( )  { 
584+           process . env . EMBER_ENV  =  'development' ; 
585+ 
586+           dependencies [ 
587+             "ember-source" 
588+           ]  =  POST_EMBER_MODULE_IMPORTS_VERSION ; 
589+           input . write ( 
590+             buildEmberSourceFixture ( POST_EMBER_MODULE_IMPORTS_VERSION ) 
591+           ) ; 
592+ 
593+           input . write ( { 
594+             app : { 
595+               "foo.js" : stripIndent ` 
596+                 import Component from '@ember/component'; 
597+ 
598+                 export default class extends Component {} 
599+               ` , 
600+             } , 
601+           } ) ; 
602+ 
603+           this . addon . project . targets  =  { 
604+             browsers : [ 'last 2 chrome versions' ] 
605+           } ; 
606+ 
607+           subject  =  this . addon . transpileTree ( input . path ( 'app' ) ,  { 
608+             'ember-cli-babel' : { 
609+               compileModules : false , 
610+               disableEmberModulesAPIPolyfill : false , 
611+             } 
612+           } ) ; 
613+           output  =  createBuilder ( subject ) ; 
614+ 
615+           yield  output . build ( ) ; 
616+ 
617+           expect ( 
618+             output . read ( ) 
619+           ) . to . deep . equal ( { 
620+             "foo.js" : `import Component from '@ember/component';\nexport default class extends Component {}` , 
621+           } ) ; 
622+         } ) ) ; 
623+ 
624+         it ( "when transpiling with compileModules: false, disableDebugTooling: false it should use modules for debug tooling" ,  co . wrap ( function *  ( )  { 
625+           process . env . EMBER_ENV  =  'development' ; 
626+ 
627+           dependencies [ 
628+             "ember-source" 
629+           ]  =  POST_EMBER_MODULE_IMPORTS_VERSION ; 
630+           input . write ( 
631+             buildEmberSourceFixture ( POST_EMBER_MODULE_IMPORTS_VERSION ) 
632+           ) ; 
633+ 
634+           input . write ( { 
635+             app : { 
636+               "foo.js" : stripIndent ` 
637+                 import { assert } from '@ember/debug'; 
638+                 assert('stuff here', isNotBad()); 
639+               ` , 
640+               "bar.js" : stripIndent ` 
641+                 import { deprecate } from '@ember/debug'; 
642+                 deprecate( 
643+                   'foo bar baz', 
644+                   false, 
645+                   { 
646+                     id: 'some-id', 
647+                     until: '1.0.0', 
648+                   } 
649+                 ); 
650+               ` , 
651+               "baz.js" : stripIndent ` 
652+                 import { deprecate } from '@ember/application/deprecations'; 
653+                 deprecate( 
654+                   'foo bar baz', 
655+                   false, 
656+                   { 
657+                     id: 'some-id', 
658+                     until: '1.0.0', 
659+                   } 
660+                 ); 
661+               ` , 
662+             } , 
663+           } ) ; 
664+ 
665+           subject  =  this . addon . transpileTree ( input . path ( 'app' ) ,  { 
666+             'ember-cli-babel' : { 
667+               compileModules : false , 
668+               disableDebugTooling : false , 
669+             } 
670+           } ) ; 
671+           output  =  createBuilder ( subject ) ; 
672+ 
673+           yield  output . build ( ) ; 
674+ 
675+           expect ( 
676+             output . read ( ) 
677+           ) . to . deep . equal ( { 
678+             "bar.js" : `import { deprecate } from '@ember/debug';\n(true && !(false) && deprecate('foo bar baz', false, {\n  id: 'some-id',\n  until: '1.0.0'\n}));` , 
679+             "baz.js" : `import { deprecate } from '@ember/application/deprecations';\n(true && !(false) && deprecate('foo bar baz', false, {\n  id: 'some-id',\n  until: '1.0.0'\n}));` , 
680+             "foo.js" : `import { assert } from '@ember/debug';\n(true && !(isNotBad()) && assert('stuff here', isNotBad()));` , 
681+           } ) ; 
682+         } ) ) ; 
683+ 
684+         it ( "when transpiling with compileModules: false, disableDebugTooling: true it should not use Ember global for debug tooling" ,  co . wrap ( function *  ( )  { 
685+           process . env . EMBER_ENV  =  'development' ; 
686+ 
687+           dependencies [ 
688+             "ember-source" 
689+           ]  =  POST_EMBER_MODULE_IMPORTS_VERSION ; 
690+           input . write ( 
691+             buildEmberSourceFixture ( POST_EMBER_MODULE_IMPORTS_VERSION ) 
692+           ) ; 
693+ 
694+           input . write ( { 
695+             app : { 
696+               "foo.js" : stripIndent ` 
697+                 import { assert } from '@ember/debug'; 
698+                 assert('stuff here', isNotBad()); 
699+               ` , 
700+               "bar.js" : stripIndent ` 
701+                 import { deprecate } from '@ember/debug'; 
702+                 deprecate( 
703+                   'foo bar baz', 
704+                   false, 
705+                   { 
706+                     id: 'some-id', 
707+                     until: '1.0.0', 
708+                   } 
709+                 ); 
710+               ` , 
711+               "baz.js" : stripIndent ` 
712+                 import { deprecate } from '@ember/application/deprecations'; 
713+                 deprecate( 
714+                   'foo bar baz', 
715+                   false, 
716+                   { 
717+                     id: 'some-id', 
718+                     until: '1.0.0', 
719+                   } 
720+                 ); 
721+               ` , 
722+             } , 
723+           } ) ; 
724+ 
725+           subject  =  this . addon . transpileTree ( input . path ( 'app' ) ,  { 
726+             'ember-cli-babel' : { 
727+               compileModules : false , 
728+               disableDebugTooling : true , 
729+             } 
730+           } ) ; 
731+           output  =  createBuilder ( subject ) ; 
732+ 
733+           yield  output . build ( ) ; 
734+ 
735+           expect ( 
736+             output . read ( ) 
737+           ) . to . deep . equal ( { 
738+             "bar.js" : `import { deprecate } from '@ember/debug';\ndeprecate('foo bar baz', false, {\n  id: 'some-id',\n  until: '1.0.0'\n});` , 
739+             "baz.js" : `import { deprecate } from '@ember/application/deprecations';\ndeprecate('foo bar baz', false, {\n  id: 'some-id',\n  until: '1.0.0'\n});` , 
740+             "foo.js" : `import { assert } from '@ember/debug';\nassert('stuff here', isNotBad());` , 
741+           } ) ; 
742+         } ) ) ; 
743+ 
461744        it ( "when transpiling with compileModules: false, it should use Ember global even on Ember 3.27+" ,  co . wrap ( function *  ( )  { 
462745          process . env . EMBER_ENV  =  'development' ; 
463746
0 commit comments