-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
Angular Standalone library barrel files #49888
Comments
The compiler needs to know which components are available, which in the case of libraries requires that this is known by looking at the To make this work, the array must be declared as a tuple type using an This is documented on angular.io in the standalone components guide. |
Thx @JoostK this works! Sorry for the issue. I missed this in the docs. |
Hi, @JoostK I have a small update. This morning I updated my library exports with the
|
@pkozlowski-opensource thanks for the info, it would be very appreciated as that is something which really makes or breaks shipping component libs as pure standalone while preserving reasonable DX. |
@pkozlowski-opensource Yes, exactly. Thx, a lot for the info and the PR. Looking forward to the fix. 💪 |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Which @angular/* package(s) are the source of the bug?
compiler
Is this a regression?
Yes
Description
When trying to migrate a module-based UI component library to standalone components, we want to support the following use case:
We have many modules that export multiple components. All those components must be imported into the consumer application for a UI feature to work. Let' say we have a
TabModule
. TheTabModule
looks something like this:library
In module land, a consumer of our library can simply import the
TabModule
and the Tab feature works. In standalone land the consumer has to import theTabGroupComponent
and theTabComponent
.consumer
This works great, but for better developer experience, we would additionally want to offer the possibility to import all components at once. Therefore we can create a
index.ts
file where we export an array that contains theTabGroupComponent
as well as theTabComponent
.library - index.ts
With this approach, the consumer could then simply import the
TabComponents
.consumer
This works great in a multi-project workspace where we built our SPA from the library sources. But once we build our library for prod, package it and publish it on npm this approach no longer works.
We get the following compile error:
consumer
We also had the case where we did not get this error but the build still failed because it was telling us that neither the
TabGroupComponent
nor theTabComponent
were provided.We also tried to import the
TabGroupComponent
and theTabComponent
individually and locally create an array with them.consumer
this one worked without errors.
We then also compared the array here with the array from our library by logging them in the constructor - and they are identical. Both are arrays containing the
TabGroupComponent
and theTabComponent
. Therefore we believe it is a bug in the compiler.Thx, a lot for your feedback and the great efforts to enable standalone components in Angular.
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
No response
The text was updated successfully, but these errors were encountered: