-
Notifications
You must be signed in to change notification settings - Fork 1
Do the entirety of the <template>
transform in rollup.
#6
Conversation
🦋 Changeset detectedLatest commit: c5272ba The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
High level this seems reasonable to me. As you say, running through Babel's parse/serialize cycle an additional time will have a perf impact, but this definitely lowers the possibility of unexpected interactions with other Rollup plugins encountering the intermediate format. A couple thoughts/questions:
(Side note, not specific to this change: given "tagged templates" already being a general ECMAScript feature, especially in combination with the existence of rendering tests and GlimmerX-style |
This definitely feels like a win to me if this is the only con! It makes the configuration quite a bit easier to follow by now only having two steps. The tradeoff you're making here, although maybe adding an additional concern for the package, seems as though it'll make it easier on end users which is a huge benefit imo. This is super exciting! 🎉 |
it would if the output from the babel plugin is untyped. but there is the tradeoff there with type checking output as opposed to input feels somewhat rude to consumers (esp if types are missing, or break due to any variety of reasons).
unchanged, rollup-plugin-ts still outputs declarations
@ef4 did some exploration here, and it required forking babel's parser due to partially implemented parser-plugin support within babel -- creating a
Thanks! There is still more work todo, like I found that my TS tests were not sufficient, because I wasn't actually using TS syntax -- easily resolved, but proves this rollup plugin is def still pre 1.0.
yeah --- classic naming struggles 😅 -- I originally thought |
I'm not sure I understand this answer. Are you saying
There's a reason I paired this question with the previous one. If your assertion is that typechecking the output of this plugin will produce bad results, then doesn't that mean the generated declarations could have issues (e.g. dropping in |
should not, but this is a personal preference. The work in this PR ideally 🤞 fixes the issue called out in the README where
not everyone has that level of intentionality. 🙃
It does. But those issues should be caught by
unsure about specifics, I'll double check once some more progress is made. |
…ustom syntax. Then use transformFromAst to only apply the template-imports babel-plugin
…lugin is easier to read
Looks like I was wrong about:
Because I got this error with
|
So when there is a type error, For example, I commented the import of the // dist/components/ts-class-demo.d.ts
import Component from '@glimmer/component';
declare class TsClassDemo extends Component {
router: RouterService;
greeting: string;
}
export { TsClassDemo as default }; So this is ideal, I believe as errors are not hidden. For an added bonus, when there are no type errors, we get declaration maps! import Component from '@glimmer/component';
import RouterService from '@ember/routing/router-service';
declare class TsClassDemo extends Component {
router: RouterService;
greeting: string;
}
export { TsClassDemo as default };
//# sourceMappingURL=components/ts-class-demo.d.ts.map |
While there is a performance hit to doing more work, I think this is acceptable:
🎉 |
Is publishing declarations with a type error in them, instead of flagging the error during publish, ideal? Edit: I'm realizing I may have misinterpreted what you meant by "downstream." Does that mean "downstream by Hopefully in the general case type errors are caught by other tooling, like
It seems like we should probably have declarations for If we had code that produced |
gotchya! I consider downstream the consuming application (like in a monorepo is where they'd catch this pre-publish, yet during development) -- upstream (to me), would be rollup-plugin-ts.
This is still a good question though -- I did not intend to imply this. I do agree that having some publish protection would be good. Maybe
yeah, I can PR that -- is it just a new folder + index.d.ts file at this location: https://github.com/emberjs/ember.js/tree/master/types/preview/%40ember (plus a type-test?)
I suppose only if folks had |
The resulting |
Thanks for explaining that! I'll get a PR up for the missing types so we can soon flip transpileOnly back to false / omit it. |
I think this would be a good mode for some use cases, like v2 addon authors. But I don't think it should be the only mode because this will be unacceptably expensive in large application, for two reasons. The first is the double babel parse which is discussed above. When we eliminated a second babel parse from ember-auto-import is saved tens of seconds from big apps. This would add that much cost back. The second is the double HBS parse. The HBS parse itself is a relatively expensive part of every build, and this strategy would need to do it twice. Once to build up the scope bag, and once to actually convert the template to wire format. |
Pending feedback, tho here are the tradeoffs to this approach:
Pros:
Less docs for us to maintain
Cons:
Tasks
<template>
code<template>
transform in rollup. #6 (comment)<template>
-compiled out is what is passed torollup-plugin-ts