diff --git a/packages/nuxt3/src/builder/app.ts b/packages/nuxt3/src/builder/app.ts index afcac3c9fe..cc04222743 100644 --- a/packages/nuxt3/src/builder/app.ts +++ b/packages/nuxt3/src/builder/app.ts @@ -4,7 +4,7 @@ import { Builder } from './builder' import { NuxtRoute, resolvePagesRoutes } from './pages' import { NuxtPlugin, resolvePlugins } from './plugins' export interface NuxtApp { - main: string + main?: string routes: NuxtRoute[] dir: string extensions: string[] diff --git a/packages/nuxt3/src/builder/webpack/configs/client.ts b/packages/nuxt3/src/builder/webpack/configs/client.ts index 8cd110b5d3..db1ffde384 100644 --- a/packages/nuxt3/src/builder/webpack/configs/client.ts +++ b/packages/nuxt3/src/builder/webpack/configs/client.ts @@ -2,6 +2,8 @@ import path from 'path' import querystring from 'querystring' import webpack from 'webpack' import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer' +import type { ClientOptions } from 'webpack-hot-middleware' + import { applyPresets, WebpackConfigContext } from '../utils/config' import { nuxt } from '../presets/nuxt' @@ -47,14 +49,14 @@ function clientHMR (ctx: WebpackConfigContext) { return } - const clientOptions = options.build.hotMiddleware?.client || {} + const clientOptions = options.build.hotMiddleware?.client || {} as ClientOptions const hotMiddlewareClientOptions = { reload: true, timeout: 30000, - ansiColors: JSON.stringify(clientOptions.ansiColors || {}), - overlayStyles: JSON.stringify(clientOptions.overlayStyles || {}), path: `${options.router.base}/__webpack_hmr/${ctx.name}`.replace(/\/\//g, '/'), ...clientOptions, + ansiColors: JSON.stringify(clientOptions.ansiColors || {}), + overlayStyles: JSON.stringify(clientOptions.overlayStyles || {}), name: ctx.name } const hotMiddlewareClientOptionsStr = querystring.stringify(hotMiddlewareClientOptions) diff --git a/packages/nuxt3/src/builder/webpack/plugins/externals.ts b/packages/nuxt3/src/builder/webpack/plugins/externals.ts index e1b951fc81..704917c39e 100644 --- a/packages/nuxt3/src/builder/webpack/plugins/externals.ts +++ b/packages/nuxt3/src/builder/webpack/plugins/externals.ts @@ -31,7 +31,7 @@ function readDir (dirName) { } return module }) - .reduce(function (prev, next) { + .reduce(function (prev, next) { return prev.concat(next) }, []) } catch (e) { diff --git a/packages/nuxt3/src/builder/webpack/plugins/warning-ignore.ts b/packages/nuxt3/src/builder/webpack/plugins/warning-ignore.ts index b61901778c..d111997a78 100644 --- a/packages/nuxt3/src/builder/webpack/plugins/warning-ignore.ts +++ b/packages/nuxt3/src/builder/webpack/plugins/warning-ignore.ts @@ -1,4 +1,7 @@ +import { WebpackError } from 'webpack' export default class WarningIgnorePlugin { + filter: (warn: WebpackError) => boolean + constructor (filter) { this.filter = filter } diff --git a/packages/nuxt3/src/builder/webpack/utils/index.ts b/packages/nuxt3/src/builder/webpack/utils/index.ts index 2daa4f2283..338d7a6a30 100644 --- a/packages/nuxt3/src/builder/webpack/utils/index.ts +++ b/packages/nuxt3/src/builder/webpack/utils/index.ts @@ -1,2 +1 @@ -export { default as StyleLoader } from './style-loader' export { reservedVueTags } from './reserved-tags' diff --git a/packages/nuxt3/src/builder/webpack/utils/mfs.ts b/packages/nuxt3/src/builder/webpack/utils/mfs.ts index 03eb031ae9..2f55362e6d 100644 --- a/packages/nuxt3/src/builder/webpack/utils/mfs.ts +++ b/packages/nuxt3/src/builder/webpack/utils/mfs.ts @@ -2,12 +2,14 @@ import path from 'path' import pify from 'pify' import { Volume, createFsFromVolume } from 'memfs' +import type { IFs } from 'memfs' + export function createMFS () { // Create a new volume const fs = createFsFromVolume(new Volume()) // Clone to extend - const _fs = { ...fs } + const _fs : Partial & { join?(...paths: string[]): string } = { ...fs } // fs.join method is (still) expected by webpack-dev-middleware // There might be differences with https://github.com/webpack/memory-fs/blob/master/lib/join.js diff --git a/packages/nuxt3/src/config/config/_common.ts b/packages/nuxt3/src/config/config/_common.ts index 28cd98c699..caac58a06f 100644 --- a/packages/nuxt3/src/config/config/_common.ts +++ b/packages/nuxt3/src/config/config/_common.ts @@ -81,6 +81,7 @@ export type NuxtModule = string | ModuleHandler | [string | ModuleHandler, any] export type ServerMiddleware = string | { path: string, prefix?: boolean, handler: string | express.NextFunction } | express.NextFunction interface CommonConfiguration { + _majorVersion: Number _modules: NuxtModule[] _nuxtConfigFile?: string alias: Record @@ -129,6 +130,7 @@ interface CommonConfiguration { } export default (): CommonConfiguration => ({ + _majorVersion: undefined, // Env dev: Boolean(env.dev), test: Boolean(env.test), @@ -170,6 +172,7 @@ export default (): CommonConfiguration => ({ _nuxtConfigFile: undefined, srcDir: undefined, buildDir: '.nuxt', + vite: false, modulesDir: [ 'node_modules' ], diff --git a/packages/nuxt3/src/config/config/router.ts b/packages/nuxt3/src/config/config/router.ts index 4b809a437c..f7228ae837 100644 --- a/packages/nuxt3/src/config/config/router.ts +++ b/packages/nuxt3/src/config/config/router.ts @@ -1,4 +1,4 @@ -import { RouteRecordRaw, ScrollBehavior } from 'vue-router' +import { RouteRecordRaw, RouterScrollBehavior } from 'vue-router' type UnionToIntersection = (T extends any ? (k: T) => void : never) extends ((k: infer U) => void) ? U : never type RouteConfig = UnionToIntersection @@ -25,7 +25,7 @@ export interface RouterConfigurationNormalized { prefetchPayloads: boolean routes: Route[] routeNameSplitter: string - scrollBehavior: null | ScrollBehavior + scrollBehavior: null | RouterScrollBehavior stringifyQuery: boolean trailingSlash?: boolean }