Repository navigation
RFC: Improving support for auto-imports in an Analog SFC #901
brandonroberts
announced in
Announcements
Replies: 4 comments 1 reply
|
It looks like we can use any key in the interface ImportAttributes {
[key: string]: string;
}If we go with import attributes I propose using it more broadly to replace some aspects of The Example: <script lang="ts">
import DefaultFromLib from '@external/lib' with { meta: 'imports' };
import { FormsModule } from '@angular/forms' with { meta: 'imports' };
import { StateService } from './data-access/state.service' with { meta: 'providers' }
import { myFunc } from './somewhere' with { meta: 'exposes' }
</script> |
0 replies
|
happy with import attributes |
0 replies
|
Import attributes for the win |
0 replies
|
Sorry for asking, maybe a noob question but just wanted to ask, how would import attributes solve this problem? |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
For an Analog SFC, we support auto-adding of
.analogfiles to theimportsarray of the underlying component.We do this by identifying the filename of the originating analog file. This works well for importing single files. It does not work for analog files imported from libraries or barrel files
To resolve this issue we are looking at using import attributes:
Import Attributes (Stage 3 proposal, available in TypeScript 5.3)
Import attributes are supported in TypeScript 5.3+ and allow us to use an existing standard for imports that declares them available for the template
One caveat is that non-template imports could not be included in the same import block
Alternatives
Import analysis with ts-morph
Currently, we are loading analog SFCs in ts-morph to compile them into TypeScript source. We could use some analysis based on Import Declarations but this approach is prone to errors and performance implications.
Template Imports
Another alternative would be to declare the imports inside the template block that are made available to the template
or
This has a pitfall of making it hard to parse with IDEs already supporting Angular and Analog component authoring and syntax highlighting, including an upcoming release of WebStorm.
All reactions