mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
feat(nuxt): add versions
to runtime nuxtApp (#19064)
This commit is contained in:
parent
c35104c769
commit
d4a75240ac
@ -42,6 +42,8 @@ Note: this is an internal interface, and some properties might change until stab
|
||||
const nuxtApp = {
|
||||
vueApp, // the global Vue application: https://vuejs.org/api/application.html#application-api
|
||||
|
||||
versions, // an object containing Nuxt and Vue versions
|
||||
|
||||
// These let you call and add runtime NuxtApp hooks
|
||||
// https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/app/nuxt.ts#L18
|
||||
hooks,
|
||||
|
5
packages/nuxt/index.d.ts
vendored
Normal file
5
packages/nuxt/index.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
declare global {
|
||||
const __NUXT_VERSION__: string
|
||||
}
|
||||
|
||||
export {}
|
@ -60,6 +60,7 @@ export interface NuxtSSRContext extends SSRContext {
|
||||
interface _NuxtApp {
|
||||
vueApp: App<Element>
|
||||
globalName: string
|
||||
versions: Record<string, string>
|
||||
|
||||
hooks: Hookable<RuntimeNuxtHooks>
|
||||
hook: _NuxtApp['hooks']['hook']
|
||||
@ -120,6 +121,10 @@ export function createNuxtApp (options: CreateOptions) {
|
||||
const nuxtApp: NuxtApp = {
|
||||
provide: undefined,
|
||||
globalName: 'nuxt',
|
||||
versions: {
|
||||
get nuxt () { return __NUXT_VERSION__ },
|
||||
get vue () { return nuxtApp.vueApp.version }
|
||||
},
|
||||
payload: reactive({
|
||||
data: {},
|
||||
state: {},
|
||||
|
@ -59,6 +59,7 @@ export async function bundle (nuxt: Nuxt) {
|
||||
exclude: ['nuxt/app']
|
||||
},
|
||||
css: resolveCSSOptions(nuxt),
|
||||
define: { __NUXT_VERSION__: JSON.stringify(nuxt._version) },
|
||||
build: {
|
||||
copyPublicDir: false,
|
||||
rollupOptions: {
|
||||
|
@ -230,6 +230,7 @@ function getEnv (ctx: WebpackConfigContext) {
|
||||
'process.env.NODE_ENV': JSON.stringify(ctx.config.mode),
|
||||
'process.mode': JSON.stringify(ctx.config.mode),
|
||||
'process.dev': options.dev,
|
||||
__NUXT_VERSION__: JSON.stringify(ctx.nuxt._version),
|
||||
'process.env.VUE_ENV': JSON.stringify(ctx.name),
|
||||
'process.browser': ctx.isClient,
|
||||
'process.client': ctx.isClient,
|
||||
|
@ -40,7 +40,7 @@ describe.skipIf(isWindows)('minimal nuxt application', () => {
|
||||
|
||||
it('default server bundle size', async () => {
|
||||
stats.server = await analyzeSizes(['**/*.mjs', '!node_modules'], serverDir)
|
||||
expect(stats.server.totalBytes).toBeLessThan(92800)
|
||||
expect(stats.server.totalBytes).toBeLessThan(92900)
|
||||
|
||||
const modules = await analyzeSizes('node_modules/**/*', serverDir)
|
||||
expect(modules.totalBytes).toBeLessThan(2722000)
|
||||
|
Loading…
Reference in New Issue
Block a user