-
Notifications
You must be signed in to change notification settings - Fork 137
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
[vite] use transform instead of load for gjs & hbs files #1680
Conversation
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 think overall this is a good PR, it also potentially allows us to tap into some caching of modules because of the caching behaviour of rollup
If the Rollup cache is used (e.g. in watch mode or explicitly via the JavaScript API), Rollup will skip the transform hook of a module if after the load hook, the loaded code is identical to the code of the cached copy.
However I'm not too comfortable expanding the gjs filter to gts because I can imagine it would have a whole list of unintended consequences down the line 🙈 I'm sure it's probably fine but I would prefer that to be in a different PR if that's ok?
packages/vite/src/template-tag.ts
Outdated
import { Preprocessor } from 'content-tag'; | ||
|
||
const gjsFilter = createFilter('**/*.gjs?(\\?)*'); | ||
const gjsFilter = createFilter('**/*.{gjs,gts}?(\\?)*'); |
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 not comfortable adding gts to this for now. I know we should deal with the Typescript situation but I feel like that should be a wholistic PR that explicitly adds support rather than changing this one place
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.
What is 'the typescript situation'?
For running ts code, babel (or whatever) removes the type annotations and that's it
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.
yes but my understanding is that at this level we should always only be seeing gjs files no? and by "situation" I mean fully end-to-end tests on it with typechecking, that should be a different PR in my opinion
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.
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.
Why wouldn't we see the input file ext, if gjs is here already?
If it were compiled, we'd just have js, yeah?
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.
Potentially could also work with webpack if content-tag is added as a loader. Or is there already one?
Why would it work with gjs but not gts?
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.
Also, .ts is already part of the entry points and vite can load it directly. E.g the vite-app is not setup to transform ts files for the previous stage.
But sure, i can move this gts part elsewhere.
Shall i add it to #1679 ?
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.
Why wouldn't we see the input file ext, if gjs is here already?
If it were compiled, we'd just have js, yeah?
True, somehow i was thinking gts transforms to gjs first... But it would be js directly, right?
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.
Right, there is no gts to gjs conversion.
I think it goes: gts->ts->js
For content-tag -> babel/whatever
@mansona i reverted the gts part |
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.
great work 🎉
use transform function, this simplifies loading of those files without the need to handle paths