Skip to content

Fix Nested V2 Addons - #1327

Merged
ef4 merged 2 commits into
embroider-build:mainfrom
gossi:fix-nested-v2-addons
Mar 7, 2023
Merged

Fix Nested V2 Addons#1327
ef4 merged 2 commits into
embroider-build:mainfrom
gossi:fix-nested-v2-addons

Conversation

@gossi

@gossi gossi commented Jan 14, 2023

Copy link
Copy Markdown
Contributor

Fix #1325

please refer to linked issue for detailed explanation. I didn't add any tests though, there is no such scenario in the repo. Please let me know how a good test would fit within the existing suite.

if (autoImportInstance) {
autoImportInstance.registerV2Addon(name, root);
} else {
(this.parent as EAI2Instance).registerV2Addon(name, root);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we know it's safe to call this on the parent?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the biggest question mark I have, quote from the issue above:

Why I'm saying this is only a suggested fix: I'm not sure, if this piece of code is in the intention of the comment or if that means a different implementation (given I have basically no real knowledge about embroider).

which basically targets this line.

But following the analysis I put in the issue, there is either a autoImportInstance or this.parent with registerV2Addon available.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially, you can safeguard this. But I'd say, it would be better to throw an error over silently do nothing and not registering the addon at all, without a dev knowing about it ?!?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's safe once refactored inside the if (this.parent.pkg['ember-addon']?.version ?? 1) < 2) check.

@gossi

gossi commented Feb 5, 2023

Copy link
Copy Markdown
Contributor Author

@ef4 is this ready to move forward? It is improving and at the same time doesn't make it worse?

@ef4

ef4 commented Mar 6, 2023

Copy link
Copy Markdown
Contributor

The test coverage for this is in ember-auto-import, not embroider, because all of this registering v2 addons with ember-auto-import stuff is inert under embroider, it only matters for non-embroider apps where ember-auto-import is doing the work.

Opened embroider-build/ember-auto-import#571 to cover this.

@ef4

ef4 commented Mar 7, 2023

Copy link
Copy Markdown
Contributor

Thanks @gossi

@ef4
ef4 merged commit 8b65699 into embroider-build:main Mar 7, 2023
@wagenet

wagenet commented Mar 27, 2023

Copy link
Copy Markdown

Has this made it into a release yet?

@NullVoxPopuli

Copy link
Copy Markdown
Collaborator

yes, https://www.npmjs.com/package/@embroider/addon-shim/v/1.8.4-unstable.00ec2e7

main is released to the @unstable tag every merge.
Note, however, that unstable has no support (hence the name), and is meant as a means of testing

@njradford

Copy link
Copy Markdown

Also encountering this issue fwiw

This was referenced May 2, 2023
@ef4 ef4 added the bug Something isn't working label May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot read properties of undefined (reading 'registerV2Addon')

5 participants