Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
Merge branch 'main' into fix/typecheck-spa
Browse files Browse the repository at this point in the history
  • Loading branch information
Atinux committed Oct 3, 2022
2 parents c529d56 + 6d3dc3b commit 8e0d3fc
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 377 deletions.
2 changes: 1 addition & 1 deletion examples/routing/layouts/pages/dynamic.vue
Expand Up @@ -5,7 +5,7 @@
<NuxtLayout :name="layout">
Default slot
<br>
<button class="border p-1 rounded" @click="layout ? layout = null : layout = 'custom'">
<button class="border p-1 rounded" @click="layout = layout ? null : 'custom'">
Switch layout
</button>

Expand Down
21 changes: 14 additions & 7 deletions package.json
Expand Up @@ -35,23 +35,25 @@
"version": "yarn && git add yarn.lock"
},
"resolutions": {
"@nuxt/kit": "link:./packages/kit",
"@nuxt/schema": "link:./packages/schema",
"@nuxt/test-utils": "link:./packages/test-utils",
"@nuxt/vite": "link:./packages/vite",
"@nuxt/webpack": "link:./packages/webpack",
"nuxi": "link:./packages/nuxi",
"nuxt": "link:./packages/nuxt",
"@nuxt/kit": "workspace:^",
"@nuxt/schema": "workspace:^",
"@nuxt/test-utils": "workspace:^",
"@nuxt/vite-builder": "workspace:^",
"@nuxt/webpack-builder": "workspace:^",
"nuxi": "workspace:^",
"nuxt": "workspace:^",
"nuxt3": "link:./packages/nuxt",
"vite": "~3.1.3",
"unbuild": "^0.8.11"
},
"devDependencies": {
"@actions/core": "^1.9.1",
"@nuxt/test-utils": "workspace:^",
"@nuxtjs/eslint-config-typescript": "^11.0.0",
"@types/crawler": "^1.2.2",
"@types/node": "^16.11.60",
"@types/rimraf": "^3",
"@types/semver": "^7",
"@unocss/reset": "^0.45.23",
"case-police": "^0.5.10",
"changelogen": "^0.3.2",
Expand All @@ -64,10 +66,15 @@
"jiti": "^1.16.0",
"lerna": "^5.5.2",
"markdownlint-cli": "^0.32.2",
"ohmyfetch": "^0.4.19",
"pathe": "^0.3.8",
"rimraf": "^3.0.2",
"semver": "^7.3.7",
"std-env": "^3.2.1",
"typescript": "^4.8.3",
"ufo": "^0.8.5",
"unbuild": "^0.8.11",
"vite": "^3.1.4",
"vitest": "~0.19.1",
"vue-tsc": "^0.39.5"
},
Expand Down
6 changes: 4 additions & 2 deletions packages/nuxt/src/core/templates.ts
@@ -1,7 +1,7 @@
import type { Nuxt, NuxtApp, NuxtTemplate } from '@nuxt/schema'
import { genArrayFromRaw, genDynamicImport, genExport, genImport, genObjectFromRawEntries, genString, genSafeVariableName } from 'knitwork'

import { isAbsolute, join, relative } from 'pathe'
import { isAbsolute, join, relative, resolve } from 'pathe'
import { resolveSchema, generateTypes } from 'untyped'
import escapeRE from 'escape-string-regexp'
import { hash } from 'ohash'
Expand Down Expand Up @@ -120,12 +120,14 @@ export const schemaTemplate: NuxtTemplate<TemplateContext> = {
importName: m.entryPath || m.meta?.name
})).filter(m => m.configKey && m.name && !adHocModules.includes(m.name))

const relativeRoot = relative(resolve(nuxt.options.buildDir, 'types'), nuxt.options.rootDir)

return [
"import { NuxtModule } from '@nuxt/schema'",
"declare module '@nuxt/schema' {",
' interface NuxtConfig {',
...moduleInfo.filter(Boolean).map(meta =>
` [${genString(meta.configKey)}]?: typeof ${genDynamicImport(meta.importName, { wrapper: false })}.default extends NuxtModule<infer O> ? Partial<O> : Record<string, any>`
` [${genString(meta.configKey)}]?: typeof ${genDynamicImport(meta.importName.startsWith('.') ? './' + join(relativeRoot, meta.importName) : meta.importName, { wrapper: false })}.default extends NuxtModule<infer O> ? Partial<O> : Record<string, any>`
),
' }',
generateTypes(await resolveSchema(Object.fromEntries(Object.entries(nuxt.options.runtimeConfig).filter(([key]) => key !== 'public'))),
Expand Down
1 change: 1 addition & 0 deletions packages/schema/package.json
Expand Up @@ -16,6 +16,7 @@
"devDependencies": {
"@types/lodash.template": "^4",
"@types/semver": "^7",
"@vitejs/plugin-vue": "^3.1.0",
"unbuild": "latest",
"untyped": "^0.5.0",
"vite": "~3.1.3"
Expand Down

0 comments on commit 8e0d3fc

Please sign in to comment.