-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
feat: expose moduleRewrite and compileSFCStyle #104
Conversation
This doesn't add it to the main |
That's because currently because we use I will add to index |
src/node/server/index.ts
Outdated
@@ -13,6 +13,8 @@ import { assetPathPlugin } from './serverPluginAssets' | |||
import { esbuildPlugin } from './serverPluginEsbuild' | |||
|
|||
export { Resolver } | |||
export { rewriteImports } from './serverPluginModuleRewrite' | |||
export { compileSFCStyle } from './serverPluginVue' |
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 is this needed?
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 writing a plugin to do SSR based on a route, for that I need to parse the SFC file and build a script similar to what vite does. But vite relies on the middleware and the request path to retrieve the cached files or to parse a new file.
Being able to access the internals would be really useful.
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.
For consistency's sake, I think we either expose all compileSFC*
methods or we expose none of them. However, making them public means we can't treat them as internals and freely tweak arguments anymore. They are also assuming to be only used in the dev-server, so it may at some time expect a Koa context - which would make them unusable elsewhere. I think for now it's safer to just copy-paste the logic in your plugin until it's more stable.
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.
Agreed, in my case I only need the Style, the others I basically copied the logic over.
Is the rewriteImports
good to expose?
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, rewriteImports
is probably safe, although I'd consider it semi-internal for now. You should be prepared if it breaks ;)
This reverts commit 2984b92.
Exposing
moduleRewrite
andcompileSFCStyle
for plugin creators