Skip to content

Commit

Permalink
chore: stable version for nuxt 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Intevel committed Nov 17, 2022
1 parent 3471cc4 commit 102e2ee
Show file tree
Hide file tree
Showing 3 changed files with 725 additions and 749 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
"lint": "eslint --ext .js,.ts,.vue"
},
"dependencies": {
"@nuxt/kit": "^3.0.0-rc.13",
"@nuxt/kit": "^3.0.0",
"standard-version": "^9.3.2"
},
"devDependencies": {
"@nuxt/module-builder": "latest",
"@nuxtjs/eslint-config-typescript": "latest",
"eslint": "latest",
"nuxt": "^3.0.0-rc.13"
"nuxt": "^3.0.0"
},
"keywords": [
"nuxt",
Expand Down
11 changes: 6 additions & 5 deletions src/module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { resolve } from 'path'
import { fileURLToPath } from 'url'
import { defu } from 'defu'
import { defineNuxtModule, addPlugin, addAutoImportDir } from '@nuxt/kit'
import { defineNuxtModule, addPlugin, addImportsDir, isNuxt2 } from '@nuxt/kit'
import { DirectusQueryParams } from './runtime/types'
export interface ModuleOptions {
/**
Expand Down Expand Up @@ -43,9 +43,9 @@ export default defineNuxtModule<ModuleOptions>({
},
setup (options, nuxt) {
// Nuxt 2 / Bridge
if (!nuxt?.options?.runtimeConfig?.public?.directus) {
nuxt.options.publicRuntimeConfig.directus = defu(
nuxt.options.publicRuntimeConfig.directus,
if (isNuxt2() && !nuxt?.options?.runtimeConfig?.public?.directus) {
// @ts-ignore
nuxt.options.publicRuntimeConfig.directus = defu(nuxt.options.publicRuntimeConfig.directus,
{
url: options.url,
autoFetch: options.autoFetch,
Expand All @@ -56,6 +56,7 @@ export default defineNuxtModule<ModuleOptions>({
}

// Nuxt 3
nuxt.options.runtimeConfig.public = nuxt.options.runtimeConfig.public || {}
nuxt.options.runtimeConfig.public.directus = defu(nuxt.options.runtimeConfig.directus, {
url: options.url,
autoFetch: options.autoFetch,
Expand All @@ -67,7 +68,7 @@ export default defineNuxtModule<ModuleOptions>({
nuxt.options.build.transpile.push(runtimeDir)

addPlugin(resolve(runtimeDir, 'plugin'))
addAutoImportDir(resolve(runtimeDir, 'composables'))
addImportsDir(resolve(runtimeDir, 'composables'))
}
})

Expand Down
Loading

0 comments on commit 102e2ee

Please sign in to comment.