-
Notifications
You must be signed in to change notification settings - Fork 117
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
Make paraglide files available via Virtual module #3247
Conversation
🦋 Changeset detectedLatest commit: 2a81c4e The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 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 |
@manuel3108 @benmccann, where should the d.ts files go? Using the |
My suggestion would be to make it so that |
This would be the ideal solution. I'm wondering why this would even be necessary, as the current integration seems to able to just work without such file. At least I was unable to find any |
Not sure if I understand. The d.ts file is dynamically created based on the messages? If the d.ts file is static, there would be no typesafety for messages. Could you clarify how typesafety can be achieved without a dynamic .d.ts file?
Because Paraglide compiles JS with JSDoc which TypeScript can handle. Virtual modules now take away the JSDoc definitions so TypeScript needs dedicated d.ts files. In other words, using virtual modules opens up complexity that Paraglide JS did not have before. It just compiled JS files with JSDoc. Works everywhere if the TS setting is set to |
One of the main reasons to use paraglide is the typesafe messages. We can't provide those unless there are dynamically generated type-definitions somewhere. A I suggest that we place a |
Hmm, yeah, I guess there's not much option except to generate the Another solution I just thought of would be to instead generate a package in |
Doesn't work. HMR and everything breaks. We tried that route before. Things become simple once one accepts that Paraglide messages "are source code". Just like generating code from an OpenAPI spec or GraphQL schema. But, I understand that it goes against intuitions (initially).
@LorisSigrist Yes, let's emit the d.ts file in the outdir and see how users react. Could you make the config experimental e.g. |
Looks like you might be able to add a workaround in the Vite plugin to make that work: vitejs/vite#8619 (comment) |
@LorisSigrist is a blocker remaining? Lmk when it's ready to review |
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, so you want the virtual files to still be importable via the regular file-path, not just a virtual namespace @samuelstroschein? Should be doable, but we would probably need one |
@LorisSigrist I think that using the
Isn't it enough to adjust the |
Path imports can't be done via SvelteKit generates an entirely separate filetree in the |
Sounds good. And I think it is intuitive.
|
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.
Expanded the changelog and only emit the runtime.d.ts and messages.d.ts file.
Thank you loris!
/tip 350
🎉🎈 @LorisSigrist has been awarded $350! 🎈🎊 |
@LorisSigrist how was the process for you with the tipping and PR in general? |
Fixes opral/inlang-paraglide-js#264
This PR adds a
useVirtualModule
option toparaglide-unplugin
(and therefore all it's descendants). This makes a$paraglide
virtual module available instead of writing to disk. You can import it like so:Types are provided via a
.d.ts
file withdeclare module
declarations.Where should the
.d.ts
file be placed?In the
outdir
.Todos