-
Notifications
You must be signed in to change notification settings - Fork 12
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
Convert addon to use template tag #84
Conversation
🦋 Changeset detectedLatest commit: 67a5169 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Preview URLsEnv: preview |
I just published 0.2.0 of the rollup plugin. I don't expect anything you've reported to be fixed, but i'll check this branch and see what's going on |
YES!!!!! 🎉 |
Glint / gts related type issues fixed here: #90 and there are more work-arounds than I'm comfortable with in the types / imports -- I'll work towards fixing those |
The other reported issue has a fix PR here: emberjs/babel-plugin-ember-template-compilation#16 (though, I don't have sufficient context and that could throw a wrench in things 😅 ) |
Yeah, that's why I raised the issue first, without even trying to look into what needs to be fixed, as it seemed intentional for some reason. We'll see... |
dea25b0
to
18724cf
Compare
18724cf
to
4ceb555
Compare
Linting is fixed. But Embroider is broken, due to embroider-build/embroider#1382 |
016566b
to
f1d8baa
Compare
This is fixed now with embroider-build/embroider#1383. Therefore using a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 This is awesome!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love seeing these components in a single file! This is great.
// this is copy pasted from https://github.com/emberjs/ember.js/blob/60d2e0cddb353aea0d6e36a72fda971010d92355/packages/%40ember/-internals/glimmer/lib/helpers/unique-id.ts | ||
// Unfortunately due to https://github.com/emberjs/ember.js/issues/20165 we cannot use the built-in version in template tags |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! This is good to know. Thanks for the helpful comment here
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- workaround for unknown modifier helper: https://github.com/typed-ember/glint/issues/410 | ||
declare const modifier: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a PR is up! typed-ember/glint#553 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I saw that also. And it was merged some hours ago! 🎉
import type TemplateRegistry from '@glint/environment-ember-loose/registry'; | ||
|
||
// importing this directly from the published types (https://github.com/embroider-build/embroider/blob/main/packages/util/index.d.ts) does not work, | ||
// see point 3 in Dan's comment here: https://github.com/typed-ember/glint/issues/518#issuecomment-1400306133 | ||
declare class EnsureSafeComponentHelper< | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
C extends string | ComponentLike<any> | ||
> extends Helper<{ | ||
Args: { | ||
Positional: [component: C]; | ||
}; | ||
Return: C extends keyof TemplateRegistry | ||
? TemplateRegistry[C] | ||
: C extends string | ||
? ComponentLike<unknown> | ||
: C; | ||
}> {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of this cleanup is excellent 🎉
Hey @camskene @joelamb @danwenzel, pulled you into this PR on a repo you might not have seen before, as Nicole (who together with Tony usually reviewed the stuff here) is out this week and I still need one more approval to be able to merge this! 😅. Would be nice if one of you could have a look, thanks! |
<template> | ||
<input | ||
name={{@name}} | ||
type="checkbox" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised to see double quotes here, as we're now (sort of) in JS, and they were single quotes in the hbs... 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, didn't realise this before. Probably our prettier config is a bit inconsistent. I did wonder why we have single quotes in hbs before (which in other projects were usually double quotes)...
@@ -1,5 +1,6 @@ | |||
import Component from '@glimmer/component'; | |||
import { assert } from '@ember/debug'; | |||
import { on } from '@ember/modifier'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yay explicit imports! 🎉
export interface HeadlessFormControlRadioGroupComponentSignature { | ||
Element: HTMLDivElement; | ||
Args: { | ||
// the following are private arguments curried by the component helper, so users will never have to use those |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, I like this comment and the @internal
syntax. I ran into this with a component recently and was wondering if there was good messaging like this
{{yield | ||
(hash | ||
Option=(component | ||
HeadlessFormControlSelectOptionComponent selected=@value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't need ensure-safe-component
anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope! 🎉
With strict mode templates, the {{component}}
helper is also more strict, not allowing a string based lookup anymore. This makes sense as you would have explicit imports anyway. And by that, Embroider can safely assume that whatever is passed to {{component myComponent}}
as the first argument is already something that has been imported somewhere (and as such it is already "seen" by Embroider/webpack and added to the bundle), so it does not need to care about this being potentially unsafe anymore. I also learned about this more recently...
This converts all components of the addon itself (we only had this for the test-app before) to use template tags (gts).