Skip to content

Commit

Permalink
fix: use virtual file for framework version
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Oct 24, 2023
1 parent 06a921a commit 2d841f8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 8 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import {
addPlugin,
createResolver,
addRouteMiddleware,
addTemplate,
} from '@nuxt/kit'
import { defu } from 'defu'
import { version } from '../package.json'

// Module options TypeScript interface definition
export interface ModuleOptions {
Expand All @@ -23,6 +25,7 @@ export default defineNuxtModule<ModuleOptions>({
meta: {
name: '@nuxtjs/kinde',
configKey: 'kinde',
version
},
// Default configuration options of the Nuxt module
defaults: {
Expand All @@ -38,6 +41,11 @@ export default defineNuxtModule<ModuleOptions>({
postLoginRedirectURL: '',
})

addTemplate({
filename: 'kinde-version.mjs',
getContents: () => `export const version = '${version}'`,
})

// Do not add the extension since the `.ts` will be transpiled to `.mjs` after `npm run prepack`
addPlugin(resolver.resolve('./runtime/plugin'))

Expand Down
9 changes: 4 additions & 5 deletions src/runtime/server/utils/client.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import {
createKindeServerClient,
GrantType,
} from '@kinde-oss/kinde-typescript-sdk'
import { createKindeServerClient, GrantType } from '@kinde-oss/kinde-typescript-sdk'
import type { ACClient } from '@kinde-oss/kinde-typescript-sdk'
import { useRuntimeConfig } from '#imports'

import { version as frameworkVersion } from '#build/kinde-version.mjs'

let kindeClient: ACClient

export const getKindeClient = () => {
Expand All @@ -18,7 +17,7 @@ export const getKindeClient = () => {
logoutRedirectURL: config.kinde.logoutRedirectURL,
redirectURL: config.kinde.redirectURL,
framework: 'Nuxt',
frameworkVersion: '0.1.0',
frameworkVersion,
})

return kindeClient
Expand Down

0 comments on commit 2d841f8

Please sign in to comment.