mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-29 09:02:03 +00:00
docs: fix typos (#18976)
This commit is contained in:
parent
7111b6cf44
commit
b25b6c82c7
@ -18,7 +18,7 @@ Hook | Arguments | Environment | Description
|
|||||||
`app:error:cleared` | `{ redirect? }` | Server & Client | Called when a fatal error occurs.
|
`app:error:cleared` | `{ redirect? }` | Server & Client | Called when a fatal error occurs.
|
||||||
`app:data:refresh` | `keys?` | Server & Client | (internal)
|
`app:data:refresh` | `keys?` | Server & Client | (internal)
|
||||||
`vue:setup` | - | Server & Client | (internal)
|
`vue:setup` | - | Server & Client | (internal)
|
||||||
`vue:error` | `err, target, info` | Server & Client | Called when a vue error propages to the root component. [Learn More](https://vuejs.org/api/composition-api-lifecycle.html#onerrorcaptured).
|
`vue:error` | `err, target, info` | Server & Client | Called when a vue error propagates to the root component. [Learn More](https://vuejs.org/api/composition-api-lifecycle.html#onerrorcaptured).
|
||||||
`app:rendered` | `renderContext` | Server | Called when SSR rendering is done.
|
`app:rendered` | `renderContext` | Server | Called when SSR rendering is done.
|
||||||
`app:redirected` | - | Server | Called before SSR redirection.
|
`app:redirected` | - | Server | Called before SSR redirection.
|
||||||
`app:beforeMount` | `vueApp` | Client | Called before mounting the app, called only on client side.
|
`app:beforeMount` | `vueApp` | Client | Called before mounting the app, called only on client side.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
// see ../compoables/locale.ts for the implementation
|
// see ../composables/locale.ts for the implementation
|
||||||
const locales = useLocales()
|
const locales = useLocales()
|
||||||
const locale = useLocale()
|
const locale = useLocale()
|
||||||
const date = useLocaleDate(new Date('2016-10-26') /* NUXT_BIRTHDAY */)
|
const date = useLocaleDate(new Date('2016-10-26') /* NUXT_BIRTHDAY */)
|
||||||
|
@ -51,7 +51,7 @@ export async function loadNuxt (opts: LoadNuxtOptions): Promise<Nuxt> {
|
|||||||
for: opts.dev ? 'dev' : 'build',
|
for: opts.dev ? 'dev' : 'build',
|
||||||
configOverrides: opts.overrides,
|
configOverrides: opts.overrides,
|
||||||
ready: opts.ready,
|
ready: opts.ready,
|
||||||
envConfig: opts.dotenv // TODO: Backward format convertion
|
envConfig: opts.dotenv // TODO: Backward format conversion
|
||||||
})
|
})
|
||||||
|
|
||||||
return nuxt as Nuxt
|
return nuxt as Nuxt
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<Suspense @resolve="onResolve">
|
<Suspense @resolve="onResolve">
|
||||||
<ErrorComponent v-if="error" :error="error" />
|
<ErrorComponent v-if="error" :error="error" />
|
||||||
<IslandRendererer v-else-if="islandContext" :context="islandContext" />
|
<IslandRenderer v-else-if="islandContext" :context="islandContext" />
|
||||||
<AppComponent v-else />
|
<AppComponent v-else />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</template>
|
</template>
|
||||||
@ -14,7 +14,7 @@ import { useRoute } from '#app/composables/router'
|
|||||||
import AppComponent from '#build/app-component.mjs'
|
import AppComponent from '#build/app-component.mjs'
|
||||||
|
|
||||||
const ErrorComponent = defineAsyncComponent(() => import('#build/error-component.mjs').then(r => r.default || r))
|
const ErrorComponent = defineAsyncComponent(() => import('#build/error-component.mjs').then(r => r.default || r))
|
||||||
const IslandRendererer = process.server
|
const IslandRenderer = process.server
|
||||||
? defineAsyncComponent(() => import('./island-renderer').then(r => r.default || r))
|
? defineAsyncComponent(() => import('./island-renderer').then(r => r.default || r))
|
||||||
: () => null
|
: () => null
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ export function useAsyncData<
|
|||||||
error: ref(nuxt.payload._errors[key] ? createError(nuxt.payload._errors[key]) : null)
|
error: ref(nuxt.payload._errors[key] ? createError(nuxt.payload._errors[key]) : null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: Else, Soemhow check for confliciting keys with different defaults or fetcher
|
// TODO: Else, somehow check for conflicting keys with different defaults or fetcher
|
||||||
const asyncData = { ...nuxt._asyncData[key] } as AsyncData<DataT, DataE>
|
const asyncData = { ...nuxt._asyncData[key] } as AsyncData<DataT, DataE>
|
||||||
|
|
||||||
asyncData.refresh = asyncData.execute = (opts = {}) => {
|
asyncData.refresh = asyncData.execute = (opts = {}) => {
|
||||||
|
@ -82,7 +82,7 @@ export const navigateTo = (to: RouteLocationRaw | undefined | null, options?: Na
|
|||||||
const toPath = typeof to === 'string' ? to : ((to as RouteLocationPathRaw).path || '/')
|
const toPath = typeof to === 'string' ? to : ((to as RouteLocationPathRaw).path || '/')
|
||||||
const isExternal = hasProtocol(toPath, true)
|
const isExternal = hasProtocol(toPath, true)
|
||||||
if (isExternal && !options?.external) {
|
if (isExternal && !options?.external) {
|
||||||
throw new Error('Navigating to external URL is not allowed by default. Use `nagivateTo (url, { external: true })`.')
|
throw new Error('Navigating to external URL is not allowed by default. Use `navigateTo (url, { external: true })`.')
|
||||||
}
|
}
|
||||||
if (isExternal && parseURL(toPath).protocol === 'script:') {
|
if (isExternal && parseURL(toPath).protocol === 'script:') {
|
||||||
throw new Error('Cannot navigate to an URL with script protocol.')
|
throw new Error('Cannot navigate to an URL with script protocol.')
|
||||||
|
@ -5,7 +5,7 @@ import { useRouter } from '#app/composables/router'
|
|||||||
|
|
||||||
export default defineNuxtPlugin((nuxtApp) => {
|
export default defineNuxtPlugin((nuxtApp) => {
|
||||||
// Only enable behavior if initial page is prerendered
|
// Only enable behavior if initial page is prerendered
|
||||||
// TOOD: Support hybrid and dev
|
// TODO: Support hybrid and dev
|
||||||
if (!isPrerendered()) {
|
if (!isPrerendered()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -374,7 +374,7 @@ function renderHTMLDocument (html: NuxtRenderHTMLContext) {
|
|||||||
</html>`
|
</html>`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TOOD: Move to external library
|
// TODO: Move to external library
|
||||||
const HTML_TAG_RE = /<(?<tag>[a-z]+)(?<rawAttrs> [^>]*)?>(?:(?<innerHTML>[\s\S]*?)<\/\k<tag>)?/g
|
const HTML_TAG_RE = /<(?<tag>[a-z]+)(?<rawAttrs> [^>]*)?>(?:(?<innerHTML>[\s\S]*?)<\/\k<tag>)?/g
|
||||||
const HTML_TAG_ATTR_RE = /(?<name>[a-z]+)="(?<value>[^"]*)"/g
|
const HTML_TAG_ATTR_RE = /(?<name>[a-z]+)="(?<value>[^"]*)"/g
|
||||||
function extractHTMLTags (html: string) {
|
function extractHTMLTags (html: string) {
|
||||||
|
@ -50,7 +50,7 @@ export default defineNuxtModule({
|
|||||||
schema = await resolveSchema()
|
schema = await resolveSchema()
|
||||||
})
|
})
|
||||||
|
|
||||||
// Writie schema after build to allow further modifications
|
// Write schema after build to allow further modifications
|
||||||
nuxt.hooks.hook('build:done', async () => {
|
nuxt.hooks.hook('build:done', async () => {
|
||||||
await nuxt.hooks.callHook('schema:beforeWrite', schema)
|
await nuxt.hooks.callHook('schema:beforeWrite', schema)
|
||||||
await writeSchema(schema)
|
await writeSchema(schema)
|
||||||
@ -112,7 +112,7 @@ export default defineNuxtModule({
|
|||||||
)
|
)
|
||||||
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
// Merge after normalazation
|
// Merge after normalization
|
||||||
const schema = defu(...schemas)
|
const schema = defu(...schemas)
|
||||||
|
|
||||||
// Allow hooking to extend resolved schema
|
// Allow hooking to extend resolved schema
|
||||||
|
@ -95,40 +95,40 @@ describe('treeshake client only in ssr', () => {
|
|||||||
|
|
||||||
const ssrResult = await SFCCompile(`SomeComponent${index}.vue`, WithClientOnly, state.options, true)
|
const ssrResult = await SFCCompile(`SomeComponent${index}.vue`, WithClientOnly, state.options, true)
|
||||||
|
|
||||||
const treeshaked = await treeshake(ssrResult)
|
const treeshaken = await treeshake(ssrResult)
|
||||||
const [_, scopeId] = clientResult.match(/_pushScopeId\("(.*)"\)/)!
|
const [_, scopeId] = clientResult.match(/_pushScopeId\("(.*)"\)/)!
|
||||||
|
|
||||||
// ensure the id is correctly passed between server and client
|
// ensure the id is correctly passed between server and client
|
||||||
expect(clientResult).toContain(`pushScopeId("${scopeId}")`)
|
expect(clientResult).toContain(`pushScopeId("${scopeId}")`)
|
||||||
expect(treeshaked).toContain(`<div ${scopeId}>`)
|
expect(treeshaken).toContain(`<div ${scopeId}>`)
|
||||||
|
|
||||||
expect(clientResult).toContain('should-be-treeshaken')
|
expect(clientResult).toContain('should-be-treeshaken')
|
||||||
expect(treeshaked).not.toContain('should-be-treeshaken')
|
expect(treeshaken).not.toContain('should-be-treeshaken')
|
||||||
|
|
||||||
expect(treeshaked).not.toContain("import HelloWorld from '../HelloWorld.vue'")
|
expect(treeshaken).not.toContain("import HelloWorld from '../HelloWorld.vue'")
|
||||||
expect(clientResult).toContain("import HelloWorld from '../HelloWorld.vue'")
|
expect(clientResult).toContain("import HelloWorld from '../HelloWorld.vue'")
|
||||||
|
|
||||||
expect(treeshaked).not.toContain("import { Treeshaken } from 'somepath'")
|
expect(treeshaken).not.toContain("import { Treeshaken } from 'somepath'")
|
||||||
expect(clientResult).toContain("import { Treeshaken } from 'somepath'")
|
expect(clientResult).toContain("import { Treeshaken } from 'somepath'")
|
||||||
|
|
||||||
// remove resolved import
|
// remove resolved import
|
||||||
expect(treeshaked).not.toContain('const _component_ResolvedImport =')
|
expect(treeshaken).not.toContain('const _component_ResolvedImport =')
|
||||||
expect(clientResult).toContain('const _component_ResolvedImport =')
|
expect(clientResult).toContain('const _component_ResolvedImport =')
|
||||||
|
|
||||||
// expect import of ClientImport to be treeshaken but not Glob since it is also used outside <ClientOnly>
|
// expect import of ClientImport to be treeshaken but not Glob since it is also used outside <ClientOnly>
|
||||||
expect(treeshaked).not.toContain('ClientImport')
|
expect(treeshaken).not.toContain('ClientImport')
|
||||||
expect(treeshaked).toContain('import { Glob, } from \'#components\'')
|
expect(treeshaken).toContain('import { Glob, } from \'#components\'')
|
||||||
|
|
||||||
if (state.options.isProduction === false) {
|
if (state.options.isProduction === false) {
|
||||||
// treeshake at inlined template
|
// treeshake at inlined template
|
||||||
expect(treeshaked).not.toContain('ssrRenderComponent($setup["HelloWorld"]')
|
expect(treeshaken).not.toContain('ssrRenderComponent($setup["HelloWorld"]')
|
||||||
expect(treeshaked).toContain('ssrRenderComponent($setup["Glob"]')
|
expect(treeshaken).toContain('ssrRenderComponent($setup["Glob"]')
|
||||||
} else {
|
} else {
|
||||||
// treeshake unref
|
// treeshake unref
|
||||||
expect(treeshaked).not.toContain('ssrRenderComponent(_unref(HelloWorld')
|
expect(treeshaken).not.toContain('ssrRenderComponent(_unref(HelloWorld')
|
||||||
expect(treeshaked).toContain('ssrRenderComponent(_unref(Glob')
|
expect(treeshaken).toContain('ssrRenderComponent(_unref(Glob')
|
||||||
}
|
}
|
||||||
expect(treeshaked).toMatchSnapshot()
|
expect(treeshaken).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -7,7 +7,7 @@ export async function createBrowser () {
|
|||||||
|
|
||||||
let playwright: typeof import('playwright')
|
let playwright: typeof import('playwright')
|
||||||
try {
|
try {
|
||||||
// Workround for https://github.com/nuxt/nuxt/issues/13441
|
// Workaround for https://github.com/nuxt/nuxt/issues/13441
|
||||||
// TODO: Remove when upstream issue resolved
|
// TODO: Remove when upstream issue resolved
|
||||||
playwright = await import(String('playwright'))
|
playwright = await import(String('playwright'))
|
||||||
} catch {
|
} catch {
|
||||||
|
@ -2,4 +2,4 @@ export function badSideEffect () {
|
|||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error('composables/badSideEffect.ts should be tree-shaked')
|
throw new Error('composables/badSideEffect.ts should be tree-shaken')
|
||||||
|
Loading…
Reference in New Issue
Block a user