Skip to content

Commit

Permalink
fix(vite): allow full package resolution overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Aug 16, 2022
1 parent dfa3959 commit d85944a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
5 changes: 4 additions & 1 deletion packages/nuxt/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ export default defineNuxtModule<ModuleOptions>({
config.plugins.push(SchemaOrgVitePlugin({
mock: !moduleOptions.client && isClient,
full: moduleOptions.full,
runtimePath: nuxtSchemaComposablesRuntime,
aliasPaths: {
pkgDir: schemaOrgPath,
runtime: nuxtSchemaComposablesRuntime,
},
}))
})
},
Expand Down
16 changes: 8 additions & 8 deletions packages/vite/src/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export interface PluginOptions {
/**
* Path to a real custom runtime (not mocked).
*/
runtimePath?: string
/**
* Path to a real custom provider (not mocked).
*/
providerPath?: string
aliasPaths?: {
pkgDir?: string
provider?: string
runtime?: string
}
/**
* Scan files from this root directory (ignoring node_modules).
*/
Expand All @@ -40,14 +40,14 @@ export const schemaOrgSwapAliases = () => createUnplugin<PluginOptions>((args) =
const fetchPaths = async () => {
if (paths)
return paths
const pkgDir = dirname(await resolvePath(SchemaOrgPkg))
const pkgDir = args.aliasPaths?.pkgDir || dirname(await resolvePath(SchemaOrgPkg))
let provider, runtime
if (args?.mock) {
provider = runtime = await resolvePath(`${SchemaOrgPkg}/runtime/mock`)
}
else {
provider = args?.providerPath || await resolvePath(`${SchemaOrgPkg}/${args?.full ? 'full' : 'simple'}`)
runtime = args?.runtimePath || await resolvePath(`${SchemaOrgPkg}/runtime`)
provider = args.aliasPaths?.provider || await resolvePath(`${SchemaOrgPkg}/${args?.full ? 'full' : 'simple'}`)
runtime = args.aliasPaths?.runtime || await resolvePath(`${SchemaOrgPkg}/runtime`)
}
paths = {
pkgDir,
Expand Down

0 comments on commit d85944a

Please sign in to comment.