Repository navigation
Open
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: compilerIssues related to `ngc`, Angular's template compilerbugcross-cutting: standaloneIssues related to the NgModule-less worldstate: has PR
Milestone
Description
Which @angular/* package(s) are the source of the bug?
Don't known / other
Is this a regression?
No
Description
I have a library that export multiple component in a const as advised in the standalone guide:
const LU_SIMPLE_SELECT_COMPONENTS = [
LuSimpleSelectInputComponent,
LuOptionDirective,
LuDisplayerDirective,
LuOptionComponent,
] as const;Whenever I import this constant from a module or in a component in an application that use my library, I have the following issue:
Value at position 0 in the NgModule.imports of AppModule is not a reference
Value could not be determined statically.
If I redefined the same const in the application, it works.
Links
- The library part
- A Stackblitz that reproduce the issue (uncomment line 24 and comment line 23 to make it works)
Please provide a link to a minimal reproduction of the bug
Please provide the exception or error you saw
> Value at position 0 in the NgModule.imports of AppModule is not a reference
> Value could not be determined statically.
Please provide the environment you discovered this bug in (run ng version)
Angular CLI: 14.1.3
Node: 16.14.2
Package Manager: npm 8.5.0
OS: win32 x64
Angular: 14.1.3
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1401.3
@angular-devkit/build-angular 14.1.3
@angular-devkit/core 14.1.3
@angular-devkit/schematics 14.1.3
@angular/cdk 14.2.7
@schematics/angular 14.1.3
rxjs 7.5.7
typescript 4.7.4
Anything else?
Love Standalone components!
Reacted by Ronnie Henriksen Laugen, Tomas Rimkus, Nivek, Andrew Allen, Dmitry A. Efimenko, Tomas Trajan, tictak21, Swami Sanapathi, mkraus-mapp, Enrique Diaz and 7 more
Metadata
Metadata
Assignees
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: compilerIssues related to `ngc`, Angular's template compilerbugcross-cutting: standaloneIssues related to the NgModule-less worldstate: has PR
Activity
fix(compiler-cli): evaluate const tuple types statically
montella1507 commentedon Nov 17, 2022
I have another problem with exported array of standalone components and directives...
When i import to the module one by one:
imports: [DirectiveA., DirectiveB, DirectiveC]both server and prod build works.
However, when i import exported directives array:
SERVER works, but prod builds is broken - somehow it brakes imports at all.. and it cannot even find things from other imported modules.
Unfortunately.. i am not able to simulate it minimal repo :-/
Any idea what to try? What may be the cause?
Directives are in Buildable library in NX Monorepo
Probably this may be the issue:
ng-packagr/ng-packagr#2398
fix(compiler-cli): evaluate const tuple types statically (#48091)
22 remaining items
iamenrique commentedon Mar 30, 2024
No official workaround for this problem yet and docs are still the same in v17.3.2.
I'm also porting libraries to the standalone approach, and I'm doing the following to chill out these errors:
Perhaps not ideal but worth the try.
richardsengers commentedon Sep 28, 2024
It looks like this is now working. I'm not sure when it started working. The latest update of intellij Webstorm gave me a recommendation to import the const, so i thought why not give it a try!
I can now import const's from shared libraries without any problems.
Angular CLI: 18.2.3
Node: 22.3.0
Package Manager: yarn 1.22.17
OS: win32 x64
Angular: 18.2.3
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, language-service, material, material-date-fns-adapter
... platform-browser, platform-browser-dynamic, platform-server
... router, service-worker
Package Version
@angular-devkit/architect 0.1802.3 (cli-only)
@angular-devkit/build-angular 18.2.3
@angular-devkit/core 18.2.3
@angular-devkit/schematics 18.2.3
@schematics/angular 18.2.3
rxjs 7.8.1
hakimio commentedon Sep 28, 2024
Import in standalone components or NgModules?
richardsengers commentedon Sep 28, 2024
Import in standalonme components.
i'm not using NgModules anymore
richardsengers commentedon Sep 28, 2024
Hmmm ok, re-reading this topic, apparently the issue is only for NgModules, by the time it was a problem for me, I was probably still on ngModules (argh) ... I've since then converted every app to standalone, that's probably why I can import the const now.
hakimio commentedon Sep 28, 2024
It was never a problem for standalone components.
mauriziocescon commentedon Jan 15, 2025
Hey!
Just tested it with v19: as far as I can see, the problems is still present. Here is our case:
I wonder: as of right now, better to stick with modules and that's it?
Thanks!
hakimio commentedon Jan 15, 2025
@mauriziocescon that looks like a bug in your application unrelated to this issue.
Are the components in your
CC_CARDexported properly?Specifically you should find out why the error says
Value is of type '[(not statically analyzable).mauriziocescon commentedon Jan 21, 2025
Hey!
Sorry for the late reply: busy week! Indeed: local problem (too long to explain). I've made a round of tests and it seems to me it's working fine in both scenarios:
Cheers!
hakimio commentedon Jan 21, 2025
It should work in
NgModulesthe same as it works in standalone components - without any spreads. That's the bug discussed here.