-
-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(makeDefaultExport): add deprecation message for generated default
exports
#128
base: master
Are you sure you want to change the base?
feat(makeDefaultExport): add deprecation message for generated default
exports
#128
Conversation
f43ec01
to
14e8348
Compare
build.js
Outdated
var instrumented = transform(source, { | ||
plugins: ['transform-es2015-destructuring'] | ||
plugins: [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we extract the babel options to a shared variable?
index.js
Outdated
@@ -10,13 +10,23 @@ module.exports = { | |||
this.treePaths['vendor'] = 'dist'; | |||
}, | |||
|
|||
included: function() { | |||
included: function(app, parentAddon) { | |||
var isDevelopmentOrTest = app.env === 'development' || app.env === 'test'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we refactor this to the following?
var isProduction = process.env.EMBER_ENV === 'production';
index.js
Outdated
var target = parentAddon || app; | ||
|
||
target.options = target.options || {}; | ||
target.options.loader = target.options.loader || { debug: isDevelopmentOrTest }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should add a config for this if we don't need to...
index.js
Outdated
prepend: true | ||
}) | ||
}); | ||
} else if (target.options.loader.debug) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we tweak the above, this becomes } else if (!isProduction) {
lib/loader/loader.js
Outdated
'generated one anyway. This behavior is deprecated and will be removed in v5.0.0.'; | ||
}; | ||
|
||
Object.defineProperty(requirejs, 'deprecationLogger', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this? If it is just for the testing, can we tweak it to just mock console?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure what you're getting at, but I simplified things a bit and changed the arguments to support setting loader.deprecationLogger = Ember.deprecate
if we wanted. What do you think?
Sorry for the delay in reviewing @lennyburdette |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably note in the deprecation message that this behavior can be turned off via loader.makeDefaultExport
now.
…lt` 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
This change adds a `loader.debug` option to Ember CLI builds. It defaults to true for development and test builds. When true, it prepends loader.debug.js instead of loader.js to the application's vendor.js.
14e8348
to
fc83edb
Compare
@trentmwillis Good catch. I added instructions for disabling makeDefaultExport in the deprecation message. |
@rwjblue thanks for the review! |
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. We should removemakeDefaultExport
in version 5.0. This updatemakeDefaultExport
.Addresses #114