You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(makeDefaultExport): add deprecation message for generated default exports
If a module does not define a default export, loader.js assigns `exports.default = exports` for compatibility with modules that don't use `_interopRequireDefault` from babel6. Mutating exports is unexpected behavior and causes difficult-to-diagnose [bugs][1]. We should remove `makeDefaultExport` in version 5.0. This update
* adds a deprecation warning in preparation for removing `makeDefaultExport`.
* adds a debug build with the deprecation enabled.
Addresses ember-cli#114
[1]:mike-north/ember-lodash#104
@@ -640,6 +641,11 @@ test('if factory returns a value it is used as export', function() {
640
641
});
641
642
642
643
test('if a module has no default property assume the return is the default',function(){
644
+
vardeprecationMessage;
645
+
require.deprecationLogger=function(message){
646
+
deprecationMessage=message;
647
+
};
648
+
643
649
define('foo',[],function(){
644
650
return{
645
651
bar: 'bar'
@@ -664,10 +670,17 @@ test('if a module has no default property assume the return is the default', fun
664
670
});
665
671
666
672
equal(foo.bar,'bar');
673
+
674
+
equal(deprecationMessage,'The `foo` module does not define a default export, but loader.js generated one anyway. This behavior is deprecated and will be removed in v5.0.0.');
667
675
});
668
676
669
677
670
678
test('if a CJS style module has no default export assume module.exports is the default',function(){
@@ -692,10 +705,17 @@ test('if a CJS style module has no default export assume module.exports is the d
692
705
resolveRelative: 0,
693
706
pendingQueueLength: 1
694
707
});
708
+
709
+
equal(deprecationMessage,'The `Foo` module does not define a default export, but loader.js generated one anyway. This behavior is deprecated and will be removed in v5.0.0.');
695
710
});
696
711
697
712
698
713
test('if a module has no default property assume its export is default (function)',function(){
@@ -718,9 +738,16 @@ test('if a module has no default property assume its export is default (function
718
738
resolveRelative: 0,
719
739
pendingQueueLength: 1
720
740
});
741
+
742
+
equal(deprecationMessage,'The `foo` module does not define a default export, but loader.js generated one anyway. This behavior is deprecated and will be removed in v5.0.0.');
721
743
});
722
744
723
745
test('if a module has no default property assume its export is default (object)',function(){
@@ -743,9 +770,16 @@ test('if a module has no default property assume its export is default (object)'
743
770
resolveRelative: 0,
744
771
pendingQueueLength: 1
745
772
});
773
+
774
+
equal(deprecationMessage,'The `foo` module does not define a default export, but loader.js generated one anyway. This behavior is deprecated and will be removed in v5.0.0.');
746
775
});
747
776
748
777
test('does not add default if export is frozen',function(){
0 commit comments