Skip to content

Commit 293e1f2

Browse files
committed
fix: nuxt module ts fix
1 parent de6c8d7 commit 293e1f2

File tree

2 files changed

+38
-24
lines changed

2 files changed

+38
-24
lines changed

nuxt/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vueform/builder-nuxt",
3-
"version": "1.1.0",
3+
"version": "1.3.0",
44
"description": "Nuxt module for Vueform Builder",
55
"repository": "vueform/builder-nuxt",
66
"license": "MIT",
@@ -28,7 +28,7 @@
2828
"dev": "nuxi dev playground",
2929
"dev:build": "nuxi build playground",
3030
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
31-
"release": "npm run lint && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
31+
"release": "npm run lint && npm run prepack && npm publish",
3232
"lint": "eslint .",
3333
"test": "vitest run",
3434
"test:watch": "vitest watch"

nuxt/src/module.ts

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
11
import { existsSync } from 'fs'
2-
import type { NuxtModule } from '@nuxt/schema'
32
import { resolve } from 'pathe'
4-
import {
5-
defineNuxtModule,
6-
addPluginTemplate,
7-
createResolver,
8-
} from '@nuxt/kit'
3+
import { defineNuxtModule, addPluginTemplate, createResolver } from '@nuxt/kit'
94

105
// Module options TypeScript interface definition
116
export interface ModuleOptions {
127
configPath?: string,
138
builderConfigPath?: string,
149
}
1510

16-
const module: NuxtModule<ModuleOptions> = defineNuxtModule<ModuleOptions>({
11+
export default defineNuxtModule<ModuleOptions>({
1712
meta: {
1813
name: 'VueformBuilder',
1914
configKey: 'vueform-builder',
2015
compatibility: {
2116
nuxt: '^3.0.0',
2217
},
2318
},
19+
// Default configuration options of the Nuxt module
2420
defaults: {
2521
configPath: undefined,
26-
builderConfigPath: undefined,
2722
},
28-
async setup(options, nuxt) {
23+
async setup (options, nuxt) {
2924
const resolver = createResolver(import.meta.url)
3025

3126
nuxt.hook('prepare:types', (opts) => {
@@ -49,33 +44,54 @@ const module: NuxtModule<ModuleOptions> = defineNuxtModule<ModuleOptions>({
4944
]
5045
}
5146

52-
const configBase = resolve(
47+
let configBase = resolve(
5348
nuxt.options.rootDir,
5449
options.configPath || 'vueform.config.js'
5550
)
5651

57-
const builderConfigBase = resolve(
52+
let builderConfigBase = resolve(
5853
nuxt.options.rootDir,
5954
options.builderConfigPath || 'builder.config.js'
6055
)
6156

6257
addPluginTemplate({
6358
async getContents() {
64-
const configPath = await resolver.resolvePath(configBase)
65-
const configPathExists = existsSync(configPath)
66-
const builderConfigPath = await resolver.resolvePath(builderConfigBase)
67-
const builderConfigPathExists = existsSync(builderConfigPath)
59+
let configPath = await resolver.resolvePath(configBase)
60+
let configPathExists = existsSync(configPath)
6861

6962
if (!configPathExists) {
70-
throw new Error(
71-
`Vueform configuration was not located at ${configPath}`
63+
configBase = resolve(
64+
nuxt.options.rootDir,
65+
'vueform.config.ts'
7266
)
67+
68+
configPath = await resolver.resolvePath(configBase)
69+
configPathExists = existsSync(configPath)
70+
71+
if (!configPathExists) {
72+
throw new Error(
73+
`Vueform configuration was not located at ${configPath}`
74+
)
75+
}
7376
}
7477

78+
let builderConfigPath = await resolver.resolvePath(builderConfigBase)
79+
let builderConfigPathExists = existsSync(builderConfigPath)
80+
7581
if (!builderConfigPathExists) {
76-
throw new Error(
77-
`Vueform Builder configuration was not located at ${configPath}`
82+
builderConfigBase = resolve(
83+
nuxt.options.rootDir,
84+
'builder.config.ts'
7885
)
86+
87+
builderConfigPath = await resolver.resolvePath(builderConfigBase)
88+
builderConfigPathExists = existsSync(builderConfigPath)
89+
90+
if (!builderConfigPathExists) {
91+
throw new Error(
92+
`Vueform Builder configuration was not located at ${configPath}`
93+
)
94+
}
7995
}
8096

8197
return `import { defineNuxtPlugin } from '#imports'
@@ -95,7 +111,5 @@ const module: NuxtModule<ModuleOptions> = defineNuxtModule<ModuleOptions>({
95111
},
96112
filename: 'vueformBuilderPlugin.mjs',
97113
})
98-
},
114+
}
99115
})
100-
101-
export default module

0 commit comments

Comments
 (0)