Introducing the .ng format in Analog [CLOSED] #824
Replies: 20 comments 60 replies
-
Pretty sure I don't need to reiterate how much I like/want this - thank you Brandon and Chau for spearheading this! Just a couple of initial thoughts/nits:
I also wonder whether the doubled.ng We would stick with something like doubled.pipe.ts but instead of using decorators/classes it would be created entirely within the function, e.g: doubled.pipe.ts definePipe({
name: 'doubled',
transform: (value: number) => {
return value * 2
}
}) Of course, this is coming purely from the perspective of how I would ideally want this to work without considering how much this complicates the actual implementation |
Beta Was this translation helpful? Give feedback.
-
Just here to bikeshed that I'm pro |
Beta Was this translation helpful? Give feedback.
-
Just a quick flyby question...is specifying the script language truly needed? Is that a requirement for Vite or something else? |
Beta Was this translation helpful? Give feedback.
-
I love this! This is incredible work! This has me dreaming of supporting MDX rendering with something like this: <script>
import Hello from './hello.ng';
</script>
<markdown>
# Hello World
<Hello />
</markdown> Do you guys think this would be possible? |
Beta Was this translation helpful? Give feedback.
-
I love it, I'm pro and I would love to help on this if needed, one question do we need to have a .ng for directives and pipes as well? That looks a little odd but other than that this looks fantastic |
Beta Was this translation helpful? Give feedback.
-
What are the potential possibilities of making it a pre-processor so that standard Angular apps can make use of it as well? Have you identified any critical obstacles, other than lack of supporting features such as deferrable views, inputs, outputs etc? |
Beta Was this translation helpful? Give feedback.
-
Hello, it is going to be only available as SFC? |
Beta Was this translation helpful? Give feedback.
-
I thought I saw a notification about Generics Component. That is definitely something I had on my mind but I didn't have a concrete idea as to how to implement it. So I'm open-mind about it |
Beta Was this translation helpful? Give feedback.
-
I like it very much. For lifecycle hooks I think we would need some eslint support. You can accidentally make a mistake my writing |
Beta Was this translation helpful? Give feedback.
-
That looks promising! GG guys 👏 Here's a couple of questions:
|
Beta Was this translation helpful? Give feedback.
-
I'd like to be able to have multiple templates in one file. |
Beta Was this translation helpful? Give feedback.
-
Shouldn't |
Beta Was this translation helpful? Give feedback.
-
Not sure if I missed it, but I would to see variables/enums directly accessible in the template without creating an instance of them in the script section. <script lang="ts">
import {myVar, ColorEnum} from 'another-one.ng';
</script>
<template>
Variable is: {{myVar}}
Is variable blue: {{myVar === ColorEnum.BLUE}}
</template> |
Beta Was this translation helpful? Give feedback.
-
Wow! I unplug for a few weeks and you guys drop something this huge! This looks amazing and I am excited to see where your ideas lead. I'm curious about how feasible functional components become with the helper functions. For example, would the following be possible? const component1 = createComponent(withMetadata({imports: [ signalStore, myPipe]}), withTemplate(`<h1>{{myStore.value()}}</h1>`);
const component2 = createComponent(...); There is some "magic" I'm glossing over here, but I'm more curious if you think the idea is feasible given the research you have done with the compiler. I love this idea. I think it will make Angular more accessible. |
Beta Was this translation helpful? Give feedback.
-
I don't know if it's useful to you, but you can actually patch the Angular compiler to support custom transformers. |
Beta Was this translation helpful? Give feedback.
-
keep toying away with this and thinking about a few things:
|
Beta Was this translation helpful? Give feedback.
-
I remember seeing Brandon's politely worded tweet earlier about lack of functional components "pushing angular into niche markets". My initial reaction was: why change it if it isn't broken? But after seeing this implementation, even after sharing some initial concerns in a response to Joshua's tweet, I'm really warming up to this. Plus, we get to flex on the tech blogosphere which is always a good thing. I think it is a fantastic addition for angular devs who know what they are doing. But I have not gotten to the point of thinking it should be recommended to new developers. Having multiple, interchangeable, ways of doing a thing makes it harder to learn. All of the tutorials, examples, docs are in the original syntax, and I don't think it would be an enjoyable experience for a new dev who doesn't understand the workings and flow of the framework to have to try and write in this new syntax when all their online resources are written the other way. BUT if we can create really good documentation that include more substantive examples, I think we can alleviate that concern. I would be happy to help contribute to such documentation. I see myself using both authoring forms initially, old way for pages, new way for components on pages, or small components. Could switch wholly to the new format if it feels nice in practice.
This authoring syntax seems like a home run for Astro+Analog projects. I don't think I need to say more. |
Beta Was this translation helpful? Give feedback.
-
Can we skip defining the selector for components? It would still be needed for directives, but components are already being renamed with I would love to be able to skip the wrapper element à la React Fragments, but that might be beyond the scope here. Thoughts? |
Beta Was this translation helpful? Give feedback.
-
Currently the styles are added to the template in the meta. Should the styles be moved to the styles in the meta to support multiple <style> tags or is it only 1 thats allowed? |
Beta Was this translation helpful? Give feedback.
-
Proposal drop then .ng and rename it. This allows angular to use the file name in future without and clashes especially if this comes out of experimental for analog |
Beta Was this translation helpful? Give feedback.
-
This opens the discussion around #823. The goal is to get early feedback about the feature in its experimental phase.
This introduces experimental support for a
.ng
format for components, directives, and pipes. Initial work done by @nartc and @brandonroberts, with early discussions also contributed by @joshuamorony.Why
Notes
experimental-local
compilation mode.SSR is not currently supported.Inputs/Outputs are not currently supported.defineComponentMetadata
,defineDirectiveMetadata
, anddefinePipeMetadata
are used to define metadata for components, directives, and pipes.Revisions
2024/01/02
computed
defineComponentMetadata
,defineDirectiveMetadata
have been consolidated intodefineMetadata
. A component requires a<template>
where a directive does not.2024/01/03
exposes
property added to metadata for exposing globals, enums to the templateonDestroy
hook added to go along withonInit
2024/01/04
let
variables are supported by utilizing getters viaObject.defineProperties
2024/01/11
new EventEmitter()
directly2024/01/25
Concepts
Component
hello.ng
app.component.ng
Pipe (No longer included)
doubled.ng
Directive
highlight.ng
Lifecycle Hooks
An
onInit
lifecycle hook can be added for init logic.An
onDestroy
lifecycle hook can be added for teardown logic.Alternatively,
DestroyRef
can also be used for teardown logic instead:Sample App
https://github.com/brandonroberts/analog-ng
Beta Was this translation helpful? Give feedback.
All reactions