-
-
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
Avoid conflicting transforms for @ember/debug. #161
Conversation
When both babel-plugin-debug-macros and babel-plugin-ember-modules-api-polyfill attempt to replace `import { assert } from '@ember/assert';` the interaction between the two also removes any helpers that are injected by other parts of the transpilation (e.g. `_classCallCheck` or `_asyncToGenerator`) therefore making the transpiled output fail at runtime. This updates babel-plugin-ember-modules-api-polyfill to a version that allows specifying a blacklist so that we can avoid this conflict.
index.js
Outdated
@@ -260,7 +260,7 @@ module.exports = { | |||
if (this._emberVersionRequiresModulesAPIPolyfill()) { | |||
const ModulesAPIPolyfill = require('babel-plugin-ember-modules-api-polyfill'); | |||
|
|||
return [[ModulesAPIPolyfill]]; | |||
return [[ModulesAPIPolyfill, { blacklist: ['@ember/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.
are https://github.com/ember-cli/ember-rfc176-data/blob/master/globals.json#L74-L80 all supported in the other Babel plugin?
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 all of those are required (e.g. this blacklist doesn't prevent @ember/debug/data-adapter
or @ember/debug/container-debug-adapter
). The only one that is not supported by babel-plugin-debug-macros is Ember.inspect
(which seems misplaced in @ember/debug
IMHO).
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.
so import { inspect } from '@ember/debug';
won't work at all after this PR?
Updated to properly allow named exports from @Turbo87 - Ready for another look... |
oh babel... |
It looks like
From what I understand I shouldn't see an |
I think we might have to change the order of: this._getDebugMacroPlugins(config),
this._getEmberModulesAPIPolyfill(config), Update: I just tried that with a clean cache, but it didn't seem to make a difference |
Ordering is totally screwed up. Changing the order actually has no effect due to the way babel merges all plugins into a single AST visitor. |
@Turbo87 - Can you share the raw source of the imports for that snippet? Can you also confirm if the thing imported from |
@Turbo87 - OK, fixed that last issue I believe. Can you give it a try again? For more info on what was wrong, you can see the writeup in ember-cli/babel-plugin-debug-macros#45. |
@rwjblue sorry to disappoint you... 😞 it now correctly transpiled the debug macros things, but it no longer converts the module imports at all 🤔
|
40971cb
to
4f9a45e
Compare
@Turbo87 - I added a few more tests/assertions around non- |
looks like clearing my caches resolved the issue. this seems good to go 👍 |
(pardon my rudimentary understanding) but with this change if I try an import like If it's helpful I can open a new issue and try to make a reproduction, but perhaps there is something I'm not understanding about the intent of this PR? |
@Dhaulagiri - We have two plugins that both know how to operate on |
Checkout this test for example output (and confirmation that we are indeed processing these). |
When both babel-plugin-debug-macros and babel-plugin-ember-modules-api-polyfill attempt to replace
import { assert } from '@ember/assert';
the interaction between the two also removes any helpers that are injected by other parts of the transpilation (e.g._classCallCheck
or_asyncToGenerator
) therefore making the transpiled output fail at runtime.This updates babel-plugin-ember-modules-api-polyfill to a version that allows specifying a blacklist so that we can avoid this conflict.
Fixes #160