diff --git a/packages/nuxt3/src/builder/builder.ts b/packages/nuxt3/src/builder/builder.ts index c16faf57d0..3eaa5c7783 100644 --- a/packages/nuxt3/src/builder/builder.ts +++ b/packages/nuxt3/src/builder/builder.ts @@ -54,6 +54,7 @@ export default class Builder { plugins: Array<{ src: string }> + relativeToBuild: (...args: string[]) => string routes: RouteLocationRaw[] supportedExtensions: string[] @@ -123,7 +124,7 @@ export default class Builder { } } - resolveAppTemplate() { + resolveAppTemplate () { // Resolve appDir const templatesDir = path.join(this.options.appDir, '_templates') const files = globby.sync(path.join(templatesDir, '/**')) @@ -265,7 +266,7 @@ export default class Builder { } } - globPathWithExtensions(path: string) { + globPathWithExtensions (path: string) { return `${path}/**/*.{${this.supportedExtensions.join(',')}}` } @@ -351,7 +352,7 @@ export default class Builder { ) } - addOptionalTemplates(templateContext) { + addOptionalTemplates (templateContext) { if (this.options.build.indicator) { // templateContext.templateFiles.push('components/nuxt-build-indicator.vue') } @@ -361,14 +362,14 @@ export default class Builder { } } - async resolveFiles(dir, cwd = this.options.srcDir) { + async resolveFiles (dir, cwd = this.options.srcDir) { return this.ignore.filter(await glob(this.globPathWithExtensions(dir), { cwd, follow: this.options.build.followSymlinks })) } - async resolveRelative(dir) { + async resolveRelative (dir) { const dirPrefix = new RegExp(`^${dir}/`) return (await this.resolveFiles(dir)).map(file => ({ src: file.replace(dirPrefix, '') })) } @@ -387,7 +388,7 @@ export default class Builder { templateVars.hasApp = false } - async resolveLayouts({ templateVars, templateFiles }) { + async resolveLayouts ({ templateVars, templateFiles }) { if (!this.options.features.layouts) { return } @@ -425,7 +426,7 @@ export default class Builder { } } - async resolvePages(templateContext) { + async resolvePages (templateContext) { const { templateVars } = templateContext const pagesDir = path.join(this.options.srcDir, this.options.dir.pages) @@ -486,7 +487,7 @@ export default class Builder { this.routes = templateVars.router.routes } - async resolveStore({ templateVars, templateFiles }) { + async resolveStore ({ templateVars, templateFiles }) { // Add store if needed if (!this.options.features.store || !this.options.store) { return @@ -742,7 +743,7 @@ export default class Builder { patterns.push(r(this.options.srcDir, this.options.dir.pages)) } - patterns = patterns.map((path) => upath.normalizeSafe(this.globPathWithExtensions(path))) + patterns = patterns.map(path => upath.normalizeSafe(this.globPathWithExtensions(path))) const refreshFiles = debounce(() => this.generateRoutesAndFiles(), 200) diff --git a/packages/nuxt3/src/builder/context/build.ts b/packages/nuxt3/src/builder/context/build.ts index 28efbfac28..f34ad5654b 100644 --- a/packages/nuxt3/src/builder/context/build.ts +++ b/packages/nuxt3/src/builder/context/build.ts @@ -5,7 +5,7 @@ export default class BuildContext { nuxt: Builder['nuxt'] options: Builder['nuxt']['options'] target: Builder['nuxt']['options']['target'] - + constructor (builder: Builder) { this._builder = builder this.nuxt = builder.nuxt diff --git a/packages/nuxt3/src/cli/command.ts b/packages/nuxt3/src/cli/command.ts index 3f5a67c127..17acc4cb27 100644 --- a/packages/nuxt3/src/cli/command.ts +++ b/packages/nuxt3/src/cli/command.ts @@ -26,7 +26,6 @@ export interface Command { type Hooks = Parameters[0] - export default class NuxtCommand extends Hookable { _argv: string[] _parsedArgv: null | ParsedArgs @@ -123,7 +122,7 @@ export default class NuxtCommand extends Hookable { return this._parsedArgv } - async getNuxtConfig(extraOptions: Partial = {}) { + async getNuxtConfig (extraOptions: Partial = {}) { // Flag to indicate nuxt is running with CLI (not programmatic) extraOptions._cli = true @@ -145,7 +144,6 @@ export default class NuxtCommand extends Hookable { } async getNuxt (options: CliConfiguration) { - const nuxt = new Nuxt(options) await nuxt.ready() diff --git a/packages/nuxt3/src/cli/commands/serve.ts b/packages/nuxt3/src/cli/commands/serve.ts index 9048eece91..9d0d35154b 100644 --- a/packages/nuxt3/src/cli/commands/serve.ts +++ b/packages/nuxt3/src/cli/commands/serve.ts @@ -5,10 +5,10 @@ import serveStatic from 'serve-static' import compression from 'compression' import { getNuxtConfig } from 'src/config' import { TARGETS } from 'src/utils' -import { common, server } from '../options' -import { showBanner } from '../utils/banner' import { Listener } from 'src/server' import { Nuxt } from 'src/core' +import { common, server } from '../options' +import { showBanner } from '../utils/banner' import type NuxtCommand from '../command' export default { diff --git a/packages/nuxt3/src/config/config/_app.ts b/packages/nuxt3/src/config/config/_app.ts index 43d6914011..569b9d4d64 100644 --- a/packages/nuxt3/src/config/config/_app.ts +++ b/packages/nuxt3/src/config/config/_app.ts @@ -169,4 +169,4 @@ export default (): AppOptions => ({ // if (typeof options.extensions === 'string') { // options.extensions = [options.extensions] // } -// } \ No newline at end of file +// } diff --git a/packages/nuxt3/src/config/config/_common.ts b/packages/nuxt3/src/config/config/_common.ts index e58301785f..9099578eb7 100644 --- a/packages/nuxt3/src/config/config/_common.ts +++ b/packages/nuxt3/src/config/config/_common.ts @@ -1,3 +1,4 @@ +import path from 'path' import type { WatchOptions as ChokidarWatchOptions } from 'chokidar' import type { NextHandleFunction, Server as ConnectServer } from 'connect' import type { configHooksT } from 'hookable/types/types' @@ -5,11 +6,10 @@ import ignore from 'ignore' import capitalize from 'lodash/capitalize' import env from 'std-env' import type { Configuration as WebpackConfiguration } from 'webpack' -import path from 'path' import { TARGETS, MODES, Target, Mode } from 'src/utils' -import type { NormalizedConfiguration } from '../options' import Hookable from 'hookable' +import type { NormalizedConfiguration } from '../options' type IgnoreOptions = Parameters[0] type IgnoreInstance = ReturnType diff --git a/packages/nuxt3/src/config/config/build.ts b/packages/nuxt3/src/config/config/build.ts index 0306328e1f..00ce807eb5 100644 --- a/packages/nuxt3/src/config/config/build.ts +++ b/packages/nuxt3/src/config/config/build.ts @@ -13,14 +13,12 @@ import type { Options as PugOptions } from 'pug' import type { TerserPluginOptions } from 'terser-webpack-plugin' import type { VueLoaderOptions } from 'vue-loader' import type { - Configuration as WebpackConfiguration, WebpackPluginFunction, - + Configuration as WebpackConfiguration, WebpackPluginFunction } from 'webpack' import type { Options as WebpackDevMiddlewareOptions } from 'webpack-dev-middleware' import type { MiddlewareOptions as WebpackHotMiddlewareOptions, ClientOptions as WebpackHotMiddlewareClientOptions } from 'webpack-hot-middleware' - interface WebpackEnv { isClient: boolean isDev: boolean @@ -96,7 +94,6 @@ interface PostcssVariableMap { environmentVariables?: Record } - interface PostcssConfiguration { order?: PostcssOrderPreset | string[] | ((names: string[], presets: PostcssOrderPresetFunctions) => string[]) plugins?: { @@ -177,7 +174,7 @@ export default () => ({ } as BabelOptions, /** * Enable cache of [terser-webpack-plugin](https://github.com/webpack-contrib/terser-webpack-plugin#options) and [cache-loader](https://github.com/webpack-contrib/cache-loader#cache-loader) - * + * * ⚠️ Experimental * @default false */ @@ -201,7 +198,7 @@ export default () => ({ * Enables Common CSS Extraction using Vue Server Renderer guidelines. * * Using [extract-css-chunks-webpack-plugin](https://github.com/faceyspacey/extract-css-chunks-webpack-plugin/) under the hood, all your CSS will be extracted into separate files, usually one per component. This allows caching your CSS and JavaScript separately and is worth a try in case you have a lot of global or shared CSS. - * + * * @default false */ extractCSS: false as boolean | Record, @@ -303,7 +300,7 @@ export default () => ({ optimizeCSS: undefined as undefined | OptimizeCssAssetsWebpackPluginOptions | boolean, /** * Enable [thread-loader](https://github.com/webpack-contrib/thread-loader#thread-loader) in webpack building - * + * * ⚠️ Experimental * @default false */ @@ -349,12 +346,12 @@ export default () => ({ commons: true }, /** - * Creates special webpack bundle for SSR renderer. + * Creates special webpack bundle for SSR renderer. * @default true for universal mode and `false` for spa mode */ ssr: undefined as undefined | boolean, /** - * + * */ standalone: false, stats: { @@ -371,7 +368,7 @@ export default () => ({ */ templates: [] as Template[], /** - * Terser plugin options. Set to `false` to disable this plugin. See https://github.com/webpack-contrib/terser-webpack-plugin + * Terser plugin options. Set to `false` to disable this plugin. See https://github.com/webpack-contrib/terser-webpack-plugin */ terser: {} as TerserPluginOptions | boolean, // Name of NPM packages to be transpiled @@ -380,6 +377,6 @@ export default () => ({ /** * You can provide your custom files to watch and regenerate after changes. This feature is specially useful for using with modules. */ - watch: [] as string[], + watch: [] as string[] }) diff --git a/packages/nuxt3/src/config/config/index.ts b/packages/nuxt3/src/config/config/index.ts index d1280bfb82..89987c7a6e 100644 --- a/packages/nuxt3/src/config/config/index.ts +++ b/packages/nuxt3/src/config/config/index.ts @@ -26,7 +26,7 @@ export const getDefaultNuxtConfig = () => cli: cli(), generate: generate(), export: undefined as undefined | GenerateOptions, - telemetry: undefined as undefined | boolean, + telemetry: undefined as undefined | boolean }) -export type DefaultConfiguration = ReturnType \ No newline at end of file +export type DefaultConfiguration = ReturnType diff --git a/packages/nuxt3/src/config/config/server.ts b/packages/nuxt3/src/config/config/server.ts index 888ff81df8..d8529719d2 100644 --- a/packages/nuxt3/src/config/config/server.ts +++ b/packages/nuxt3/src/config/config/server.ts @@ -25,4 +25,4 @@ export default ({ env = {} }: { env?: ServerProcessEnv } = {}) => ({ socket: env.UNIX_SOCKET || env.npm_package_config_unix_socket, timing: false as false | { total: boolean } -}) +}) diff --git a/packages/nuxt3/src/config/load.ts b/packages/nuxt3/src/config/load.ts index 87bb9c7240..265801e1b7 100644 --- a/packages/nuxt3/src/config/load.ts +++ b/packages/nuxt3/src/config/load.ts @@ -10,8 +10,8 @@ import destr from 'destr' import * as rc from 'rc9' import { LoadOptions } from 'src/core/load' -import { defaultNuxtConfigFile } from './config' import { CliConfiguration, Configuration } from 'src/config/options' +import { defaultNuxtConfigFile } from './config' // @ts-ignore const isJest = typeof jest !== 'undefined' @@ -71,7 +71,7 @@ export async function loadNuxtConfig ({ // Clear cache clearRequireCache(configFile) const _require = createRequire(module) - let _config: Configuration | ((ctx: Record) => Promise) = interopDefault(_require(configFile) || {}) + const _config: Configuration | ((ctx: Record) => Promise) = interopDefault(_require(configFile) || {}) if (typeof _config === 'function') { try { diff --git a/packages/nuxt3/src/config/options.ts b/packages/nuxt3/src/config/options.ts index fd8ac37c00..401388148c 100644 --- a/packages/nuxt3/src/config/options.ts +++ b/packages/nuxt3/src/config/options.ts @@ -7,9 +7,9 @@ import pick from 'lodash/pick' import uniq from 'lodash/uniq' import destr from 'destr' import { TARGETS, MODES, guardDir, isNonEmptyString, isPureObject, isUrl, getMainModule, urlJoin, getPKG } from 'src/utils' +import type { EnvConfig } from 'src/config/load' import { DefaultConfiguration, defaultNuxtConfigFile, getDefaultNuxtConfig } from './config' import { deleteProp, mergeConfigs, setProp, overrideProp, Optional } from './transformers' -import type { EnvConfig } from 'src/config/load' interface InputConfiguration { appTemplatePath?: string @@ -39,7 +39,7 @@ export interface CliConfiguration extends Configuration { _nuxtConfigFiles?: string[] } -export function getNuxtConfig(_options: Configuration) { +export function getNuxtConfig (_options: Configuration) { // Prevent duplicate calls if ('__normalized__' in _options) { return _options @@ -48,7 +48,7 @@ export function getNuxtConfig(_options: Configuration) { return normalizeConfig(_options as CliConfiguration) } -function normalizeConfig(_options: CliConfiguration) { +function normalizeConfig (_options: CliConfiguration) { // Clone options to prevent unwanted side-effects const _config: CliConfiguration = Object.assign({}, _options) @@ -382,7 +382,6 @@ function normalizeConfig(_options: CliConfiguration) { overrideProp(options.server, 'timing', { total: true, ...options.server.timing }) } - overrideProp(options, 'serverMiddleware', Array.isArray(options.serverMiddleware) ? options.serverMiddleware : Object.entries(options.serverMiddleware) .map(([path, handler]) => ({ path, handler })) ) diff --git a/packages/nuxt3/src/config/transformers.ts b/packages/nuxt3/src/config/transformers.ts index 87d81ba87e..1016055f3c 100644 --- a/packages/nuxt3/src/config/transformers.ts +++ b/packages/nuxt3/src/config/transformers.ts @@ -4,20 +4,20 @@ export type Optional = { -readonly [K in keyof T]?: T[K] extends Function ? T[K] : T[K] extends RegExp ? T[K] : T[K] extends Promise ? T[K] : T[K] extends Array ? Array : Optional } -export function setProp, K extends string, V>(obj: O, key: K, value: V): asserts obj is O & { [key in K]: V } { - (obj as { [key in K]: V })[key] = value +export function setProp, K extends string, V> (obj: O, key: K, value: V): asserts obj is O & { [key in K]: V } { + (obj as { [key in K]: V })[key] = value } type Override, K extends keyof O, V> = K extends Array ? { [P in keyof O]: K extends P ? O[P] extends Array ? Array : K | O[P] : O[P] } : O & { [key in K]: V } -export function overrideProp, K extends keyof O, V>(obj: O, key: K, value: V): asserts obj is Override { - (obj as { [key in K]: V })[key] = value +export function overrideProp, K extends keyof O, V> (obj: O, key: K, value: V): asserts obj is Override { + (obj as { [key in K]: V })[key] = value } -export function deleteProp, K extends string>(obj: O, key: K): asserts obj is Exclude { - delete obj[key] +export function deleteProp, K extends string> (obj: O, key: K): asserts obj is Exclude { + delete obj[key] } type MergeArrays = S extends Array ? T extends Array ? Array : T | Array : T | S @@ -33,6 +33,6 @@ type Merge = S extends Array ? MergeArrays : S extends Function // T extends Array ? Array> : T -export function mergeConfigs, Source extends Record>(dest: Dest, source: Source): Merge { - return defaultsDeep(dest, source) -} \ No newline at end of file +export function mergeConfigs, Source extends Record> (dest: Dest, source: Source): Merge { + return defaultsDeep(dest, source) +} diff --git a/packages/nuxt3/src/core/module.ts b/packages/nuxt3/src/core/module.ts index 56b4896f35..fd5c9fbcc5 100644 --- a/packages/nuxt3/src/core/module.ts +++ b/packages/nuxt3/src/core/module.ts @@ -6,8 +6,8 @@ import consola from 'consola' import type { NormalizedConfiguration } from 'src/config' import { chainFn, sequence } from 'src/utils' -import Nuxt from './nuxt' import type { NuxtModule, ModuleHandler } from 'src/config/config/_common' +import Nuxt from './nuxt' interface TemplateInput { filename?: string @@ -27,7 +27,7 @@ export default class ModuleContainer { handler: ModuleHandler }> - constructor(nuxt: Nuxt) { + constructor (nuxt: Nuxt) { this.nuxt = nuxt this.options = nuxt.options this.requiredModules = {} @@ -40,7 +40,7 @@ export default class ModuleContainer { } } - async ready() { + async ready () { // Call before hook await this.nuxt.callHook('modules:before', this, this.options.modules) @@ -59,11 +59,11 @@ export default class ModuleContainer { await this.nuxt.callHook('modules:done', this) } - addVendor() { + addVendor () { consola.warn('addVendor has been deprecated due to webpack4 optimization') } - addTemplate(template: TemplateInput | string) { + addTemplate (template: TemplateInput | string) { if (!template) { throw new Error('Invalid template: ' + JSON.stringify(template)) } @@ -92,7 +92,7 @@ export default class ModuleContainer { return templateObj } - addPlugin(template: TemplateInput) { + addPlugin (template: TemplateInput) { const { dst } = this.addTemplate(template) // Add to nuxt plugins @@ -104,7 +104,7 @@ export default class ModuleContainer { }) } - addLayout(template: TemplateInput, name: string) { + addLayout (template: TemplateInput, name: string) { const { dst, src } = this.addTemplate(template) const layoutName = name || path.parse(src).name const layout = this.options.layouts[layoutName] @@ -122,31 +122,31 @@ export default class ModuleContainer { } } - addErrorLayout(dst: string) { + addErrorLayout (dst: string) { const relativeBuildDir = path.relative(this.options.rootDir, this.options.buildDir) this.options.ErrorPage = `~/${relativeBuildDir}/${dst}` } - addServerMiddleware(middleware: NormalizedConfiguration['serverMiddleware'][number]) { + addServerMiddleware (middleware: NormalizedConfiguration['serverMiddleware'][number]) { this.options.serverMiddleware.push(middleware) } - extendBuild(fn: NormalizedConfiguration['build']['extend']) { + extendBuild (fn: NormalizedConfiguration['build']['extend']) { this.options.build.extend = chainFn(this.options.build.extend, fn) } - extendRoutes(fn: NormalizedConfiguration['router']['extendRoutes']) { + extendRoutes (fn: NormalizedConfiguration['router']['extendRoutes']) { this.options.router.extendRoutes = chainFn( this.options.router.extendRoutes, fn ) } - requireModule(moduleOpts: NuxtModule) { + requireModule (moduleOpts: NuxtModule) { return this.addModule(moduleOpts) } - async addModule(moduleOpts: NuxtModule) { + async addModule (moduleOpts: NuxtModule) { let src: string | ModuleHandler let options: Record let handler: ModuleHandler | ModuleHandler & { meta: { name: string } } diff --git a/packages/nuxt3/src/core/nuxt.ts b/packages/nuxt3/src/core/nuxt.ts index 9157ca457b..fcac0aee84 100644 --- a/packages/nuxt3/src/core/nuxt.ts +++ b/packages/nuxt3/src/core/nuxt.ts @@ -28,7 +28,7 @@ export default class Nuxt extends Hookable { render?: Server['app'] showReady?: () => void - constructor(options: Configuration = {}) { + constructor (options: Configuration = {}) { super(consola) // Assign options and apply defaults @@ -70,18 +70,18 @@ export default class Nuxt extends Hookable { } } - static get version() { + static get version () { return `v${version}` + (global.__NUXT_DEV__ ? '-development' : '') } - ready() { + ready () { if (!this._ready) { this._ready = this._init() } return this._ready } - async _init() { + async _init () { if (this._initCalled) { return this } @@ -108,7 +108,7 @@ export default class Nuxt extends Hookable { return this } - _initServer() { + _initServer () { if (this.server) { return } @@ -118,7 +118,7 @@ export default class Nuxt extends Hookable { defineAlias(this, this.server, ['renderRoute', 'renderAndGetWindow', 'listen']) } - async close(callback?: () => any | Promise) { + async close (callback?: () => any | Promise) { await this.callHook('close', this) if (typeof callback === 'function') { diff --git a/packages/nuxt3/src/core/resolver.ts b/packages/nuxt3/src/core/resolver.ts index 5d247f580f..3d0b428fe0 100644 --- a/packages/nuxt3/src/core/resolver.ts +++ b/packages/nuxt3/src/core/resolver.ts @@ -128,7 +128,7 @@ export default class Resolver { throw new Error(`Cannot resolve "${path}" from "${resolvedPath}"`) } - requireModule (path: string, { useESM, isAlias, interopDefault }: RequireModuleOptions = {}): T { + requireModule (path: string, { useESM, isAlias, interopDefault }: RequireModuleOptions = {}): T { let resolvedPath = path let requiredModule: any diff --git a/packages/nuxt3/src/generator/generator.ts b/packages/nuxt3/src/generator/generator.ts index 778f513b66..51a520ab64 100644 --- a/packages/nuxt3/src/generator/generator.ts +++ b/packages/nuxt3/src/generator/generator.ts @@ -31,7 +31,7 @@ export default class Generator { routes: Array<{ route: string } & Record> generatedRoutes: Set - constructor(nuxt: Nuxt, builder?: Builder) { + constructor (nuxt: Nuxt, builder?: Builder) { this.nuxt = nuxt this.options = nuxt.options this.builder = builder @@ -53,7 +53,7 @@ export default class Generator { } } - async generate({ build = true, init = true } = {}) { + async generate ({ build = true, init = true } = {}) { consola.debug('Initializing generator...') await this.initiate({ build, init }) @@ -80,7 +80,7 @@ export default class Generator { return { errors } } - async initiate({ build = true, init = true } = {}) { + async initiate ({ build = true, init = true } = {}) { // Wait for nuxt be ready await this.nuxt.ready() @@ -119,7 +119,7 @@ export default class Generator { } } - async initRoutes(...args) { + async initRoutes (...args) { // Resolve config.generate.routes promises before generating the routes let generateRoutes = [] if (this.options.router.mode !== 'hash') { @@ -150,7 +150,7 @@ export default class Generator { return routes } - shouldGenerateRoute(route) { + shouldGenerateRoute (route) { return this.options.generate.exclude.every((regex) => { if (typeof regex === 'string') { return regex !== route @@ -159,7 +159,7 @@ export default class Generator { }) } - getBuildConfig() { + getBuildConfig () { try { return require(path.join(this.options.buildDir, 'nuxt/config.json')) } catch (err) { @@ -167,11 +167,11 @@ export default class Generator { } } - getAppRoutes() { + getAppRoutes () { return require(path.join(this.options.buildDir, 'routes.json')) } - async generateRoutes(routes) { + async generateRoutes (routes) { const errors = [] this.routes = [] @@ -204,7 +204,7 @@ export default class Generator { return errors } - _formatErrors(errors) { + _formatErrors (errors) { return errors .map(({ type, route, error }) => { const isHandled = type === 'handled' @@ -223,7 +223,7 @@ export default class Generator { .join('\n') } - async afterGenerate() { + async afterGenerate () { const { fallback } = this.options.generate // Disable SPA fallback if value isn't a non-empty string @@ -255,7 +255,7 @@ export default class Generator { consola.success('Client-side fallback created: `' + fallback + '`') } - async initDist() { + async initDist () { // Clean destination folder await fsExtra.emptyDir(this.distPath) @@ -283,7 +283,7 @@ export default class Generator { await this.nuxt.callHook('export:distCopied', this) } - decorateWithPayloads(routes, generateRoutes) { + decorateWithPayloads (routes, generateRoutes) { const routeMap = {} // Fill routeMap for known routes routes.forEach((route) => { @@ -301,7 +301,7 @@ export default class Generator { return Object.values(routeMap) } - async generateRoute({ route, payload = {}, errors = [] }) { + async generateRoute ({ route, payload = {}, errors = [] }) { let html const pageErrors = [] @@ -415,7 +415,7 @@ export default class Generator { return true } - minifyHtml(html: string) { + minifyHtml (html: string) { const minificationOptions = this.options.build.html.minify if (!minificationOptions) { diff --git a/packages/nuxt3/src/server/server.ts b/packages/nuxt3/src/server/server.ts index b7cd219fab..f44d5f6972 100644 --- a/packages/nuxt3/src/server/server.ts +++ b/packages/nuxt3/src/server/server.ts @@ -43,6 +43,7 @@ export default class Server { spaTemplate?: TemplateExecutor errorTemplate?: TemplateExecutor } + serverContext: ServerContext constructor (nuxt: Nuxt) { diff --git a/packages/nuxt3/src/utils/constants.ts b/packages/nuxt3/src/utils/constants.ts index 9195fd516f..4bf394035d 100644 --- a/packages/nuxt3/src/utils/constants.ts +++ b/packages/nuxt3/src/utils/constants.ts @@ -10,4 +10,4 @@ export const MODES = { spa: 'spa' } as const -export type Mode = keyof typeof MODES \ No newline at end of file +export type Mode = keyof typeof MODES diff --git a/packages/nuxt3/src/utils/resolve.ts b/packages/nuxt3/src/utils/resolve.ts index 976d0aec51..2da6686cb6 100644 --- a/packages/nuxt3/src/utils/resolve.ts +++ b/packages/nuxt3/src/utils/resolve.ts @@ -67,7 +67,7 @@ interface AliasOptions { warn?: boolean } -export function defineAlias >( +export function defineAlias > ( src: O, target: Record, prop: string | string[], diff --git a/packages/nuxt3/src/utils/route.ts b/packages/nuxt3/src/utils/route.ts index 65e4e4f7ea..3df421c656 100644 --- a/packages/nuxt3/src/utils/route.ts +++ b/packages/nuxt3/src/utils/route.ts @@ -49,7 +49,7 @@ function cleanChildrenRoutes (routes: NuxtRouteConfig[], isChild = false, routeN routes.forEach((route) => { route.path = isChild ? route.path.replace('/', '') : route.path if (route.path.includes('?')) { - const names = typeof route.name === 'string' && route.name.split(routeNameSplitter) || [] + const names = typeof route.name === 'string' && route.name.split(routeNameSplitter) || [] const paths = route.path.split('/') if (!isChild) { paths.shift() diff --git a/packages/nuxt3/src/utils/timer.ts b/packages/nuxt3/src/utils/timer.ts index 5e822d7006..2d3b2e6c70 100644 --- a/packages/nuxt3/src/utils/timer.ts +++ b/packages/nuxt3/src/utils/timer.ts @@ -15,7 +15,7 @@ async function promiseFinally ( return result } -export const timeout = function timeout ( +export const timeout = function timeout ( fn: Promise, ms: number, msg: string diff --git a/packages/nuxt3/src/vue-renderer/renderer.ts b/packages/nuxt3/src/vue-renderer/renderer.ts index c1aae5dd08..cb6d1fcf44 100644 --- a/packages/nuxt3/src/vue-renderer/renderer.ts +++ b/packages/nuxt3/src/vue-renderer/renderer.ts @@ -4,10 +4,10 @@ import consola from 'consola' import template from 'lodash/template' import { TARGETS, isModernRequest, waitFor } from 'src/utils' +import ServerContext from 'src/server/context' import SPARenderer from './renderers/spa' import SSRRenderer from './renderers/ssr' import ModernRenderer from './renderers/modern' -import ServerContext from 'src/server/context' export default class VueRenderer { __closed?: boolean diff --git a/packages/nuxt3/src/vue-renderer/renderers/base.ts b/packages/nuxt3/src/vue-renderer/renderers/base.ts index 693fd5cb28..dfb369fac0 100644 --- a/packages/nuxt3/src/vue-renderer/renderers/base.ts +++ b/packages/nuxt3/src/vue-renderer/renderers/base.ts @@ -1,4 +1,4 @@ -import ServerContext from "nuxt/server/context" +import ServerContext from 'nuxt/server/context' export default class BaseRenderer { serverContext: ServerContext diff --git a/packages/nuxt3/src/webpack/config/base.ts b/packages/nuxt3/src/webpack/config/base.ts index 2372899100..df719889ae 100644 --- a/packages/nuxt3/src/webpack/config/base.ts +++ b/packages/nuxt3/src/webpack/config/base.ts @@ -258,7 +258,7 @@ export default class WebpackBaseConfig { alias () { return { ...this.buildContext.options.alias, - 'app': this.buildContext.options.appDir, + app: this.buildContext.options.appDir, 'nuxt-build': this.buildContext.options.buildDir, 'vue-meta': require.resolve(`vue-meta${this.isServer ? '' : '/dist/vue-meta.esm.browser.js'}`) }