-
Notifications
You must be signed in to change notification settings - Fork 136
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
Multiple versions of @embroider/macros
may conflict at runtime in classic builds
#592
Comments
FWIW, I am fairly sure that this is not an issue in Embroider builds since we'd fall into this branch: embroider/packages/macros/src/babel/state.ts Lines 48 to 51 in 45f2a7c
And the import path would be relative to the "includer" (and therefore duplicate as needed). |
In embroider builds, even that wouldn't come up, because there's only ever one version of |
Gotcha, perfect. So this definitely will only affect ember-cli build pipeline. I do think it needs to be resolved before broadly suggesting addons migrate to |
I did that though, and yes, there were some rough edges. Loosely related: #509 (and still not quite resolved as apps using |
I agree that we could solve this by versioning the runtime as @rwjblue describes. But I also think we could solve this the way ember-auto-import does, by choosing one copy to rule them all and letting it do all the real work, in both babel and runtime. And the reason I'd favor that strategy if practical is that it's closer to how the macros work under embroider. |
So having reviewed the code and thought about it, I think going with runtime versioning is fine. Because of the constraints of running in the classic mode, it's actually better to let each copy of macros do its own babel on its own consumers. |
As far as I can tell, we haven't yet shipped any incompatible releases. The first release that had the runtime code in I can add documentation to the runtime module to warn against that eventuality, but I don't think any actual code changes are needed right now. |
@ef4 - I'm not sure you're talking about the same thing, but @rwjblue opened this issue exactly because there was a case with conflicting versions. Just wanted to mention that if you haven't seen it. |
Those versions don’t actually conflict, because only one of them contains addon/runtime.js. It looks like ember-cli-addon-guard will complain even if we use @rwjblue’s suggested solution here. It doesn’t know whether an addon is being careful to tolerate multiple versions. |
@ef4, @rwjblue - I hit this issue yet again with
And that's even when I'm using my own branch of What am I to do with all this? If every single addon uses their own version of |
Addon guard is wrong, there is no problem with your setup. There is no correctness problem (because all versions of macros have compatible runtimes), and there is no wasted bytes problems (because ember-cli will collapse the runtimes together into a single copy).
First, in the app it scales just fine for the reasons above. Second, addons having a dependency on |
We should update ember-cli-addon-guard to make it aware that this package is safe, but you can add |
Ah, OK, thank you both, I didn't know the @rwjblue - if you open an issue or something in |
I ran into an issue with
the versions that yarn installed were 0.29.0 (via ember-classic-decorator v2.0.1), 0.33.0 (ember-auto-import v1.10.1), and 0.41.0 (ember-basic-dropdown via ember-power-select v4.1.6) pinning |
@tehhowch I don't think that's the same as the above issue, please file a new one if you have a reproducible problem. |
Yes, that looks like this bug. |
I saw the same error mentioned here today (with a different placeholder) when attempting to upgrade |
When multiple versions of
@embrodier/macros
co-exist at runtime (in non-Embroider builds) the@embroider/macros/runtime
module will not be guaranteed to be the one that the babel plugin (which injects the import statement) expects. Specifically, this is because the ember-cli build pipeline merges multiple versions of addons down in such a way that it is quite confusing to reason about which one "wins", but it is very likely to be the "wrong one" for at least one consumer.Specifically, if this code runs:
embroider/packages/macros/src/babel/macros-babel-plugin.ts
Lines 222 to 233 in 45f2a7c
It will always default to
@embroider/macros/runtime
:embroider/packages/macros/src/babel/state.ts
Lines 53 to 55 in 45f2a7c
Which is absolutely not guaranteed to have matching implementations between the babel plugin that emits the import and the actual runtime function that will be found and ran.
My suggestion: update
pathToRuntime
and thepackages/macros/src/ember-addon-main.ts
to "scope" theaddon
folder contents under a versioned path (e.g.@embroider/macros/1/runtime
) such that the import that is injected is guaranteed to match implementations between babel plugin side of things and the runtime side. I don't anticipate that the version would explicitly match thepackage.json
version (I'd bet most of the time we release a new version of@embroider/macros
we don't break the contract between babel plugins and runtime macros) but having a revision to bump when the coupling between the two sides (build time + runtime) will ensure that the two versions of@embroider/macros
can co-exist together.The text was updated successfully, but these errors were encountered: