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

Commit 3a60bf6

Browse files
authored
perf(nuxt): import defineNuxtConfig from nuxt/config (#7485)
1 parent 5d79ed5 commit 3a60bf6

File tree

6 files changed

+26
-3
lines changed

6 files changed

+26
-3
lines changed

packages/nuxt/config.cjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function defineNuxtConfig (config) {
2+
return config
3+
}
4+
5+
module.exports = {
6+
defineNuxtConfig
7+
}

packages/nuxt/config.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { NuxtConfig } from '@nuxt/schema'
2+
export { NuxtConfig } from '@nuxt/schema'
3+
4+
export declare function defineNuxtConfig(config: NuxtConfig): NuxtConfig

packages/nuxt/config.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function defineNuxtConfig (config) {
2+
return config
3+
}
4+
5+
export { defineNuxtConfig }

packages/nuxt/package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
},
1313
"exports": {
1414
".": "./dist/index.mjs",
15+
"./config": {
16+
"import": "./config.mjs",
17+
"require": "./config.cjs",
18+
"types": "./config.d.ts"
19+
},
1520
"./app": "./dist/app/index.mjs",
1621
"./package.json": "./package.json"
1722
},
@@ -24,7 +29,8 @@
2429
"app.d.ts",
2530
"bin",
2631
"types.d.ts",
27-
"dist"
32+
"dist",
33+
"config.*"
2834
],
2935
"scripts": {
3036
"prepack": "unbuild"

packages/nuxt/src/core/nuxt.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,10 @@ export async function loadNuxt (opts: LoadNuxtOptions): Promise<Nuxt> {
234234
return nuxt
235235
}
236236

237+
/** @deprecated Use import { defineNuxtConfig } from 'nuxt/config' */
237238
export function defineNuxtConfig (config: NuxtConfig): NuxtConfig {
238239
return config
239240
}
240241

241-
// For a convenience import together with `defineNuxtConfig`
242+
/** @deprecated Use import type { NuxtConfig } from 'nuxt/config' */
242243
export type { NuxtConfig }

playground/nuxt.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import { defineNuxtConfig } from 'nuxt'
1+
import { defineNuxtConfig } from 'nuxt/config'
22

33
export default defineNuxtConfig({})

0 commit comments

Comments
 (0)