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
Copy file name to clipboardexpand all lines: tests/all.js
+42
Original file line number
Diff line number
Diff line change
@@ -640,6 +640,11 @@ test('if factory returns a value it is used as export', function() {
640
640
});
641
641
642
642
test('if a module has no default property assume the return is the default',function(){
643
+
vardeprecationMessage;
644
+
require.deprecationLogger=function(message){
645
+
deprecationMessage=message;
646
+
};
647
+
643
648
define('foo',[],function(){
644
649
return{
645
650
bar: 'bar'
@@ -664,10 +669,17 @@ test('if a module has no default property assume the return is the default', fun
664
669
});
665
670
666
671
equal(foo.bar,'bar');
672
+
673
+
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
674
});
668
675
669
676
670
677
test('if a CJS style module has no default export assume module.exports is the default',function(){
@@ -692,10 +704,17 @@ test('if a CJS style module has no default export assume module.exports is the d
692
704
resolveRelative: 0,
693
705
pendingQueueLength: 1
694
706
});
707
+
708
+
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
709
});
696
710
697
711
698
712
test('if a module has no default property assume its export is default (function)',function(){
@@ -718,9 +737,16 @@ test('if a module has no default property assume its export is default (function
718
737
resolveRelative: 0,
719
738
pendingQueueLength: 1
720
739
});
740
+
741
+
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
742
});
722
743
723
744
test('if a module has no default property assume its export is default (object)',function(){
@@ -743,9 +769,16 @@ test('if a module has no default property assume its export is default (object)'
743
769
resolveRelative: 0,
744
770
pendingQueueLength: 1
745
771
});
772
+
773
+
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
774
});
747
775
748
776
test('does not add default if export is frozen',function(){
0 commit comments