nuxt-nightly 4.2.0-29336619.cf102e88 → 4.2.0-29344147.7bcc4ca3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/composables/payload.js +1 -1
- package/dist/app/types/augments.d.ts +0 -26
- package/dist/app/types.d.ts +35 -2
- package/dist/index.mjs +30 -770
- package/package.json +6 -13
- package/types.d.mts +1 -38
- package/types.d.ts +1 -38
- package/dist/core/runtime/nitro/handlers/error.d.ts +0 -3
- package/dist/core/runtime/nitro/handlers/error.js +0 -63
- package/dist/core/runtime/nitro/handlers/island.d.ts +0 -4
- package/dist/core/runtime/nitro/handlers/island.js +0 -100
- package/dist/core/runtime/nitro/handlers/renderer.d.ts +0 -16
- package/dist/core/runtime/nitro/handlers/renderer.js +0 -237
- package/dist/core/runtime/nitro/middleware/no-ssr.d.ts +0 -2
- package/dist/core/runtime/nitro/middleware/no-ssr.js +0 -7
- package/dist/core/runtime/nitro/plugins/dev-server-logs.d.ts +0 -3
- package/dist/core/runtime/nitro/plugins/dev-server-logs.js +0 -82
- package/dist/core/runtime/nitro/templates/error-500.d.ts +0 -2
- package/dist/core/runtime/nitro/templates/error-500.js +0 -6
- package/dist/core/runtime/nitro/utils/app-config.d.ts +0 -2
- package/dist/core/runtime/nitro/utils/app-config.js +0 -25
- package/dist/core/runtime/nitro/utils/cache-driver.d.ts +0 -2
- package/dist/core/runtime/nitro/utils/cache-driver.js +0 -34
- package/dist/core/runtime/nitro/utils/cache.d.ts +0 -8
- package/dist/core/runtime/nitro/utils/cache.js +0 -18
- package/dist/core/runtime/nitro/utils/config.d.ts +0 -1
- package/dist/core/runtime/nitro/utils/config.js +0 -1
- package/dist/core/runtime/nitro/utils/dev.d.ts +0 -1
- package/dist/core/runtime/nitro/utils/dev.js +0 -328
- package/dist/core/runtime/nitro/utils/error.d.ts +0 -6
- package/dist/core/runtime/nitro/utils/error.js +0 -11
- package/dist/core/runtime/nitro/utils/paths.d.ts +0 -4
- package/dist/core/runtime/nitro/utils/paths.js +0 -16
- package/dist/core/runtime/nitro/utils/renderer/app.d.ts +0 -7
- package/dist/core/runtime/nitro/utils/renderer/app.js +0 -32
- package/dist/core/runtime/nitro/utils/renderer/build-files.d.ts +0 -22
- package/dist/core/runtime/nitro/utils/renderer/build-files.js +0 -86
- package/dist/core/runtime/nitro/utils/renderer/inline-styles.d.ts +0 -2
- package/dist/core/runtime/nitro/utils/renderer/inline-styles.js +0 -13
- package/dist/core/runtime/nitro/utils/renderer/islands.d.ts +0 -36
- package/dist/core/runtime/nitro/utils/renderer/islands.js +0 -82
- package/dist/core/runtime/nitro/utils/renderer/payload.d.ts +0 -37
- package/dist/core/runtime/nitro/utils/renderer/payload.js +0 -66
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import fs, { promises, existsSync, readdirSync, statSync,
|
|
1
|
+
import fs, { promises, existsSync, readdirSync, statSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { mkdir, readFile, readdir, writeFile, rm, stat, unlink, open } from 'node:fs/promises';
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
4
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
5
5
|
import { dirname, resolve, normalize, basename, extname, relative, isAbsolute, join } from 'pathe';
|
|
6
6
|
import { createHooks, createDebugger } from 'hookable';
|
|
7
7
|
import ignore from 'ignore';
|
|
8
|
-
import { useLogger, tryUseNuxt, useNuxt, directoryToURL, getLayerDirectories, resolveFiles, resolvePath, defineNuxtModule, findPath, addPlugin, addTemplate, addTypeTemplate, addComponent, useNitro, addBuildPlugin, isIgnored, resolveAlias as resolveAlias$1, addPluginTemplate, addImportsSources, addVitePlugin, createIsIgnored, updateTemplates, tryResolveModule, normalizeModuleTranspilePath,
|
|
8
|
+
import { useLogger, tryUseNuxt, useNuxt, directoryToURL, getLayerDirectories, resolveFiles, resolvePath, defineNuxtModule, findPath, addPlugin, addTemplate, addTypeTemplate, addComponent, useNitro, addBuildPlugin, isIgnored, resolveAlias as resolveAlias$1, addPluginTemplate, addImportsSources, addVitePlugin, createIsIgnored, updateTemplates, tryResolveModule, normalizeModuleTranspilePath, importModule, createResolver, tryImportModule, runWithNuxtContext, nuxtCtx, loadNuxtConfig, addWebpackPlugin, installModules, resolveIgnorePatterns, addRouteMiddleware, resolveModuleWithOptions, normalizeTemplate, normalizePlugin } from '@nuxt/kit';
|
|
9
9
|
import { resolvePackageJSON, readPackage, readPackageJSON } from 'pkg-types';
|
|
10
10
|
import { hash, isEqual, serialize } from 'ohash';
|
|
11
11
|
import consola, { consola as consola$1 } from 'consola';
|
|
@@ -17,14 +17,14 @@ import { withTrailingSlash as withTrailingSlash$1, parseURL, parseQuery, joinURL
|
|
|
17
17
|
import { ImpoundPlugin } from 'impound';
|
|
18
18
|
import defu$1, { defu } from 'defu';
|
|
19
19
|
import { satisfies, coerce } from 'semver';
|
|
20
|
-
import { isCI, provider,
|
|
20
|
+
import { isCI, provider, hasTTY } from 'std-env';
|
|
21
21
|
import { genArrayFromRaw, genSafeVariableName, genImport, genDynamicImport, genObjectFromRawEntries, genString, genExport } from 'knitwork';
|
|
22
22
|
import { resolveModulePath } from 'exsolve';
|
|
23
23
|
import { addDependency } from 'nypm';
|
|
24
24
|
import { reverseResolveAlias, filename, resolveAlias } from 'pathe/utils';
|
|
25
25
|
import { createRoutesContext } from 'unplugin-vue-router';
|
|
26
26
|
import { resolveOptions } from 'unplugin-vue-router/options';
|
|
27
|
-
import { toRouteMatcher, createRouter
|
|
27
|
+
import { toRouteMatcher, createRouter } from 'radix3';
|
|
28
28
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
29
29
|
import { runInNewContext } from 'node:vm';
|
|
30
30
|
import { klona } from 'klona';
|
|
@@ -42,9 +42,6 @@ import { parse, walk as walk$1, ELEMENT_NODE } from 'ultrahtml';
|
|
|
42
42
|
import { isObject } from '@vue/shared';
|
|
43
43
|
import { parseQuery as parseQuery$1 } from 'vue-router';
|
|
44
44
|
import { createTransformer } from 'unctx/transform';
|
|
45
|
-
import { cpus } from 'node:os';
|
|
46
|
-
import { createNitro, scanHandlers, writeTypes, copyPublicAssets, prepare, build as build$1, prerender, createDevServer } from 'nitropack';
|
|
47
|
-
import { dynamicEventHandler, defineEventHandler } from 'h3';
|
|
48
45
|
import { watch as watch$1 } from 'chokidar';
|
|
49
46
|
import { debounce } from 'perfect-debounce';
|
|
50
47
|
import { resolveSchema, generateTypes } from 'untyped';
|
|
@@ -2842,7 +2839,7 @@ function TransformPlugin$1(nuxt, options) {
|
|
|
2842
2839
|
if (!code.includes("#components")) {
|
|
2843
2840
|
return;
|
|
2844
2841
|
}
|
|
2845
|
-
const pkg = isAbsolute(id) &&
|
|
2842
|
+
const pkg = isAbsolute(id) && /node_modules[\\/](?!\.virtual)/.test(id) ? await readPackage(id, { try: true }) : void 0;
|
|
2846
2843
|
if (isObject(pkg) && isObject(pkg.imports) && Object.hasOwn(pkg.imports, "#components")) {
|
|
2847
2844
|
return;
|
|
2848
2845
|
}
|
|
@@ -3595,7 +3592,7 @@ function normalizeDirs(dir, cwd, options) {
|
|
|
3595
3592
|
return normalizedDirs.sort(compareDirByPathLength);
|
|
3596
3593
|
}
|
|
3597
3594
|
|
|
3598
|
-
const NODE_MODULES_RE
|
|
3595
|
+
const NODE_MODULES_RE = /[\\/]node_modules[\\/]/;
|
|
3599
3596
|
const IMPORTS_RE = /(['"])#imports\1/;
|
|
3600
3597
|
const TransformPlugin = ({ ctx, options, sourcemap }) => createUnplugin(() => {
|
|
3601
3598
|
return {
|
|
@@ -3615,7 +3612,7 @@ const TransformPlugin = ({ ctx, options, sourcemap }) => createUnplugin(() => {
|
|
|
3615
3612
|
},
|
|
3616
3613
|
async transform(code, id) {
|
|
3617
3614
|
id = normalize(id);
|
|
3618
|
-
const isNodeModule = NODE_MODULES_RE
|
|
3615
|
+
const isNodeModule = NODE_MODULES_RE.test(id) && !options.transform?.include?.some((pattern) => pattern.test(id));
|
|
3619
3616
|
if (isNodeModule && !IMPORTS_RE.test(code)) {
|
|
3620
3617
|
return;
|
|
3621
3618
|
}
|
|
@@ -3831,9 +3828,9 @@ function addDeclarationTemplates(ctx, options) {
|
|
|
3831
3828
|
});
|
|
3832
3829
|
}
|
|
3833
3830
|
|
|
3834
|
-
const version = "4.2.0-
|
|
3831
|
+
const version = "4.2.0-29344147.7bcc4ca3";
|
|
3835
3832
|
|
|
3836
|
-
|
|
3833
|
+
function createImportProtectionPatterns(nuxt, options) {
|
|
3837
3834
|
const patterns = [];
|
|
3838
3835
|
const context = contextFlags[options.context];
|
|
3839
3836
|
patterns.push([
|
|
@@ -3866,7 +3863,7 @@ const createImportProtectionPatterns = (nuxt, options) => {
|
|
|
3866
3863
|
]);
|
|
3867
3864
|
}
|
|
3868
3865
|
return patterns;
|
|
3869
|
-
}
|
|
3866
|
+
}
|
|
3870
3867
|
const contextFlags = {
|
|
3871
3868
|
"nitro-app": "server runtime",
|
|
3872
3869
|
"nuxt-app": "the Vue part of your app",
|
|
@@ -4097,645 +4094,21 @@ const addModuleTranspiles = (nuxt) => {
|
|
|
4097
4094
|
}
|
|
4098
4095
|
};
|
|
4099
4096
|
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
};
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
verbose: 3
|
|
4108
|
-
};
|
|
4109
|
-
const NODE_MODULES_RE = /(?<=\/)node_modules\/(.+)$/;
|
|
4110
|
-
const PNPM_NODE_MODULES_RE = /\.pnpm\/.+\/node_modules\/(.+)$/;
|
|
4111
|
-
async function initNitro(nuxt) {
|
|
4112
|
-
const layerDirs = getLayerDirectories(nuxt);
|
|
4113
|
-
const excludePaths = [];
|
|
4114
|
-
for (const dirs of layerDirs) {
|
|
4115
|
-
const paths = [
|
|
4116
|
-
dirs.root.match(NODE_MODULES_RE)?.[1]?.replace(/\/$/, ""),
|
|
4117
|
-
dirs.root.match(PNPM_NODE_MODULES_RE)?.[1]?.replace(/\/$/, "")
|
|
4118
|
-
];
|
|
4119
|
-
for (const dir of paths) {
|
|
4120
|
-
if (dir) {
|
|
4121
|
-
excludePaths.push(escapeRE(dir));
|
|
4122
|
-
}
|
|
4123
|
-
}
|
|
4124
|
-
}
|
|
4125
|
-
const layerPublicAssetsDirs = [];
|
|
4126
|
-
for (const dirs of layerDirs) {
|
|
4127
|
-
if (existsSync(dirs.public)) {
|
|
4128
|
-
layerPublicAssetsDirs.push({ dir: dirs.public });
|
|
4129
|
-
}
|
|
4130
|
-
}
|
|
4131
|
-
const excludePattern = excludePaths.length ? [new RegExp(`node_modules\\/(?!${excludePaths.join("|")})`)] : [/node_modules/];
|
|
4132
|
-
const rootDirWithSlash = withTrailingSlash$1(nuxt.options.rootDir);
|
|
4133
|
-
const moduleEntryPaths = [];
|
|
4134
|
-
for (const m of nuxt.options._installedModules) {
|
|
4135
|
-
const path = m.meta?.rawPath || m.entryPath;
|
|
4136
|
-
if (path) {
|
|
4137
|
-
moduleEntryPaths.push(path);
|
|
4138
|
-
}
|
|
4139
|
-
}
|
|
4140
|
-
const modules = await resolveNuxtModule(rootDirWithSlash, moduleEntryPaths);
|
|
4141
|
-
const sharedDirs = /* @__PURE__ */ new Set();
|
|
4142
|
-
if (nuxt.options.nitro.imports !== false && nuxt.options.imports.scan !== false) {
|
|
4143
|
-
for (const layer of nuxt.options._layers) {
|
|
4144
|
-
if (layer.config?.imports?.scan === false) {
|
|
4145
|
-
continue;
|
|
4146
|
-
}
|
|
4147
|
-
sharedDirs.add(resolve(layer.config.rootDir, layer.config.dir?.shared ?? "shared", "utils"));
|
|
4148
|
-
sharedDirs.add(resolve(layer.config.rootDir, layer.config.dir?.shared ?? "shared", "types"));
|
|
4149
|
-
}
|
|
4150
|
-
}
|
|
4151
|
-
const mockProxy = resolveModulePath("mocked-exports/proxy", { from: import.meta.url });
|
|
4152
|
-
const nitroConfig = defu(nuxt.options.nitro, {
|
|
4153
|
-
debug: nuxt.options.debug ? nuxt.options.debug.nitro : false,
|
|
4154
|
-
rootDir: nuxt.options.rootDir,
|
|
4155
|
-
workspaceDir: nuxt.options.workspaceDir,
|
|
4156
|
-
srcDir: nuxt.options.serverDir,
|
|
4157
|
-
dev: nuxt.options.dev,
|
|
4158
|
-
buildDir: nuxt.options.buildDir,
|
|
4159
|
-
experimental: {
|
|
4160
|
-
asyncContext: nuxt.options.experimental.asyncContext,
|
|
4161
|
-
typescriptBundlerResolution: nuxt.options.future.typescriptBundlerResolution || nuxt.options.typescript?.tsConfig?.compilerOptions?.moduleResolution?.toLowerCase() === "bundler" || nuxt.options.nitro.typescript?.tsConfig?.compilerOptions?.moduleResolution?.toLowerCase() === "bundler"
|
|
4162
|
-
},
|
|
4163
|
-
framework: {
|
|
4164
|
-
name: "nuxt",
|
|
4165
|
-
version: version
|
|
4166
|
-
},
|
|
4167
|
-
imports: {
|
|
4168
|
-
autoImport: nuxt.options.imports.autoImport,
|
|
4169
|
-
dirs: [...sharedDirs],
|
|
4170
|
-
imports: [
|
|
4171
|
-
{
|
|
4172
|
-
as: "__buildAssetsURL",
|
|
4173
|
-
name: "buildAssetsURL",
|
|
4174
|
-
from: resolve(distDir, "core/runtime/nitro/utils/paths")
|
|
4175
|
-
},
|
|
4176
|
-
{
|
|
4177
|
-
as: "__publicAssetsURL",
|
|
4178
|
-
name: "publicAssetsURL",
|
|
4179
|
-
from: resolve(distDir, "core/runtime/nitro/utils/paths")
|
|
4180
|
-
},
|
|
4181
|
-
{
|
|
4182
|
-
// TODO: Remove after https://github.com/nitrojs/nitro/issues/1049
|
|
4183
|
-
as: "defineAppConfig",
|
|
4184
|
-
name: "defineAppConfig",
|
|
4185
|
-
from: resolve(distDir, "core/runtime/nitro/utils/config"),
|
|
4186
|
-
priority: -1
|
|
4187
|
-
}
|
|
4188
|
-
],
|
|
4189
|
-
exclude: [...excludePattern, /[\\/]\.git[\\/]/]
|
|
4190
|
-
},
|
|
4191
|
-
esbuild: {
|
|
4192
|
-
options: { exclude: excludePattern }
|
|
4193
|
-
},
|
|
4194
|
-
analyze: !nuxt.options.test && nuxt.options.build.analyze && (nuxt.options.build.analyze === true || nuxt.options.build.analyze.enabled) ? {
|
|
4195
|
-
template: "treemap",
|
|
4196
|
-
projectRoot: nuxt.options.rootDir,
|
|
4197
|
-
filename: join(nuxt.options.analyzeDir, "{name}.html")
|
|
4198
|
-
} : false,
|
|
4199
|
-
scanDirs: layerDirs.map((dirs) => dirs.server),
|
|
4200
|
-
renderer: resolve(distDir, "core/runtime/nitro/handlers/renderer"),
|
|
4201
|
-
nodeModulesDirs: nuxt.options.modulesDir,
|
|
4202
|
-
handlers: nuxt.options.serverHandlers,
|
|
4203
|
-
devHandlers: [],
|
|
4204
|
-
baseURL: nuxt.options.app.baseURL,
|
|
4205
|
-
virtual: {
|
|
4206
|
-
"#internal/nuxt.config.mjs": () => nuxt.vfs["#build/nuxt.config.mjs"] || "",
|
|
4207
|
-
"#internal/nuxt/app-config": () => nuxt.vfs["#build/app.config.mjs"]?.replace(/\/\*\* client \*\*\/[\s\S]*\/\*\* client-end \*\*\//, "") || "",
|
|
4208
|
-
"#spa-template": async () => `export const template = ${JSON.stringify(await spaLoadingTemplate(nuxt))}`,
|
|
4209
|
-
// this will be overridden in vite plugin
|
|
4210
|
-
"#internal/entry-chunk.mjs": () => `export const entryFileName = undefined`,
|
|
4211
|
-
"#internal/nuxt/entry-ids.mjs": () => `export default []`
|
|
4212
|
-
},
|
|
4213
|
-
routeRules: {
|
|
4214
|
-
"/__nuxt_error": { cache: false }
|
|
4215
|
-
},
|
|
4216
|
-
appConfig: nuxt.options.appConfig,
|
|
4217
|
-
appConfigFiles: layerDirs.map((dirs) => join(dirs.app, "app.config")),
|
|
4218
|
-
typescript: {
|
|
4219
|
-
strict: true,
|
|
4220
|
-
generateTsConfig: true,
|
|
4221
|
-
tsconfigPath: "tsconfig.server.json",
|
|
4222
|
-
tsConfig: {
|
|
4223
|
-
compilerOptions: {
|
|
4224
|
-
lib: ["esnext", "webworker", "dom.iterable"],
|
|
4225
|
-
skipLibCheck: true
|
|
4226
|
-
},
|
|
4227
|
-
include: [
|
|
4228
|
-
join(nuxt.options.buildDir, "types/nitro-nuxt.d.ts"),
|
|
4229
|
-
...modules.flatMap((m) => {
|
|
4230
|
-
const moduleDir = relativeWithDot(nuxt.options.buildDir, m);
|
|
4231
|
-
return [
|
|
4232
|
-
join(moduleDir, "runtime/server"),
|
|
4233
|
-
join(moduleDir, "dist/runtime/server")
|
|
4234
|
-
];
|
|
4235
|
-
}),
|
|
4236
|
-
...layerDirs.map((dirs) => relativeWithDot(nuxt.options.buildDir, join(dirs.shared, "**/*.d.ts")))
|
|
4237
|
-
],
|
|
4238
|
-
exclude: [
|
|
4239
|
-
...nuxt.options.modulesDir.map((m) => relativeWithDot(nuxt.options.buildDir, m)),
|
|
4240
|
-
// nitro generate output: https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/core/nitro.ts#L186
|
|
4241
|
-
relativeWithDot(nuxt.options.buildDir, resolve(nuxt.options.rootDir, "dist"))
|
|
4242
|
-
]
|
|
4243
|
-
}
|
|
4244
|
-
},
|
|
4245
|
-
publicAssets: [
|
|
4246
|
-
nuxt.options.dev ? { dir: resolve(nuxt.options.buildDir, "dist/client") } : {
|
|
4247
|
-
dir: join(nuxt.options.buildDir, "dist/client", nuxt.options.app.buildAssetsDir),
|
|
4248
|
-
maxAge: 31536e3,
|
|
4249
|
-
baseURL: nuxt.options.app.buildAssetsDir
|
|
4250
|
-
},
|
|
4251
|
-
...layerPublicAssetsDirs
|
|
4252
|
-
],
|
|
4253
|
-
prerender: {
|
|
4254
|
-
ignoreUnprefixedPublicAssets: true,
|
|
4255
|
-
failOnError: true,
|
|
4256
|
-
concurrency: cpus().length * 4 || 4,
|
|
4257
|
-
routes: [].concat(nuxt.options.generate.routes)
|
|
4258
|
-
},
|
|
4259
|
-
sourceMap: nuxt.options.sourcemap.server,
|
|
4260
|
-
externals: {
|
|
4261
|
-
inline: [
|
|
4262
|
-
...nuxt.options.dev ? [] : [
|
|
4263
|
-
...nuxt.options.experimental.externalVue ? [] : ["vue", "@vue/"],
|
|
4264
|
-
"@nuxt/",
|
|
4265
|
-
nuxt.options.buildDir
|
|
4266
|
-
],
|
|
4267
|
-
...nuxt.options.build.transpile.filter((i) => typeof i === "string"),
|
|
4268
|
-
"nuxt/dist",
|
|
4269
|
-
"nuxt3/dist",
|
|
4270
|
-
"nuxt-nightly/dist",
|
|
4271
|
-
distDir,
|
|
4272
|
-
// Ensure app config files have auto-imports injected even if they are pure .js files
|
|
4273
|
-
...layerDirs.map((dirs) => join(dirs.app, "app.config"))
|
|
4274
|
-
],
|
|
4275
|
-
traceInclude: [
|
|
4276
|
-
// force include files used in generated code from the runtime-compiler
|
|
4277
|
-
...nuxt.options.vue.runtimeCompiler && !nuxt.options.experimental.externalVue ? [
|
|
4278
|
-
...nuxt.options.modulesDir.reduce((targets, path) => {
|
|
4279
|
-
const serverRendererPath = resolve(path, "vue/server-renderer/index.js");
|
|
4280
|
-
if (existsSync(serverRendererPath)) {
|
|
4281
|
-
targets.push(serverRendererPath);
|
|
4282
|
-
}
|
|
4283
|
-
return targets;
|
|
4284
|
-
}, [])
|
|
4285
|
-
] : []
|
|
4286
|
-
]
|
|
4287
|
-
},
|
|
4288
|
-
alias: {
|
|
4289
|
-
// Vue 3 mocks
|
|
4290
|
-
...nuxt.options.vue.runtimeCompiler || nuxt.options.experimental.externalVue ? {} : {
|
|
4291
|
-
"estree-walker": mockProxy,
|
|
4292
|
-
"@babel/parser": mockProxy,
|
|
4293
|
-
"@vue/compiler-core": mockProxy,
|
|
4294
|
-
"@vue/compiler-dom": mockProxy,
|
|
4295
|
-
"@vue/compiler-ssr": mockProxy
|
|
4296
|
-
},
|
|
4297
|
-
"@vue/devtools-api": "vue-devtools-stub",
|
|
4298
|
-
// Nuxt aliases
|
|
4299
|
-
...nuxt.options.alias,
|
|
4300
|
-
// Paths
|
|
4301
|
-
"#internal/nuxt/paths": resolve(distDir, "core/runtime/nitro/utils/paths")
|
|
4302
|
-
},
|
|
4303
|
-
replace: {
|
|
4304
|
-
"process.env.NUXT_NO_SSR": String(nuxt.options.ssr === false),
|
|
4305
|
-
"process.env.NUXT_EARLY_HINTS": String(nuxt.options.experimental.writeEarlyHints !== false),
|
|
4306
|
-
"process.env.NUXT_NO_SCRIPTS": String(nuxt.options.features.noScripts === "all" || !!nuxt.options.features.noScripts && !nuxt.options.dev),
|
|
4307
|
-
"process.env.NUXT_INLINE_STYLES": String(!!nuxt.options.features.inlineStyles),
|
|
4308
|
-
"process.env.PARSE_ERROR_DATA": String(!!nuxt.options.experimental.parseErrorData),
|
|
4309
|
-
"process.env.NUXT_JSON_PAYLOADS": String(!!nuxt.options.experimental.renderJsonPayloads),
|
|
4310
|
-
"process.env.NUXT_ASYNC_CONTEXT": String(!!nuxt.options.experimental.asyncContext),
|
|
4311
|
-
"process.env.NUXT_SHARED_DATA": String(!!nuxt.options.experimental.sharedPrerenderData),
|
|
4312
|
-
"process.dev": String(nuxt.options.dev),
|
|
4313
|
-
"__VUE_PROD_DEVTOOLS__": String(false)
|
|
4314
|
-
},
|
|
4315
|
-
rollupConfig: {
|
|
4316
|
-
output: {
|
|
4317
|
-
generatedCode: {
|
|
4318
|
-
symbols: true
|
|
4319
|
-
// temporary fix for https://github.com/vuejs/core/issues/8351
|
|
4320
|
-
}
|
|
4321
|
-
},
|
|
4322
|
-
plugins: []
|
|
4323
|
-
},
|
|
4324
|
-
logLevel: logLevelMapReverse[nuxt.options.logLevel]
|
|
4325
|
-
});
|
|
4326
|
-
if (nuxt.options.experimental.serverAppConfig && nitroConfig.imports) {
|
|
4327
|
-
nitroConfig.imports.imports ||= [];
|
|
4328
|
-
nitroConfig.imports.imports.push({
|
|
4329
|
-
name: "useAppConfig",
|
|
4330
|
-
from: resolve(distDir, "core/runtime/nitro/utils/app-config"),
|
|
4331
|
-
priority: -1
|
|
4332
|
-
});
|
|
4333
|
-
}
|
|
4334
|
-
if (!nitroConfig.errorHandler && (nuxt.options.dev || !nuxt.options.experimental.noVueServer)) {
|
|
4335
|
-
nitroConfig.errorHandler = resolve(distDir, "core/runtime/nitro/handlers/error");
|
|
4336
|
-
}
|
|
4337
|
-
nitroConfig.srcDir = resolve(nuxt.options.rootDir, nuxt.options.srcDir, nitroConfig.srcDir);
|
|
4338
|
-
nitroConfig.ignore ||= [];
|
|
4339
|
-
nitroConfig.ignore.push(
|
|
4340
|
-
...resolveIgnorePatterns(nitroConfig.srcDir),
|
|
4341
|
-
`!${join(nuxt.options.buildDir, "dist/client", nuxt.options.app.buildAssetsDir, "**/*")}`
|
|
4342
|
-
);
|
|
4343
|
-
nitroConfig.plugins = nitroConfig.plugins?.map((plugin) => plugin ? resolveAlias$1(plugin, nuxt.options.alias) : plugin);
|
|
4344
|
-
if (nuxt.options.experimental.appManifest) {
|
|
4345
|
-
const buildId = nuxt.options.runtimeConfig.app.buildId ||= nuxt.options.buildId;
|
|
4346
|
-
const buildTimestamp = Date.now();
|
|
4347
|
-
const manifestPrefix = joinURL(nuxt.options.app.buildAssetsDir, "builds");
|
|
4348
|
-
const tempDir = join(nuxt.options.buildDir, "manifest");
|
|
4349
|
-
nitroConfig.prerender ||= {};
|
|
4350
|
-
nitroConfig.prerender.ignore ||= [];
|
|
4351
|
-
nitroConfig.prerender.ignore.push(joinURL(nuxt.options.app.baseURL, manifestPrefix));
|
|
4352
|
-
nitroConfig.publicAssets.unshift(
|
|
4353
|
-
// build manifest
|
|
4354
|
-
{
|
|
4355
|
-
dir: join(tempDir, "meta"),
|
|
4356
|
-
maxAge: 31536e3,
|
|
4357
|
-
baseURL: joinURL(manifestPrefix, "meta")
|
|
4358
|
-
},
|
|
4359
|
-
// latest build
|
|
4360
|
-
{
|
|
4361
|
-
dir: tempDir,
|
|
4362
|
-
maxAge: 1,
|
|
4363
|
-
baseURL: manifestPrefix
|
|
4364
|
-
}
|
|
4365
|
-
);
|
|
4366
|
-
nuxt.options.alias["#app-manifest"] = join(tempDir, `meta/${buildId}.json`);
|
|
4367
|
-
if (!nuxt.options.dev) {
|
|
4368
|
-
nuxt.hook("build:before", async () => {
|
|
4369
|
-
await promises.mkdir(join(tempDir, "meta"), { recursive: true });
|
|
4370
|
-
await promises.writeFile(join(tempDir, `meta/${buildId}.json`), JSON.stringify({}));
|
|
4371
|
-
});
|
|
4372
|
-
}
|
|
4373
|
-
nuxt.hook("nitro:config", (config) => {
|
|
4374
|
-
config.alias ||= {};
|
|
4375
|
-
config.alias["#app-manifest"] = join(tempDir, `meta/${buildId}.json`);
|
|
4376
|
-
const rules = config.routeRules;
|
|
4377
|
-
for (const rule in rules) {
|
|
4378
|
-
if (!rules[rule].appMiddleware) {
|
|
4379
|
-
continue;
|
|
4380
|
-
}
|
|
4381
|
-
const value = rules[rule].appMiddleware;
|
|
4382
|
-
if (typeof value === "string") {
|
|
4383
|
-
rules[rule].appMiddleware = { [value]: true };
|
|
4384
|
-
} else if (Array.isArray(value)) {
|
|
4385
|
-
const normalizedRules = {};
|
|
4386
|
-
for (const middleware of value) {
|
|
4387
|
-
normalizedRules[middleware] = true;
|
|
4388
|
-
}
|
|
4389
|
-
rules[rule].appMiddleware = normalizedRules;
|
|
4390
|
-
}
|
|
4391
|
-
}
|
|
4392
|
-
});
|
|
4393
|
-
nuxt.hook("nitro:init", (nitro2) => {
|
|
4394
|
-
nitro2.hooks.hook("rollup:before", async (nitro3) => {
|
|
4395
|
-
const routeRules = {};
|
|
4396
|
-
const _routeRules = nitro3.options.routeRules;
|
|
4397
|
-
const validManifestKeys = /* @__PURE__ */ new Set(["prerender", "redirect", "appMiddleware"]);
|
|
4398
|
-
for (const key in _routeRules) {
|
|
4399
|
-
if (key === "/__nuxt_error") {
|
|
4400
|
-
continue;
|
|
4401
|
-
}
|
|
4402
|
-
let hasRules = false;
|
|
4403
|
-
const filteredRules = {};
|
|
4404
|
-
for (const routeKey in _routeRules[key]) {
|
|
4405
|
-
const value = _routeRules[key][routeKey];
|
|
4406
|
-
if (value && validManifestKeys.has(routeKey)) {
|
|
4407
|
-
if (routeKey === "redirect") {
|
|
4408
|
-
filteredRules[routeKey] = typeof value === "string" ? value : value.to;
|
|
4409
|
-
} else {
|
|
4410
|
-
filteredRules[routeKey] = value;
|
|
4411
|
-
}
|
|
4412
|
-
hasRules = true;
|
|
4413
|
-
}
|
|
4414
|
-
}
|
|
4415
|
-
if (hasRules) {
|
|
4416
|
-
routeRules[key] = filteredRules;
|
|
4417
|
-
}
|
|
4418
|
-
}
|
|
4419
|
-
const prerenderedRoutes = /* @__PURE__ */ new Set();
|
|
4420
|
-
const routeRulesMatcher = toRouteMatcher(
|
|
4421
|
-
createRouter({ routes: routeRules })
|
|
4422
|
-
);
|
|
4423
|
-
if (nitro3._prerenderedRoutes?.length) {
|
|
4424
|
-
const payloadSuffix = nuxt.options.experimental.renderJsonPayloads ? "/_payload.json" : "/_payload.js";
|
|
4425
|
-
for (const route of nitro3._prerenderedRoutes) {
|
|
4426
|
-
if (!route.error && route.route.endsWith(payloadSuffix)) {
|
|
4427
|
-
const url = route.route.slice(0, -payloadSuffix.length) || "/";
|
|
4428
|
-
const rules = defu({}, ...routeRulesMatcher.matchAll(url).reverse());
|
|
4429
|
-
if (!rules.prerender) {
|
|
4430
|
-
prerenderedRoutes.add(url);
|
|
4431
|
-
}
|
|
4432
|
-
}
|
|
4433
|
-
}
|
|
4434
|
-
}
|
|
4435
|
-
const manifest = {
|
|
4436
|
-
id: buildId,
|
|
4437
|
-
timestamp: buildTimestamp,
|
|
4438
|
-
matcher: exportMatcher(routeRulesMatcher),
|
|
4439
|
-
prerendered: nuxt.options.dev ? [] : [...prerenderedRoutes]
|
|
4440
|
-
};
|
|
4441
|
-
await promises.mkdir(join(tempDir, "meta"), { recursive: true });
|
|
4442
|
-
await promises.writeFile(join(tempDir, "latest.json"), JSON.stringify({
|
|
4443
|
-
id: buildId,
|
|
4444
|
-
timestamp: buildTimestamp
|
|
4445
|
-
}));
|
|
4446
|
-
await promises.writeFile(join(tempDir, `meta/${buildId}.json`), JSON.stringify(manifest));
|
|
4447
|
-
});
|
|
4448
|
-
});
|
|
4449
|
-
}
|
|
4450
|
-
if (!nuxt.options.experimental.appManifest) {
|
|
4451
|
-
nuxt.options.alias["#app-manifest"] = mockProxy;
|
|
4452
|
-
}
|
|
4453
|
-
const FORWARD_SLASH_RE = /\//g;
|
|
4454
|
-
if (!nuxt.options.ssr) {
|
|
4455
|
-
nitroConfig.virtual["#build/dist/server/server.mjs"] = "export default () => {}";
|
|
4456
|
-
if (process.platform === "win32") {
|
|
4457
|
-
nitroConfig.virtual["#build/dist/server/server.mjs".replace(FORWARD_SLASH_RE, "\\")] = "export default () => {}";
|
|
4458
|
-
}
|
|
4459
|
-
}
|
|
4460
|
-
if (nuxt.options.dev || nuxt.options.builder === "@nuxt/webpack-builder" || nuxt.options.builder === "@nuxt/rspack-builder") {
|
|
4461
|
-
nitroConfig.virtual["#build/dist/server/styles.mjs"] = "export default {}";
|
|
4462
|
-
if (process.platform === "win32") {
|
|
4463
|
-
nitroConfig.virtual["#build/dist/server/styles.mjs".replace(FORWARD_SLASH_RE, "\\")] = "export default {}";
|
|
4464
|
-
}
|
|
4465
|
-
}
|
|
4466
|
-
nitroConfig.rollupConfig.plugins = await nitroConfig.rollupConfig.plugins || [];
|
|
4467
|
-
nitroConfig.rollupConfig.plugins = toArray(nitroConfig.rollupConfig.plugins);
|
|
4468
|
-
const sharedDir = withTrailingSlash$1(resolve(nuxt.options.rootDir, nuxt.options.dir.shared));
|
|
4469
|
-
const relativeSharedDir = withTrailingSlash$1(relative(nuxt.options.rootDir, resolve(nuxt.options.rootDir, nuxt.options.dir.shared)));
|
|
4470
|
-
const sharedPatterns = [/^#shared\//, new RegExp("^" + escapeRE(sharedDir)), new RegExp("^" + escapeRE(relativeSharedDir))];
|
|
4471
|
-
nitroConfig.rollupConfig.plugins.push(
|
|
4472
|
-
ImpoundPlugin.rollup({
|
|
4473
|
-
cwd: nuxt.options.rootDir,
|
|
4474
|
-
include: sharedPatterns,
|
|
4475
|
-
patterns: createImportProtectionPatterns(nuxt, { context: "shared" })
|
|
4476
|
-
}),
|
|
4477
|
-
ImpoundPlugin.rollup({
|
|
4478
|
-
cwd: nuxt.options.rootDir,
|
|
4479
|
-
patterns: createImportProtectionPatterns(nuxt, { context: "nitro-app" }),
|
|
4480
|
-
exclude: [/node_modules[\\/]nitro(?:pack)?(?:-nightly)?[\\/]|core[\\/]runtime[\\/]nitro[\\/](?:handlers|utils)/, ...sharedPatterns]
|
|
4481
|
-
})
|
|
4482
|
-
);
|
|
4483
|
-
const isIgnored = createIsIgnored(nuxt);
|
|
4484
|
-
nitroConfig.devStorage ??= {};
|
|
4485
|
-
nitroConfig.devStorage.root ??= {
|
|
4486
|
-
driver: "fs",
|
|
4487
|
-
readOnly: true,
|
|
4488
|
-
base: nitroConfig.rootDir,
|
|
4489
|
-
watchOptions: {
|
|
4490
|
-
ignored: [isIgnored]
|
|
4491
|
-
}
|
|
4492
|
-
};
|
|
4493
|
-
nitroConfig.devStorage.src ??= {
|
|
4494
|
-
driver: "fs",
|
|
4495
|
-
readOnly: true,
|
|
4496
|
-
base: nitroConfig.srcDir,
|
|
4497
|
-
watchOptions: {
|
|
4498
|
-
ignored: [isIgnored]
|
|
4499
|
-
}
|
|
4500
|
-
};
|
|
4501
|
-
await nuxt.callHook("nitro:config", nitroConfig);
|
|
4502
|
-
const excludedAlias = [/^@vue\/.*$/, "vue", /vue-router/, "vite/client", "#imports", "vue-demi", /^#app/, "~", "@", "~~", "@@"];
|
|
4503
|
-
const basePath = nitroConfig.typescript.tsConfig.compilerOptions?.baseUrl ? resolve(nuxt.options.buildDir, nitroConfig.typescript.tsConfig.compilerOptions?.baseUrl) : nuxt.options.buildDir;
|
|
4504
|
-
const aliases = nitroConfig.alias;
|
|
4505
|
-
const tsConfig = nitroConfig.typescript.tsConfig;
|
|
4506
|
-
tsConfig.compilerOptions ||= {};
|
|
4507
|
-
tsConfig.compilerOptions.paths ||= {};
|
|
4508
|
-
for (const _alias in aliases) {
|
|
4509
|
-
const alias = _alias;
|
|
4510
|
-
if (excludedAlias.some((pattern) => typeof pattern === "string" ? alias === pattern : pattern.test(alias))) {
|
|
4511
|
-
continue;
|
|
4512
|
-
}
|
|
4513
|
-
if (alias in tsConfig.compilerOptions.paths) {
|
|
4514
|
-
continue;
|
|
4515
|
-
}
|
|
4516
|
-
const absolutePath = resolve(basePath, aliases[alias]);
|
|
4517
|
-
const isDirectory = aliases[alias].endsWith("/") || await promises.stat(absolutePath).then((r) => r.isDirectory()).catch(
|
|
4518
|
-
() => null
|
|
4519
|
-
/* file does not exist */
|
|
4520
|
-
);
|
|
4521
|
-
tsConfig.compilerOptions.paths[alias] = [absolutePath];
|
|
4522
|
-
if (isDirectory) {
|
|
4523
|
-
tsConfig.compilerOptions.paths[`${alias}/*`] = [`${absolutePath}/*`];
|
|
4524
|
-
}
|
|
4525
|
-
}
|
|
4526
|
-
const nitro = await createNitro(nitroConfig, {
|
|
4527
|
-
compatibilityDate: nuxt.options.compatibilityDate,
|
|
4528
|
-
dotenv: nuxt.options._loadOptions?.dotenv
|
|
4529
|
-
});
|
|
4530
|
-
const spaLoadingTemplateFilePath = await spaLoadingTemplatePath(nuxt);
|
|
4531
|
-
nuxt.hook("builder:watch", async (_event, relativePath) => {
|
|
4532
|
-
const path = resolve(nuxt.options.srcDir, relativePath);
|
|
4533
|
-
if (path === spaLoadingTemplateFilePath) {
|
|
4534
|
-
await nitro.hooks.callHook("rollup:reload");
|
|
4535
|
-
}
|
|
4536
|
-
});
|
|
4537
|
-
const cacheDir = resolve(nuxt.options.buildDir, "cache/nitro/prerender");
|
|
4538
|
-
const cacheDriverPath = join(distDir, "core/runtime/nitro/utils/cache-driver.js");
|
|
4539
|
-
await promises.rm(cacheDir, { recursive: true, force: true }).catch(() => {
|
|
4540
|
-
});
|
|
4541
|
-
nitro.options._config.storage = defu(nitro.options._config.storage, {
|
|
4542
|
-
"internal:nuxt:prerender": {
|
|
4543
|
-
// TODO: resolve upstream where file URLs are not being resolved/inlined correctly
|
|
4544
|
-
driver: isWindows ? pathToFileURL(cacheDriverPath).href : cacheDriverPath,
|
|
4545
|
-
base: cacheDir
|
|
4546
|
-
}
|
|
4547
|
-
});
|
|
4548
|
-
nuxt._nitro = nitro;
|
|
4549
|
-
await nuxt.callHook("nitro:init", nitro);
|
|
4550
|
-
nitro.vfs = nuxt.vfs = nitro.vfs || nuxt.vfs || {};
|
|
4551
|
-
nuxt.hook("close", () => nitro.hooks.callHook("close"));
|
|
4552
|
-
nitro.hooks.hook("prerender:routes", (routes) => {
|
|
4553
|
-
return nuxt.callHook("prerender:routes", { routes });
|
|
4554
|
-
});
|
|
4555
|
-
if (nuxt.options.vue.runtimeCompiler) {
|
|
4556
|
-
addVitePlugin({
|
|
4557
|
-
name: "nuxt:vue:runtime-compiler",
|
|
4558
|
-
applyToEnvironment: (environment) => environment.name === "client",
|
|
4559
|
-
enforce: "pre",
|
|
4560
|
-
resolveId(id, importer) {
|
|
4561
|
-
if (id === "vue") {
|
|
4562
|
-
return this.resolve("vue/dist/vue.esm-bundler", importer, { skipSelf: true });
|
|
4563
|
-
}
|
|
4564
|
-
}
|
|
4565
|
-
});
|
|
4566
|
-
for (const hook of ["webpack:config", "rspack:config"]) {
|
|
4567
|
-
nuxt.hook(hook, (configuration) => {
|
|
4568
|
-
const clientConfig = configuration.find((config) => config.name === "client");
|
|
4569
|
-
if (!clientConfig.resolve) {
|
|
4570
|
-
clientConfig.resolve.alias = {};
|
|
4571
|
-
}
|
|
4572
|
-
if (Array.isArray(clientConfig.resolve.alias)) {
|
|
4573
|
-
clientConfig.resolve.alias.push({
|
|
4574
|
-
name: "vue",
|
|
4575
|
-
alias: "vue/dist/vue.esm-bundler"
|
|
4576
|
-
});
|
|
4577
|
-
} else {
|
|
4578
|
-
clientConfig.resolve.alias.vue = "vue/dist/vue.esm-bundler";
|
|
4579
|
-
}
|
|
4580
|
-
});
|
|
4581
|
-
}
|
|
4582
|
-
}
|
|
4583
|
-
const devMiddlewareHandler = dynamicEventHandler();
|
|
4584
|
-
nitro.options.devHandlers.unshift({ handler: devMiddlewareHandler });
|
|
4585
|
-
nitro.options.devHandlers.push(...nuxt.options.devServerHandlers);
|
|
4586
|
-
nitro.options.handlers.unshift({
|
|
4587
|
-
route: "/__nuxt_error",
|
|
4588
|
-
lazy: true,
|
|
4589
|
-
handler: resolve(distDir, "core/runtime/nitro/handlers/renderer")
|
|
4590
|
-
});
|
|
4591
|
-
if (nuxt.options.experimental.chromeDevtoolsProjectSettings) {
|
|
4592
|
-
const cacheDir2 = resolve(nuxt.options.rootDir, "node_modules/.cache/nuxt");
|
|
4593
|
-
let projectConfiguration = await readFile(join(cacheDir2, "chrome-workspace.json"), "utf-8").then((r) => JSON.parse(r)).catch(() => null);
|
|
4594
|
-
if (!projectConfiguration) {
|
|
4595
|
-
projectConfiguration = { uuid: randomUUID() };
|
|
4596
|
-
await mkdir(cacheDir2, { recursive: true });
|
|
4597
|
-
await writeFile(join(cacheDir2, "chrome-workspace.json"), JSON.stringify(projectConfiguration), "utf-8");
|
|
4598
|
-
}
|
|
4599
|
-
nitro.options.devHandlers.push({
|
|
4600
|
-
route: "/.well-known/appspecific/com.chrome.devtools.json",
|
|
4601
|
-
handler: defineEventHandler(() => ({
|
|
4602
|
-
workspace: {
|
|
4603
|
-
...projectConfiguration,
|
|
4604
|
-
root: nuxt.options.rootDir
|
|
4605
|
-
}
|
|
4606
|
-
}))
|
|
4607
|
-
});
|
|
4608
|
-
}
|
|
4609
|
-
if (!nuxt.options.dev && nuxt.options.experimental.noVueServer) {
|
|
4610
|
-
nitro.hooks.hook("rollup:before", (nitro2) => {
|
|
4611
|
-
if (nitro2.options.preset === "nitro-prerender") {
|
|
4612
|
-
nitro2.options.errorHandler = resolve(distDir, "core/runtime/nitro/handlers/error");
|
|
4613
|
-
return;
|
|
4614
|
-
}
|
|
4615
|
-
const nuxtErrorHandler = nitro2.options.handlers.findIndex((h) => h.route === "/__nuxt_error");
|
|
4616
|
-
if (nuxtErrorHandler >= 0) {
|
|
4617
|
-
nitro2.options.handlers.splice(nuxtErrorHandler, 1);
|
|
4618
|
-
}
|
|
4619
|
-
nitro2.options.renderer = void 0;
|
|
4620
|
-
});
|
|
4621
|
-
}
|
|
4622
|
-
nitro.hooks.hook("types:extend", (types) => {
|
|
4623
|
-
types.tsConfig ||= {};
|
|
4624
|
-
const rootDirGlob = relativeWithDot(nuxt.options.buildDir, join(nuxt.options.rootDir, "**/*"));
|
|
4625
|
-
types.tsConfig.include = types.tsConfig.include?.filter((i) => i !== rootDirGlob);
|
|
4626
|
-
});
|
|
4627
|
-
nuxt.hook("prepare:types", async (opts) => {
|
|
4628
|
-
if (!nuxt.options.dev) {
|
|
4629
|
-
await scanHandlers(nitro);
|
|
4630
|
-
await writeTypes(nitro);
|
|
4631
|
-
}
|
|
4632
|
-
opts.tsConfig.exclude ||= [];
|
|
4633
|
-
opts.tsConfig.exclude.push(relative(nuxt.options.buildDir, resolve(nuxt.options.rootDir, nitro.options.output.dir)));
|
|
4634
|
-
opts.tsConfig.exclude.push(relative(nuxt.options.buildDir, resolve(nuxt.options.rootDir, nuxt.options.serverDir)));
|
|
4635
|
-
opts.references.push({ path: resolve(nuxt.options.buildDir, "types/nitro.d.ts") });
|
|
4636
|
-
opts.sharedTsConfig.compilerOptions ||= {};
|
|
4637
|
-
opts.sharedTsConfig.compilerOptions.paths ||= {};
|
|
4638
|
-
for (const key in nuxt.options.alias) {
|
|
4639
|
-
if (nitro.options.alias[key] && nitro.options.alias[key] === nuxt.options.alias[key]) {
|
|
4640
|
-
const dirKey = join(key, "*");
|
|
4641
|
-
if (opts.tsConfig.compilerOptions?.paths[key]) {
|
|
4642
|
-
opts.sharedTsConfig.compilerOptions.paths[key] = opts.tsConfig.compilerOptions.paths[key];
|
|
4643
|
-
}
|
|
4644
|
-
if (opts.tsConfig.compilerOptions?.paths[dirKey]) {
|
|
4645
|
-
opts.sharedTsConfig.compilerOptions.paths[dirKey] = opts.tsConfig.compilerOptions.paths[dirKey];
|
|
4646
|
-
}
|
|
4647
|
-
}
|
|
4648
|
-
}
|
|
4649
|
-
});
|
|
4650
|
-
if (nitro.options.static) {
|
|
4651
|
-
nitro.hooks.hook("prerender:routes", (routes) => {
|
|
4652
|
-
for (const route of ["/200.html", "/404.html"]) {
|
|
4653
|
-
routes.add(route);
|
|
4654
|
-
}
|
|
4655
|
-
if (!nuxt.options.ssr) {
|
|
4656
|
-
routes.add("/index.html");
|
|
4657
|
-
}
|
|
4658
|
-
});
|
|
4659
|
-
}
|
|
4660
|
-
if (!nuxt.options.dev) {
|
|
4661
|
-
nitro.hooks.hook("rollup:before", async (nitro2) => {
|
|
4662
|
-
await copyPublicAssets(nitro2);
|
|
4663
|
-
await nuxt.callHook("nitro:build:public-assets", nitro2);
|
|
4664
|
-
});
|
|
4665
|
-
}
|
|
4666
|
-
async function symlinkDist() {
|
|
4667
|
-
if (nitro.options.static) {
|
|
4668
|
-
const distDir2 = resolve(nuxt.options.rootDir, "dist");
|
|
4669
|
-
if (!existsSync(distDir2)) {
|
|
4670
|
-
await promises.symlink(nitro.options.output.publicDir, distDir2, "junction").catch(() => {
|
|
4671
|
-
});
|
|
4672
|
-
}
|
|
4673
|
-
}
|
|
4674
|
-
}
|
|
4675
|
-
nuxt.hook("build:done", async () => {
|
|
4676
|
-
await nuxt.callHook("nitro:build:before", nitro);
|
|
4677
|
-
await prepare(nitro);
|
|
4678
|
-
if (nuxt.options.dev) {
|
|
4679
|
-
return build$1(nitro);
|
|
4680
|
-
}
|
|
4681
|
-
await prerender(nitro);
|
|
4682
|
-
logger$1.restoreAll();
|
|
4683
|
-
await build$1(nitro);
|
|
4684
|
-
logger$1.wrapAll();
|
|
4685
|
-
await symlinkDist();
|
|
4686
|
-
});
|
|
4687
|
-
if (nuxt.options.dev) {
|
|
4688
|
-
for (const builder of ["webpack", "rspack"]) {
|
|
4689
|
-
nuxt.hook(`${builder}:compile`, ({ name, compiler }) => {
|
|
4690
|
-
if (name === "server") {
|
|
4691
|
-
const memfs = compiler.outputFileSystem;
|
|
4692
|
-
nitro.options.virtual["#build/dist/server/server.mjs"] = () => memfs.readFileSync(join(nuxt.options.buildDir, "dist/server/server.mjs"), "utf-8");
|
|
4693
|
-
}
|
|
4694
|
-
});
|
|
4695
|
-
nuxt.hook(`${builder}:compiled`, () => {
|
|
4696
|
-
nuxt.server.reload();
|
|
4697
|
-
});
|
|
4698
|
-
}
|
|
4699
|
-
nuxt.hook("vite:compiled", () => {
|
|
4700
|
-
nuxt.server.reload();
|
|
4701
|
-
});
|
|
4702
|
-
nuxt.hook("server:devHandler", (h) => {
|
|
4703
|
-
devMiddlewareHandler.set(h);
|
|
4704
|
-
});
|
|
4705
|
-
nuxt.server = createDevServer(nitro);
|
|
4706
|
-
const waitUntilCompile = new Promise((resolve2) => nitro.hooks.hook("compiled", () => resolve2()));
|
|
4707
|
-
nuxt.hook("build:done", () => waitUntilCompile);
|
|
4708
|
-
}
|
|
4709
|
-
}
|
|
4710
|
-
const RELATIVE_RE = /^([^.])/;
|
|
4711
|
-
function relativeWithDot(from, to) {
|
|
4712
|
-
return relative(from, to).replace(RELATIVE_RE, "./$1") || ".";
|
|
4713
|
-
}
|
|
4714
|
-
async function spaLoadingTemplatePath(nuxt) {
|
|
4715
|
-
if (typeof nuxt.options.spaLoadingTemplate === "string") {
|
|
4716
|
-
return resolve(nuxt.options.srcDir, nuxt.options.spaLoadingTemplate);
|
|
4097
|
+
async function bundleServer(nuxt) {
|
|
4098
|
+
try {
|
|
4099
|
+
const { bundle } = !nuxt.options.server.builder || typeof nuxt.options.server.builder === "string" ? await loadServerBuilder(nuxt, nuxt.options.server.builder) : nuxt.options.server.builder;
|
|
4100
|
+
await bundle(nuxt);
|
|
4101
|
+
} catch (error) {
|
|
4102
|
+
await nuxt.callHook("build:error", error);
|
|
4103
|
+
throw error;
|
|
4717
4104
|
}
|
|
4718
|
-
const possiblePaths = nuxt.options._layers.map((layer) => resolve(layer.config.srcDir, layer.config.dir?.app || "app", "spa-loading-template.html"));
|
|
4719
|
-
return await findPath(possiblePaths) ?? resolve(nuxt.options.srcDir, nuxt.options.dir?.app || "app", "spa-loading-template.html");
|
|
4720
4105
|
}
|
|
4721
|
-
async function
|
|
4722
|
-
if (nuxt.options.spaLoadingTemplate === false) {
|
|
4723
|
-
return "";
|
|
4724
|
-
}
|
|
4725
|
-
const spaLoadingTemplate2 = await spaLoadingTemplatePath(nuxt);
|
|
4106
|
+
async function loadServerBuilder(nuxt, builder = "@nuxt/nitro-server") {
|
|
4726
4107
|
try {
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
}
|
|
4730
|
-
} catch {
|
|
4731
|
-
}
|
|
4732
|
-
if (nuxt.options.spaLoadingTemplate === true) {
|
|
4733
|
-
return template();
|
|
4734
|
-
}
|
|
4735
|
-
if (nuxt.options.spaLoadingTemplate) {
|
|
4736
|
-
logger$1.warn(`Could not load custom \`spaLoadingTemplate\` path as it does not exist: \`${nuxt.options.spaLoadingTemplate}\`.`);
|
|
4108
|
+
return await importModule(builder, { url: [directoryToURL(nuxt.options.rootDir), new URL(import.meta.url)] });
|
|
4109
|
+
} catch (err) {
|
|
4110
|
+
throw new Error(`Loading \`${builder}\` server builder failed.`, { cause: err });
|
|
4737
4111
|
}
|
|
4738
|
-
return "";
|
|
4739
4112
|
}
|
|
4740
4113
|
|
|
4741
4114
|
const schemaModule = defineNuxtModule({
|
|
@@ -5731,6 +5104,7 @@ Using \`${fallbackCompatibilityDate}\` as fallback. More info at: ${colors.under
|
|
|
5731
5104
|
tsConfig: { compilerOptions: { paths: { ...paths } } }
|
|
5732
5105
|
});
|
|
5733
5106
|
});
|
|
5107
|
+
const serverBuilderTypePath = typeof nuxt.options.server.builder === "string" ? nuxt.options.server.builder === "@nuxt/nitro-server" ? resolveModulePath(nuxt.options.server.builder, { from: import.meta.url }) : nuxt.options.server.builder : void 0;
|
|
5734
5108
|
nuxt.hook("prepare:types", async (opts) => {
|
|
5735
5109
|
opts.references.push({ path: resolve(nuxt.options.buildDir, "types/plugins.d.ts") });
|
|
5736
5110
|
if (nuxt.options.typescript.shim) {
|
|
@@ -5748,6 +5122,10 @@ Using \`${fallbackCompatibilityDate}\` as fallback. More info at: ${colors.under
|
|
|
5748
5122
|
if (typeof nuxt.options.builder === "string" && nuxt.options.builder !== "@nuxt/vite-builder") {
|
|
5749
5123
|
opts.nodeReferences.push({ types: nuxt.options.builder });
|
|
5750
5124
|
}
|
|
5125
|
+
if (serverBuilderTypePath) {
|
|
5126
|
+
opts.references.push({ types: serverBuilderTypePath });
|
|
5127
|
+
opts.nodeReferences.push({ types: serverBuilderTypePath });
|
|
5128
|
+
}
|
|
5751
5129
|
opts.sharedReferences.push({ path: resolve(nuxt.options.buildDir, "types/runtime-config.d.ts") });
|
|
5752
5130
|
opts.sharedReferences.push({ path: resolve(nuxt.options.buildDir, "types/app.config.d.ts") });
|
|
5753
5131
|
paths ||= await resolveTypescriptPaths(nuxt);
|
|
@@ -5766,6 +5144,9 @@ Using \`${fallbackCompatibilityDate}\` as fallback. More info at: ${colors.under
|
|
|
5766
5144
|
nuxt.hook("nitro:prepare:types", (opts) => {
|
|
5767
5145
|
opts.references.push({ path: resolve(nuxt.options.buildDir, "types/app.config.d.ts") });
|
|
5768
5146
|
opts.references.push({ path: resolve(nuxt.options.buildDir, "types/runtime-config.d.ts") });
|
|
5147
|
+
if (serverBuilderTypePath) {
|
|
5148
|
+
opts.references.push({ types: serverBuilderTypePath });
|
|
5149
|
+
}
|
|
5769
5150
|
});
|
|
5770
5151
|
if (nuxt.options.scripts) {
|
|
5771
5152
|
if (!nuxt.options._modules.some((m) => m === "@nuxt/scripts" || m === "@nuxt/scripts-nightly")) {
|
|
@@ -5854,18 +5235,6 @@ Using \`${fallbackCompatibilityDate}\` as fallback. More info at: ${colors.under
|
|
|
5854
5235
|
addPlugin(resolve(nuxt.options.appDir, "plugins/check-if-layout-used"));
|
|
5855
5236
|
addPlugin(resolve(nuxt.options.appDir, "plugins/warn.dev.server"));
|
|
5856
5237
|
}
|
|
5857
|
-
if (nuxt.options.dev && nuxt.options.features.devLogs) {
|
|
5858
|
-
addPlugin(resolve(nuxt.options.appDir, "plugins/dev-server-logs"));
|
|
5859
|
-
addServerPlugin(resolve(distDir, "core/runtime/nitro/plugins/dev-server-logs"));
|
|
5860
|
-
nuxt.options.nitro = defu$1(nuxt.options.nitro, {
|
|
5861
|
-
externals: {
|
|
5862
|
-
inline: [/#internal\/dev-server-logs-options/]
|
|
5863
|
-
},
|
|
5864
|
-
virtual: {
|
|
5865
|
-
"#internal/dev-server-logs-options": () => `export const rootDir = ${JSON.stringify(nuxt.options.rootDir)};`
|
|
5866
|
-
}
|
|
5867
|
-
});
|
|
5868
|
-
}
|
|
5869
5238
|
if (nuxt.options.experimental.asyncContext) {
|
|
5870
5239
|
addBuildPlugin(AsyncContextInjectionPlugin(nuxt), { client: false });
|
|
5871
5240
|
}
|
|
@@ -6011,24 +5380,6 @@ Using \`${fallbackCompatibilityDate}\` as fallback. More info at: ${colors.under
|
|
|
6011
5380
|
// built-in that we do not expect the user to override
|
|
6012
5381
|
filePath: resolve(nuxt.options.appDir, "components/nuxt-island")
|
|
6013
5382
|
});
|
|
6014
|
-
addServerTemplate({
|
|
6015
|
-
filename: "#internal/nuxt/island-renderer.mjs",
|
|
6016
|
-
getContents() {
|
|
6017
|
-
if (nuxt.options.dev || nuxt.options.experimental.componentIslands !== "auto" || nuxt.apps.default?.pages?.some((p) => p.mode === "server") || nuxt.apps.default?.components?.some((c) => c.mode === "server" && !nuxt.apps.default?.components.some((other) => other.pascalName === c.pascalName && other.mode === "client"))) {
|
|
6018
|
-
return `export { default } from '${resolve(distDir, "core/runtime/nitro/handlers/island")}'`;
|
|
6019
|
-
}
|
|
6020
|
-
return `import { defineEventHandler } from 'h3'; export default defineEventHandler(() => {});`;
|
|
6021
|
-
}
|
|
6022
|
-
});
|
|
6023
|
-
addServerHandler({
|
|
6024
|
-
route: "/__nuxt_island/**",
|
|
6025
|
-
handler: "#internal/nuxt/island-renderer.mjs"
|
|
6026
|
-
});
|
|
6027
|
-
if (!nuxt.options.ssr && nuxt.options.experimental.componentIslands !== "auto") {
|
|
6028
|
-
nuxt.options.ssr = true;
|
|
6029
|
-
nuxt.options.nitro.routeRules ||= {};
|
|
6030
|
-
nuxt.options.nitro.routeRules["/**"] = defu$1(nuxt.options.nitro.routeRules["/**"], { ssr: false });
|
|
6031
|
-
}
|
|
6032
5383
|
}
|
|
6033
5384
|
if (!nuxt.options.dev && nuxt.options.experimental.payloadExtraction) {
|
|
6034
5385
|
addPlugin(resolve(nuxt.options.appDir, "plugins/payload.client"));
|
|
@@ -6117,7 +5468,7 @@ export default defineNuxtPlugin({
|
|
|
6117
5468
|
return normalize(t).split("node_modules/").pop();
|
|
6118
5469
|
});
|
|
6119
5470
|
addModuleTranspiles(nuxt);
|
|
6120
|
-
await
|
|
5471
|
+
await bundleServer(nuxt);
|
|
6121
5472
|
const nitro = useNitro();
|
|
6122
5473
|
if (nitro.options.static && nuxt.options.experimental.payloadExtraction === void 0) {
|
|
6123
5474
|
logger.warn("Using experimental payload extraction for full-static output. You can opt-out by setting `experimental.payloadExtraction` to `false`.");
|
|
@@ -6652,96 +6003,6 @@ const middlewareTemplate = {
|
|
|
6652
6003
|
].join("\n");
|
|
6653
6004
|
}
|
|
6654
6005
|
};
|
|
6655
|
-
function renderAttr(key, value) {
|
|
6656
|
-
return value ? `${key}="${value}"` : "";
|
|
6657
|
-
}
|
|
6658
|
-
function renderAttrs(obj) {
|
|
6659
|
-
const attrs = [];
|
|
6660
|
-
for (const key in obj) {
|
|
6661
|
-
attrs.push(renderAttr(key, obj[key]));
|
|
6662
|
-
}
|
|
6663
|
-
return attrs.join(" ");
|
|
6664
|
-
}
|
|
6665
|
-
const nitroSchemaTemplate = {
|
|
6666
|
-
filename: "types/nitro-nuxt.d.ts",
|
|
6667
|
-
async getContents({ nuxt }) {
|
|
6668
|
-
const references = [];
|
|
6669
|
-
const declarations = [];
|
|
6670
|
-
await nuxt.callHook("nitro:prepare:types", { references, declarations });
|
|
6671
|
-
const sourceDir = join(nuxt.options.buildDir, "types");
|
|
6672
|
-
const lines = [
|
|
6673
|
-
...references.map((ref) => {
|
|
6674
|
-
if ("path" in ref && isAbsolute(ref.path)) {
|
|
6675
|
-
ref.path = relative(sourceDir, ref.path);
|
|
6676
|
-
}
|
|
6677
|
-
return `/// <reference ${renderAttrs(ref)} />`;
|
|
6678
|
-
}),
|
|
6679
|
-
...declarations
|
|
6680
|
-
];
|
|
6681
|
-
return (
|
|
6682
|
-
/* typescript */
|
|
6683
|
-
`
|
|
6684
|
-
${lines.join("\n")}
|
|
6685
|
-
|
|
6686
|
-
import type { RuntimeConfig } from 'nuxt/schema'
|
|
6687
|
-
import type { H3Event } from 'h3'
|
|
6688
|
-
import type { LogObject } from 'consola'
|
|
6689
|
-
import type { NuxtIslandContext, NuxtIslandResponse, NuxtRenderHTMLContext } from 'nuxt/app'
|
|
6690
|
-
|
|
6691
|
-
declare module 'nitropack' {
|
|
6692
|
-
interface NitroRuntimeConfigApp {
|
|
6693
|
-
buildAssetsDir: string
|
|
6694
|
-
cdnURL: string
|
|
6695
|
-
}
|
|
6696
|
-
interface NitroRuntimeConfig extends RuntimeConfig {}
|
|
6697
|
-
interface NitroRouteConfig {
|
|
6698
|
-
ssr?: boolean
|
|
6699
|
-
noScripts?: boolean
|
|
6700
|
-
/** @deprecated Use \`noScripts\` instead */
|
|
6701
|
-
experimentalNoScripts?: boolean
|
|
6702
|
-
}
|
|
6703
|
-
interface NitroRouteRules {
|
|
6704
|
-
ssr?: boolean
|
|
6705
|
-
noScripts?: boolean
|
|
6706
|
-
/** @deprecated Use \`noScripts\` instead */
|
|
6707
|
-
experimentalNoScripts?: boolean
|
|
6708
|
-
appMiddleware?: Record<string, boolean>
|
|
6709
|
-
}
|
|
6710
|
-
interface NitroRuntimeHooks {
|
|
6711
|
-
'dev:ssr-logs': (ctx: { logs: LogObject[], path: string }) => void | Promise<void>
|
|
6712
|
-
'render:html': (htmlContext: NuxtRenderHTMLContext, context: { event: H3Event }) => void | Promise<void>
|
|
6713
|
-
'render:island': (islandResponse: NuxtIslandResponse, context: { event: H3Event, islandContext: NuxtIslandContext }) => void | Promise<void>
|
|
6714
|
-
}
|
|
6715
|
-
}
|
|
6716
|
-
declare module 'nitropack/types' {
|
|
6717
|
-
interface NitroRuntimeConfigApp {
|
|
6718
|
-
buildAssetsDir: string
|
|
6719
|
-
cdnURL: string
|
|
6720
|
-
}
|
|
6721
|
-
interface NitroRuntimeConfig extends RuntimeConfig {}
|
|
6722
|
-
interface NitroRouteConfig {
|
|
6723
|
-
ssr?: boolean
|
|
6724
|
-
noScripts?: boolean
|
|
6725
|
-
/** @deprecated Use \`noScripts\` instead */
|
|
6726
|
-
experimentalNoScripts?: boolean
|
|
6727
|
-
}
|
|
6728
|
-
interface NitroRouteRules {
|
|
6729
|
-
ssr?: boolean
|
|
6730
|
-
noScripts?: boolean
|
|
6731
|
-
/** @deprecated Use \`noScripts\` instead */
|
|
6732
|
-
experimentalNoScripts?: boolean
|
|
6733
|
-
appMiddleware?: Record<string, boolean>
|
|
6734
|
-
}
|
|
6735
|
-
interface NitroRuntimeHooks {
|
|
6736
|
-
'dev:ssr-logs': (ctx: { logs: LogObject[], path: string }) => void | Promise<void>
|
|
6737
|
-
'render:html': (htmlContext: NuxtRenderHTMLContext, context: { event: H3Event }) => void | Promise<void>
|
|
6738
|
-
'render:island': (islandResponse: NuxtIslandResponse, context: { event: H3Event, islandContext: NuxtIslandContext }) => void | Promise<void>
|
|
6739
|
-
}
|
|
6740
|
-
}
|
|
6741
|
-
`
|
|
6742
|
-
);
|
|
6743
|
-
}
|
|
6744
|
-
};
|
|
6745
6006
|
const clientConfigTemplate = {
|
|
6746
6007
|
filename: "nitro.client.mjs",
|
|
6747
6008
|
getContents: ({ nuxt }) => {
|
|
@@ -6944,7 +6205,6 @@ const defaultTemplates = {
|
|
|
6944
6205
|
globalPolyfillsTemplate: globalPolyfillsTemplate,
|
|
6945
6206
|
layoutTemplate: layoutTemplate,
|
|
6946
6207
|
middlewareTemplate: middlewareTemplate,
|
|
6947
|
-
nitroSchemaTemplate: nitroSchemaTemplate,
|
|
6948
6208
|
nuxtConfigTemplate: nuxtConfigTemplate,
|
|
6949
6209
|
pluginsDeclaration: pluginsDeclaration,
|
|
6950
6210
|
publicPathTemplate: publicPathTemplate,
|