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
@@ -724,6 +733,11 @@ test('if factory returns a value it is used as export', function() {
724
733
});
725
734
726
735
test('if a module has no default property assume the return is the default',function(){
736
+
vardeprecationArguments;
737
+
loader.deprecationLogger=function(){
738
+
deprecationArguments=[].slice.call(arguments);
739
+
};
740
+
727
741
define('foo',[],function(){
728
742
return{
729
743
bar: 'bar'
@@ -748,10 +762,21 @@ test('if a module has no default property assume the return is the default', fun
748
762
});
749
763
750
764
equal(foo.bar,'bar');
765
+
766
+
deepEqual(deprecationArguments,[
767
+
'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. To opt out of this behavior, set `loader.makeDefaultExport = false`.',
768
+
false,
769
+
{id: 'loaderjs.makeDefaultExport',until: '5.0.0'}
770
+
]);
751
771
});
752
772
753
773
754
774
test('if a CJS style module has no default export assume module.exports is the default',function(){
@@ -776,10 +801,21 @@ test('if a CJS style module has no default export assume module.exports is the d
776
801
resolveRelative: 0,
777
802
pendingQueueLength: 1
778
803
});
804
+
805
+
deepEqual(deprecationArguments,[
806
+
'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. To opt out of this behavior, set `loader.makeDefaultExport = false`.',
807
+
false,
808
+
{id: 'loaderjs.makeDefaultExport',until: '5.0.0'}
809
+
]);
779
810
});
780
811
781
812
782
813
test('if a module has no default property assume its export is default (function)',function(){
@@ -802,9 +838,20 @@ test('if a module has no default property assume its export is default (function
802
838
resolveRelative: 0,
803
839
pendingQueueLength: 1
804
840
});
841
+
842
+
deepEqual(deprecationArguments,[
843
+
'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. To opt out of this behavior, set `loader.makeDefaultExport = false`.',
844
+
false,
845
+
{id: 'loaderjs.makeDefaultExport',until: '5.0.0'}
846
+
]);
805
847
});
806
848
807
849
test('if a module has no default property assume its export is default (object)',function(){
@@ -827,9 +874,20 @@ test('if a module has no default property assume its export is default (object)'
827
874
resolveRelative: 0,
828
875
pendingQueueLength: 1
829
876
});
877
+
878
+
deepEqual(deprecationArguments,[
879
+
'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. To opt out of this behavior, set `loader.makeDefaultExport = false`.',
880
+
false,
881
+
{id: 'loaderjs.makeDefaultExport',until: '5.0.0'}
882
+
]);
830
883
});
831
884
832
885
test('does not add default if export is frozen',function(){
0 commit comments