Skip to content

Commit

Permalink
fix(nuxt): pergel object
Browse files Browse the repository at this point in the history
  • Loading branch information
productdevbook committed Dec 10, 2023
1 parent 4e06e90 commit f4fcc28
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 22 deletions.
6 changes: 5 additions & 1 deletion examples/devtools-test/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ export default defineNuxtConfig({
],
devtools: { enabled: true },
pergel: {
text: 'Hello World!',
projects: {
test: {
S3: true,
},
},
},
})
2 changes: 1 addition & 1 deletion examples/devtools-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"postinstall": "nuxt prepare"
},
"dependencies": {
"@pergel/nuxt": "0.0.1-beta.3"
"@pergel/nuxt": "0.0.1-beta.4"
},
"devDependencies": {
"@nuxt/devtools": "latest",
Expand Down
8 changes: 4 additions & 4 deletions examples/devtools-test/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion packages/nuxt/playground/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export default defineNuxtConfig({
}),
],
pergel: {
devtools: true,
projects: {
test: {
S3: true,
},
},
},
})
2 changes: 1 addition & 1 deletion packages/nuxt/src/core/setupModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export async function setupModules(data: {

try {
const getIndexExt = () => {
const datas = readdirSync(data.resolver.resolve(join('runtime/modules', moduleName)))
const datas = readdirSync(data.resolver.resolve(join('modules', moduleName)))
const indexExt = datas.find(file => file.includes('index') && !file.includes('.d.'))
if (!indexExt)
throw new Error(`Module ${moduleName} does not have index file`)
Expand Down
27 changes: 13 additions & 14 deletions packages/nuxt/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,6 @@ export default defineNuxtModule<PergelOptions>({
},
async setup(options, nuxt) {
const _resolver = createResolver(import.meta.url)

const { status } = await checkOptions(options)
if (!status)
return

const { saveNitroImports } = useNitroImports(nuxt)
const { saveNuxtImports } = useNuxtImports(nuxt)

const { resolvedPergelOptions } = await setupPergel(options, nuxt)

nuxt.options.vite.optimizeDeps ??= {}
nuxt.options.vite.optimizeDeps.include ??= []
nuxt.options.vite.optimizeDeps.include.push('@nuxt/devtools-kit/iframe-client')

// Pergel _pergel default options
nuxt._pergel = {
nitroImports: {},
Expand All @@ -61,6 +47,19 @@ export default defineNuxtModule<PergelOptions>({
resolver: _resolver,
}

const { status } = await checkOptions(options)
if (!status)
return

const { saveNitroImports } = useNitroImports(nuxt)
const { saveNuxtImports } = useNuxtImports(nuxt)

const { resolvedPergelOptions } = await setupPergel(options, nuxt)

nuxt.options.vite.optimizeDeps ??= {}
nuxt.options.vite.optimizeDeps.include ??= []
nuxt.options.vite.optimizeDeps.include.push('@nuxt/devtools-kit/iframe-client')

if (options.esnext) {
nuxt.options.vite.build ??= {}
nuxt.options.vite.build.target = 'esnext'
Expand Down

0 comments on commit f4fcc28

Please sign in to comment.