-
-
Notifications
You must be signed in to change notification settings - Fork 378
fix(element-plus): get esm package version, closes #194 #232
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
Conversation
How about using https://www.npmjs.com/package/local-pkg to get version? |
|
the resolver's return type is promise, and not pass the tests, is the resolver type must not be a promise? |
@antfu Maybe we can add a sync version to |
but getPkgVersion method must be a sync method, i didn't found a good method to resolve it , do you have any other good idea to make async method to sync. |
You can just make |
export function ElementPlusResolver(
options: ElementPlusResolverOptions = {},
): ComponentResolver[] {
let optionsResolved: ElementPlusResolverOptionsResolved | undefined
async function resolveOptions() {
if (optionsResolved)
return optionsResolved
optionsResolved = {
ssr: false,
version: await getPkgVersion('element-plus', '1.1.0-beta.21'),
importStyle: 'css',
directives: true,
...options,
}
return optionsResolved
}
return [
{
type: 'component',
resolve: async(name: string) => {
return resolveComponent(name, await resolveOptions())
},
},
{
type: 'directive',
resolve: async(name: string) => {
return resolveDirective(name, await resolveOptions())
},
},
]
} |
fix issue 194 use resolve instead commonjs require() to read package.json version