-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
Fix issue with app.import being undefined #89
Conversation
@stefanpenner @Turbo87 would love to get this reviewed/merged as soon as possible as I suspect it will be breaking a bunch of apps with my latest changes to |
@@ -31,7 +31,9 @@ module.exports = { | |||
}, | |||
|
|||
importPolyfill: function(app) { | |||
app.import('vendor/browser-polyfill.js', { prepend: true }); |
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.
This should use this.import
when present. That would enable this to work properly for nested addons (like ember-prop-types), whereas the guard simply makes it do nothing when used as a nested addon.
Something like:
if (this.import) { // support for ember-cli >= 2.7
this.import('vendor/browser-polyfill.js', { prepend: true });
} else { // support ember-cli < 2.7
app.import('vendor/browser-polyfill.js', { prepend: true });
}
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.
Thanks for the clarification, I've applied your recommendation.
@sandersky - Can you confirm this fixes the issues you have identified upstream? |
@rwjblue it looks like I'm still hitting a case where importPolyfill: function(app) {
if (this.import) { // support for ember-cli >= 2.7
this.import('vendor/browser-polyfill.js', { prepend: true });
} else { // support ember-cli < 2.7
console.info(Object.keys(app))
app.import('vendor/browser-polyfill.js', { prepend: true });
}
}, which provided the following: [
'parent',
'project',
'ui',
'addonPackages',
'addons',
'addonDiscovery',
'addonsFactory',
'registry',
'_didRequiredBuildPackages',
'nodeModulesPath',
'treePaths',
'treeForMethods',
'_addonsInitialized',
'options'
] So it appears the |
The following seems to fix it though: importPolyfill: function(app) {
if (this.import) { // support for ember-cli >= 2.7
this.import('vendor/browser-polyfill.js', { prepend: true });
} else { // support ember-cli < 2.7
while (app.app) {
app = app.app
}
if (app.import) {
app.import('vendor/browser-polyfill.js', { prepend: true });
}
}
}, Note: I hit another case where the |
@sandersky - What version of ember-cli are you testing with? For ember-cli >= 2.7.0 |
@rwjblue I'm using |
I do not think we should add the "walk up" strategy all over the place. We fixed this issue in 2.7 with |
@rwjblue so are you suggesting something along the lines of: importPolyfill: function(app) {
if (this.import) { // support for ember-cli >= 2.7
this.import('vendor/browser-polyfill.js', { prepend: true });
} else if (app.import) { // support ember-cli < 2.7
app.import('vendor/browser-polyfill.js', { prepend: true });
} else {
console.warn('Please add includePolyfill to your ember-cli-babel config')
}
}, My only concern is you get the warning even after you've added the |
Perhaps we could suggest they install https://github.com/ember-cli/ember-cli-import-polyfill into the app instead? That would prevent the warning on subsequent runs... |
@rwjblue I like that idea. I just verified it works as desired and committed the changes. If there are no more concerns I'm 100% satisfied with the latest approach. Thanks for the feedback/advice. |
This looks good to me. Thanks for working through the various edge cases with me. @Turbo87 / @stefanpenner - One of y'all will have to do the honors of merging + releasing as I don't have GH permissions here yet. |
I believe that you have recalled it backwards. ember-cli/ember-cli-import-polyfill#1 (comment)
|
riiiiight.... 🙊 |
@sandersky thanks for working through this! |
published as v5.1.10 |
Thanks for getting this merged so quickly @Turbo87 it appears to address the issues I was having. |
Allow plugins to bust the cache.
This fixes the following error I'm coming across in an application that consumers the addon ember-prop-types which enables the includePolyfill flag here.