Skip to content
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

Add rollup declarations plugin #2200

Merged
merged 1 commit into from
Dec 16, 2024
Merged

Add rollup declarations plugin #2200

merged 1 commit into from
Dec 16, 2024

Conversation

simonihmig
Copy link
Collaborator

@simonihmig simonihmig commented Dec 9, 2024

This invokes glint as a rollup plugin, and contains a workaround for broken gts imports, see typed-ember/glint#628.

This is an attempt to fix this long standing issue, which Glint v2 seems to fix. But we want this to work now, so v2 addons have a blessed way to support gts files. It's influenced by previous attempts (embroider-build/addon-blueprint#255, embroider-build/addon-blueprint#292), but takes a slightly different approach:

  • packages the plugin in @embroider/addon-dev so people don't have inlined plugin code in their rollup config
  • https://github.com/NullVoxPopuli/fix-bad-declaration-output uses jscodeshift to rewrite broken imports (strip the .gts extension), but I was hesitant to bring in that large dependency for that simple task. Rewriting import paths using a simple regex seems safe enough to me, especially since this is operating only on Glint-emitted code (no custom formatting expected)
  • optimizes the concurrency of running the glint executable

The long-term idea is that once Glint v2 is out, we can use that for the plugin, removing the workaround and ideally invoking programmatic Glint APIs instead of spawning it as a new process. But all of that without causing much churn for users, as they should be able to keep their rollup config unchanged.

Here is how this would be eventually adopted in the blueprint: embroider-build/addon-blueprint#315

@NullVoxPopuli
Copy link
Collaborator

https://github.com/NullVoxPopuli/fix-bad-declaration-output

There is also the fix for /// <reference stuff, which TS has said they won't fix, because they don't support what we're doing, where we want peer-provided types (using the consumer's deps). 😢

@simonihmig
Copy link
Collaborator Author

simonihmig commented Dec 9, 2024

I haven't really looked deeply into that issue, just picked up here that this issue is not anymore. Did I get this wrong?

And btw, fully broken CI here is unrelated, stable itself is broken. Trying to get this fixed in #2201

@NullVoxPopuli
Copy link
Collaborator

this issue is not anymore.

it's been a while for me, but I remember TS 5.5 did not fix the issue, though i did not try setting explicitly preserve: false -- I could also be misremembering at this point, so it's probably good to re-evaluate -- based on this emberobserver search: https://emberobserver.com/code-search?codeQuery=fix-bad-declaration-output, it's possible I'm out of date! haha

@ef4
Copy link
Contributor

ef4 commented Dec 10, 2024

We discussed at tooling team, this seems worth landing.

This invokes glint as a rollup plugin, and contains a workaround for broken gts imports, see typed-ember/glint#628
@simonihmig simonihmig marked this pull request as ready for review December 11, 2024 18:33
@simonihmig simonihmig requested a review from a team December 11, 2024 18:33
@simonihmig
Copy link
Collaborator Author

Green now and ready for review!

@SergeAstapov SergeAstapov added the enhancement New feature or request label Dec 11, 2024
@simonihmig simonihmig merged commit 96d33a3 into stable Dec 16, 2024
229 checks passed
@simonihmig simonihmig deleted the si-dts-plugin branch December 16, 2024 14:57
@github-actions github-actions bot mentioned this pull request Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants