nitro-nightly 3.0.1-20251127-003817-dd47a8df → 3.0.1-20251201-104553-0f08396c
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/_build/rolldown.mjs +1 -1
- package/dist/_build/rollup.mjs +12 -12
- package/dist/_build/vite.build.mjs +2 -2
- package/dist/_build/vite.plugin.mjs +2 -2
- package/dist/_chunks/{BT4o98A6.mjs → Qe19FNKf.mjs} +658 -520
- package/dist/_chunks/{QnObqKaP.mjs → _yl3G_3Y.mjs} +41 -70
- package/dist/_dev.mjs +4 -9
- package/dist/builder.mjs +1 -1
- package/dist/presets/_nitro/runtime/nitro-dev.d.mts +1 -1
- package/dist/presets/_nitro/runtime/nitro-dev.mjs +1 -1
- package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +1 -1
- package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +1 -1
- package/dist/presets/_nitro/runtime/service-worker.d.mts +1 -1
- package/dist/presets/_nitro/runtime/service-worker.mjs +1 -1
- package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +1 -1
- package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +1 -1
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +1 -1
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +1 -1
- package/dist/presets/aws-lambda/runtime/aws-lambda.d.mts +1 -1
- package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +1 -1
- package/dist/presets/azure/runtime/azure-swa.d.mts +1 -1
- package/dist/presets/azure/runtime/azure-swa.mjs +1 -1
- package/dist/presets/bun/runtime/bun.d.mts +1 -1
- package/dist/presets/bun/runtime/bun.mjs +1 -1
- package/dist/presets/cloudflare/runtime/_module-handler.d.mts +1 -1
- package/dist/presets/cloudflare/runtime/_module-handler.mjs +1 -1
- package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +1 -1
- package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +1 -1
- package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +1 -1
- package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +1 -1
- package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +1 -1
- package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +1 -1
- package/dist/presets/deno/runtime/deno-deploy.d.mts +1 -1
- package/dist/presets/deno/runtime/deno-deploy.mjs +1 -1
- package/dist/presets/deno/runtime/deno-server.d.mts +1 -1
- package/dist/presets/deno/runtime/deno-server.mjs +1 -1
- package/dist/presets/netlify/runtime/netlify-edge.d.mts +1 -1
- package/dist/presets/netlify/runtime/netlify-edge.mjs +1 -1
- package/dist/presets/netlify/runtime/netlify.d.mts +1 -1
- package/dist/presets/netlify/runtime/netlify.mjs +1 -1
- package/dist/presets/node/runtime/node-cluster.d.mts +1 -1
- package/dist/presets/node/runtime/node-cluster.mjs +1 -1
- package/dist/presets/node/runtime/node-middleware.d.mts +1 -1
- package/dist/presets/node/runtime/node-middleware.mjs +1 -1
- package/dist/presets/node/runtime/node-server.d.mts +1 -1
- package/dist/presets/node/runtime/node-server.mjs +1 -1
- package/dist/presets/standard/runtime/server.d.mts +1 -1
- package/dist/presets/standard/runtime/server.mjs +1 -1
- package/dist/presets/stormkit/runtime/stormkit.d.mts +1 -1
- package/dist/presets/stormkit/runtime/stormkit.mjs +1 -1
- package/dist/presets/vercel/runtime/vercel.node.d.mts +1 -1
- package/dist/presets/vercel/runtime/vercel.node.mjs +1 -1
- package/dist/presets/vercel/runtime/vercel.web.d.mts +1 -1
- package/dist/presets/vercel/runtime/vercel.web.mjs +1 -1
- package/dist/presets/winterjs/runtime/winterjs.d.mts +1 -1
- package/dist/presets/winterjs/runtime/winterjs.mjs +1 -1
- package/dist/presets/zeabur/runtime/zeabur.d.mts +1 -1
- package/dist/presets/zeabur/runtime/zeabur.mjs +1 -1
- package/dist/runtime/internal/vite/dev-entry.mjs +1 -1
- package/dist/types/index.d.mts +6 -4
- package/dist/vite.mjs +2 -2
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as __toESM } from "./OEiRXl0H.mjs";
|
|
2
|
-
import { O as relative, k as resolve, w as join, x as dirname } from "../_libs/c12.mjs";
|
|
2
|
+
import { O as relative, T as normalize, k as resolve, w as join, x as dirname } from "../_libs/c12.mjs";
|
|
3
3
|
import { c as parseNodeModulePath } from "../_libs/local-pkg.mjs";
|
|
4
4
|
import { i as unplugin } from "../_libs/unimport.mjs";
|
|
5
5
|
import { t as glob } from "../_libs/tinyglobby.mjs";
|
|
@@ -17,11 +17,11 @@ import { defu } from "defu";
|
|
|
17
17
|
import { pkgDir, presetsDir, runtimeDependencies, runtimeDir } from "nitro/meta";
|
|
18
18
|
import { hash } from "ohash";
|
|
19
19
|
import { defineEnv } from "unenv";
|
|
20
|
-
import { connectors } from "db0";
|
|
21
20
|
import { transformSync } from "oxc-transform";
|
|
22
|
-
import { builtinDrivers, normalizeKey } from "unstorage";
|
|
23
21
|
import { rollupNodeFileTrace } from "nf3";
|
|
22
|
+
import { connectors } from "db0";
|
|
24
23
|
import { RENDER_CONTEXT_KEYS, compileTemplateToString, hasTemplateSyntax } from "rendu";
|
|
24
|
+
import { builtinDrivers, normalizeKey } from "unstorage";
|
|
25
25
|
|
|
26
26
|
//#region src/build/config.ts
|
|
27
27
|
function baseBuildConfig(nitro) {
|
|
@@ -138,192 +138,52 @@ function routeToFsPath(route) {
|
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
//#endregion
|
|
141
|
-
//#region src/
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const _modules = /* @__PURE__ */ new Map();
|
|
145
|
-
for (const [id, mod] of Object.entries(modules)) {
|
|
146
|
-
cache[id] = mod;
|
|
147
|
-
_modules.set(id, mod);
|
|
148
|
-
_modules.set(resolve(id), mod);
|
|
149
|
-
}
|
|
150
|
-
return {
|
|
151
|
-
name: "virtual",
|
|
152
|
-
resolveId(id, importer) {
|
|
153
|
-
if (id in modules) return {
|
|
154
|
-
id: PREFIX + id,
|
|
155
|
-
...opts
|
|
156
|
-
};
|
|
157
|
-
if (importer) {
|
|
158
|
-
const resolved = resolve(dirname(importer.startsWith(PREFIX) ? importer.slice(9) : importer), id);
|
|
159
|
-
if (_modules.has(resolved)) return PREFIX + resolved;
|
|
160
|
-
}
|
|
161
|
-
return null;
|
|
162
|
-
},
|
|
163
|
-
async load(id) {
|
|
164
|
-
if (!id.startsWith(PREFIX)) return null;
|
|
165
|
-
const idNoPrefix = id.slice(9);
|
|
166
|
-
if (!_modules.has(idNoPrefix)) return null;
|
|
167
|
-
let m = _modules.get(idNoPrefix);
|
|
168
|
-
if (typeof m === "function") m = await m();
|
|
169
|
-
if (!m) return null;
|
|
170
|
-
cache[id.replace(PREFIX, "")] = m;
|
|
171
|
-
return {
|
|
172
|
-
code: m,
|
|
173
|
-
map: null
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
//#endregion
|
|
180
|
-
//#region src/build/plugins/database.ts
|
|
181
|
-
function database(nitro) {
|
|
182
|
-
if (!nitro.options.experimental.database) return virtual({ "#nitro-internal-virtual/database": () => {
|
|
183
|
-
return `export const connectionConfigs = {};`;
|
|
184
|
-
} }, nitro.vfs);
|
|
185
|
-
const dbConfigs = nitro.options.dev && nitro.options.devDatabase || nitro.options.database;
|
|
186
|
-
const connectorsNames = [...new Set(Object.values(dbConfigs || {}).map((config) => config?.connector))].filter(Boolean);
|
|
187
|
-
for (const name of connectorsNames) if (!connectors[name]) throw new Error(`Database connector "${name}" is invalid.`);
|
|
188
|
-
return virtual({ "#nitro-internal-virtual/database": () => {
|
|
189
|
-
return `
|
|
190
|
-
${connectorsNames.map((name) => `import ${camelCase(name)}Connector from "${connectors[name]}";`).join("\n")}
|
|
191
|
-
|
|
192
|
-
export const connectionConfigs = {
|
|
193
|
-
${Object.entries(dbConfigs || {}).map(([name, { connector, options }]) => `${name}: {
|
|
194
|
-
connector: ${camelCase(connector)}Connector,
|
|
195
|
-
options: ${JSON.stringify(options)}
|
|
196
|
-
}`).join(",\n")}
|
|
197
|
-
};
|
|
198
|
-
`;
|
|
199
|
-
} }, nitro.vfs);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
//#endregion
|
|
203
|
-
//#region src/build/plugins/routing.ts
|
|
204
|
-
const RuntimeRouteRules = [
|
|
205
|
-
"headers",
|
|
206
|
-
"redirect",
|
|
207
|
-
"proxy",
|
|
208
|
-
"cache"
|
|
209
|
-
];
|
|
210
|
-
function routing(nitro) {
|
|
211
|
-
return virtual({
|
|
212
|
-
"#nitro-internal-virtual/routing": () => {
|
|
213
|
-
const allHandlers = uniqueBy([
|
|
214
|
-
...Object.values(nitro.routing.routes.routes).flatMap((h) => h.data),
|
|
215
|
-
...Object.values(nitro.routing.routedMiddleware.routes).map((h) => h.data),
|
|
216
|
-
...nitro.routing.globalMiddleware
|
|
217
|
-
], "_importHash");
|
|
218
|
-
return `
|
|
219
|
-
import * as __routeRules__ from "nitro/~internal/runtime/route-rules";
|
|
220
|
-
import * as srvxNode from "srvx/node"
|
|
221
|
-
import * as h3 from "h3";
|
|
222
|
-
|
|
223
|
-
export const findRouteRules = ${nitro.routing.routeRules.compileToString({
|
|
224
|
-
serialize: serializeRouteRule,
|
|
225
|
-
matchAll: true
|
|
226
|
-
})}
|
|
227
|
-
|
|
228
|
-
const multiHandler = (...handlers) => {
|
|
229
|
-
const final = handlers.pop()
|
|
230
|
-
const middleware = handlers.filter(Boolean).map(h => h3.toMiddleware(h));
|
|
231
|
-
return (ev) => h3.callMiddleware(ev, middleware, final);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
${allHandlers.filter((h) => !h.lazy).map((h) => `import ${h._importHash} from "${h.handler}";`).join("\n")}
|
|
235
|
-
|
|
236
|
-
${allHandlers.filter((h) => h.lazy).map((h) => `const ${h._importHash} = h3.defineLazyEventHandler(() => import("${h.handler}")${h.format === "node" ? ".then(m => srvxNode.toFetchHandler(m.default))" : ""});`).join("\n")}
|
|
237
|
-
|
|
238
|
-
export const findRoute = ${nitro.routing.routes.compileToString({ serialize: serializeHandler })}
|
|
239
|
-
|
|
240
|
-
export const findRoutedMiddleware = ${nitro.routing.routedMiddleware.compileToString({
|
|
241
|
-
serialize: serializeHandler,
|
|
242
|
-
matchAll: true
|
|
243
|
-
})};
|
|
244
|
-
|
|
245
|
-
export const globalMiddleware = [
|
|
246
|
-
${nitro.routing.globalMiddleware.map((h) => h.lazy ? h._importHash : `h3.toEventHandler(${h._importHash})`).join(",")}
|
|
247
|
-
].filter(Boolean);
|
|
248
|
-
`;
|
|
249
|
-
},
|
|
250
|
-
"#nitro-internal-virtual/routing-meta": () => {
|
|
251
|
-
const routeHandlers = uniqueBy(Object.values(nitro.routing.routes.routes).flatMap((h) => h.data), "_importHash");
|
|
252
|
-
return `
|
|
253
|
-
${routeHandlers.map((h) => `import ${h._importHash}Meta from "${h.handler}?meta";`).join("\n")}
|
|
254
|
-
export const handlersMeta = [
|
|
255
|
-
${routeHandlers.map((h) => `{ route: ${JSON.stringify(h.route)}, method: ${JSON.stringify(h.method?.toLowerCase())}, meta: ${h._importHash}Meta }`).join(",\n")}
|
|
256
|
-
];
|
|
257
|
-
`.trim();
|
|
258
|
-
}
|
|
259
|
-
}, nitro.vfs);
|
|
260
|
-
}
|
|
261
|
-
function uniqueBy(arr, key) {
|
|
262
|
-
return [...new Map(arr.map((item) => [item[key], item])).values()];
|
|
263
|
-
}
|
|
264
|
-
function serializeHandler(h) {
|
|
265
|
-
const meta = Array.isArray(h) ? h[0] : h;
|
|
266
|
-
return `{${[
|
|
267
|
-
`route:${JSON.stringify(meta.route)}`,
|
|
268
|
-
meta.method && `method:${JSON.stringify(meta.method)}`,
|
|
269
|
-
meta.meta && `meta:${JSON.stringify(meta.meta)}`,
|
|
270
|
-
`handler:${Array.isArray(h) ? `multiHandler(${h.map((handler) => serializeHandlerFn(handler)).join(",")})` : serializeHandlerFn(h)}`
|
|
271
|
-
].filter(Boolean).join(",")}}`;
|
|
272
|
-
}
|
|
273
|
-
function serializeHandlerFn(h) {
|
|
274
|
-
let code = h._importHash;
|
|
275
|
-
if (!h.lazy) {
|
|
276
|
-
if (h.format === "node") code = `srvxNode.toFetchHandler(${code})`;
|
|
277
|
-
code = `h3.toEventHandler(${code})`;
|
|
278
|
-
}
|
|
279
|
-
return code;
|
|
280
|
-
}
|
|
281
|
-
function serializeRouteRule(h) {
|
|
282
|
-
return `[${Object.entries(h).filter(([name, options]) => options !== void 0 && name[0] !== "_").map(([name, options]) => {
|
|
283
|
-
return `{${[
|
|
284
|
-
`name:${JSON.stringify(name)}`,
|
|
285
|
-
`route:${JSON.stringify(h._route)}`,
|
|
286
|
-
h._method && `method:${JSON.stringify(h._method)}`,
|
|
287
|
-
RuntimeRouteRules.includes(name) && `handler:__routeRules__.${name}`,
|
|
288
|
-
`options:${JSON.stringify(options)}`
|
|
289
|
-
].filter(Boolean).join(",")}}`;
|
|
290
|
-
}).join(",")}]`;
|
|
141
|
+
//#region src/utils/regex.ts
|
|
142
|
+
function escapeRegExp(string) {
|
|
143
|
+
return string.replace(/[-\\^$*+?.()|[\]{}]/g, String.raw`\$&`);
|
|
291
144
|
}
|
|
292
145
|
|
|
293
146
|
//#endregion
|
|
294
147
|
//#region src/build/plugins/route-meta.ts
|
|
295
|
-
const
|
|
148
|
+
const PREFIX$2 = "\0nitro:route-meta:";
|
|
296
149
|
function routeMeta(nitro) {
|
|
297
150
|
return {
|
|
298
151
|
name: "nitro:route-meta",
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
152
|
+
resolveId: {
|
|
153
|
+
filter: { id: /^(?!\u0000)(.+)\?meta$/ },
|
|
154
|
+
async handler(id, importer, resolveOpts) {
|
|
155
|
+
if (id.endsWith("?meta")) {
|
|
156
|
+
const resolved = await this.resolve(id.replace("?meta", ""), importer, resolveOpts);
|
|
157
|
+
if (!resolved) return;
|
|
158
|
+
return PREFIX$2 + resolved.id;
|
|
159
|
+
}
|
|
305
160
|
}
|
|
306
161
|
},
|
|
307
|
-
load
|
|
308
|
-
|
|
162
|
+
load: {
|
|
163
|
+
filter: { id: /* @__PURE__ */ new RegExp(`^${escapeRegExp(PREFIX$2)}`) },
|
|
164
|
+
handler(id) {
|
|
165
|
+
if (id.startsWith(PREFIX$2)) return readFile(id.slice(18), { encoding: "utf8" });
|
|
166
|
+
}
|
|
309
167
|
},
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
168
|
+
transform: {
|
|
169
|
+
filter: { id: /* @__PURE__ */ new RegExp(`^${escapeRegExp(PREFIX$2)}`) },
|
|
170
|
+
async handler(code, id) {
|
|
171
|
+
let meta = null;
|
|
172
|
+
try {
|
|
173
|
+
const jsCode = transformSync(id, code).code;
|
|
174
|
+
const ast = this.parse(jsCode);
|
|
175
|
+
for (const node of ast.body) if (node.type === "ExpressionStatement" && node.expression.type === "CallExpression" && node.expression.callee.type === "Identifier" && node.expression.callee.name === "defineRouteMeta" && node.expression.arguments.length === 1) {
|
|
176
|
+
meta = astToObject(node.expression.arguments[0]);
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
} catch (error) {
|
|
180
|
+
nitro.logger.warn(`[handlers-meta] Cannot extra route meta for: ${id}: ${error}`);
|
|
319
181
|
}
|
|
320
|
-
|
|
321
|
-
|
|
182
|
+
return {
|
|
183
|
+
code: `export default ${JSON.stringify(meta)};`,
|
|
184
|
+
map: null
|
|
185
|
+
};
|
|
322
186
|
}
|
|
323
|
-
return {
|
|
324
|
-
code: `export default ${JSON.stringify(meta)};`,
|
|
325
|
-
map: null
|
|
326
|
-
};
|
|
327
187
|
}
|
|
328
188
|
};
|
|
329
189
|
}
|
|
@@ -357,228 +217,196 @@ function serverMain(nitro) {
|
|
|
357
217
|
}
|
|
358
218
|
|
|
359
219
|
//#endregion
|
|
360
|
-
//#region src/build/plugins/
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
const etag = (0, import_etag$1.default)(assetData);
|
|
384
|
-
const stat$2 = await promises.stat(fullPath);
|
|
385
|
-
const assetId = joinURL(nitro.options.baseURL, decodeURIComponent(id));
|
|
386
|
-
let encoding;
|
|
387
|
-
if (id.endsWith(".gz")) encoding = "gzip";
|
|
388
|
-
else if (id.endsWith(".br")) encoding = "br";
|
|
389
|
-
assets[assetId] = {
|
|
390
|
-
type: nitro._prerenderMeta?.[assetId]?.contentType || mimeType,
|
|
391
|
-
encoding,
|
|
392
|
-
etag,
|
|
393
|
-
mtime: stat$2.mtime.toJSON(),
|
|
394
|
-
size: stat$2.size,
|
|
395
|
-
path: relative(nitro.options.output.serverDir, fullPath),
|
|
396
|
-
data: nitro.options.serveStatic === "inline" ? assetData.toString("base64") : void 0
|
|
220
|
+
//#region src/build/plugins/virtual.ts
|
|
221
|
+
const PREFIX$1 = "\0nitro:virtual:";
|
|
222
|
+
function virtual(input) {
|
|
223
|
+
const modules = /* @__PURE__ */ new Map();
|
|
224
|
+
for (const mod of input) {
|
|
225
|
+
const render = () => typeof mod.template === "function" ? mod.template() : mod.template;
|
|
226
|
+
modules.set(mod.id, {
|
|
227
|
+
module: mod,
|
|
228
|
+
render
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
return {
|
|
232
|
+
name: "nitro:virtual",
|
|
233
|
+
api: { modules },
|
|
234
|
+
resolveId: {
|
|
235
|
+
order: "pre",
|
|
236
|
+
filter: { id: /* @__PURE__ */ new RegExp(`^(${[...modules.keys()].map((id) => escapeRegExp(id)).join("|")})$`) },
|
|
237
|
+
handler: (id) => {
|
|
238
|
+
const mod = modules.get(id);
|
|
239
|
+
if (!mod) return null;
|
|
240
|
+
return {
|
|
241
|
+
id: PREFIX$1 + id,
|
|
242
|
+
moduleSideEffects: mod.module.moduleSideEffects ?? false
|
|
397
243
|
};
|
|
398
244
|
}
|
|
399
|
-
return `export default ${JSON.stringify(assets, null, 2)};`;
|
|
400
|
-
},
|
|
401
|
-
"#nitro-internal-virtual/public-assets-node": () => {
|
|
402
|
-
return `
|
|
403
|
-
import { promises as fsp } from 'node:fs'
|
|
404
|
-
import { fileURLToPath } from 'node:url'
|
|
405
|
-
import { resolve, dirname } from 'node:path'
|
|
406
|
-
import assets from '#nitro-internal-virtual/public-assets-data'
|
|
407
|
-
export function readAsset (id) {
|
|
408
|
-
const serverDir = dirname(fileURLToPath(globalThis.__nitro_main__))
|
|
409
|
-
return fsp.readFile(resolve(serverDir, assets[id].path))
|
|
410
|
-
}`;
|
|
411
|
-
},
|
|
412
|
-
"#nitro-internal-virtual/public-assets-deno": () => {
|
|
413
|
-
return `
|
|
414
|
-
import assets from '#nitro-internal-virtual/public-assets-data'
|
|
415
|
-
export function readAsset (id) {
|
|
416
|
-
// https://deno.com/deploy/docs/serve-static-assets
|
|
417
|
-
const path = '.' + decodeURIComponent(new URL(\`../public\${id}\`, 'file://').pathname)
|
|
418
|
-
return Deno.readFile(path);
|
|
419
|
-
}`;
|
|
420
|
-
},
|
|
421
|
-
"#nitro-internal-virtual/public-assets-null": () => {
|
|
422
|
-
return `
|
|
423
|
-
export function readAsset (id) {
|
|
424
|
-
return Promise.resolve(null);
|
|
425
|
-
}`;
|
|
426
|
-
},
|
|
427
|
-
"#nitro-internal-virtual/public-assets-inline": () => {
|
|
428
|
-
return `
|
|
429
|
-
import assets from '#nitro-internal-virtual/public-assets-data'
|
|
430
|
-
export function readAsset (id) {
|
|
431
|
-
if (!assets[id]) { return undefined }
|
|
432
|
-
if (assets[id]._data) { return assets[id]._data }
|
|
433
|
-
if (!assets[id].data) { return assets[id].data }
|
|
434
|
-
assets[id]._data = Uint8Array.from(atob(assets[id].data), (c) => c.charCodeAt(0))
|
|
435
|
-
return assets[id]._data
|
|
436
|
-
}`;
|
|
437
245
|
},
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
if (id.startsWith(base)) { return true }
|
|
451
|
-
}
|
|
452
|
-
return false
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
export function getPublicAssetMeta(id = '') {
|
|
456
|
-
for (const base in publicAssetBases) {
|
|
457
|
-
if (id.startsWith(base)) { return publicAssetBases[base] }
|
|
458
|
-
}
|
|
459
|
-
return {}
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
export function getAsset (id) {
|
|
463
|
-
return assets[id]
|
|
464
|
-
}
|
|
465
|
-
`;
|
|
246
|
+
load: {
|
|
247
|
+
order: "pre",
|
|
248
|
+
filter: { id: /* @__PURE__ */ new RegExp(`^${escapeRegExp(PREFIX$1)}`) },
|
|
249
|
+
handler: async (id) => {
|
|
250
|
+
const idNoPrefix = id.slice(15);
|
|
251
|
+
const mod = modules.get(idNoPrefix);
|
|
252
|
+
if (!mod) throw new Error(`Virtual module ${idNoPrefix} not found.`);
|
|
253
|
+
return {
|
|
254
|
+
code: await mod.render(),
|
|
255
|
+
map: null
|
|
256
|
+
};
|
|
257
|
+
}
|
|
466
258
|
}
|
|
467
|
-
}
|
|
259
|
+
};
|
|
468
260
|
}
|
|
469
261
|
|
|
470
262
|
//#endregion
|
|
471
|
-
//#region src/build/plugins/
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
const
|
|
485
|
-
|
|
486
|
-
assets[id] = {
|
|
487
|
-
fsPath,
|
|
488
|
-
meta: {}
|
|
489
|
-
};
|
|
490
|
-
let type = src_default.getType(id) || "text/plain";
|
|
491
|
-
if (type.startsWith("text")) type += "; charset=utf-8";
|
|
492
|
-
const etag = (0, import_etag.default)(await promises.readFile(fsPath));
|
|
493
|
-
const mtime = await promises.stat(fsPath).then((s) => s.mtime.toJSON());
|
|
494
|
-
assets[id].meta = {
|
|
495
|
-
type,
|
|
496
|
-
etag,
|
|
497
|
-
mtime
|
|
498
|
-
};
|
|
263
|
+
//#region src/build/plugins/resolve.ts
|
|
264
|
+
const subpathMap = {
|
|
265
|
+
"nitro/h3": "h3",
|
|
266
|
+
"nitro/deps/h3": "h3",
|
|
267
|
+
"nitro/deps/ofetch": "ofetch"
|
|
268
|
+
};
|
|
269
|
+
function nitroResolveIds() {
|
|
270
|
+
return {
|
|
271
|
+
name: "nitro:resolve-ids",
|
|
272
|
+
resolveId: {
|
|
273
|
+
order: "pre",
|
|
274
|
+
handler(id, importer, rOpts) {
|
|
275
|
+
if (importer && importer.startsWith("\0nitro:virtual:#nitro-internal-virtual")) return this.resolve(id, runtimeDir, { skipSelf: true });
|
|
276
|
+
const mappedId = subpathMap[id];
|
|
277
|
+
if (mappedId) return this.resolve(mappedId, runtimeDir, { skipSelf: true });
|
|
499
278
|
}
|
|
500
279
|
}
|
|
501
|
-
|
|
502
|
-
} }, nitro.vfs);
|
|
280
|
+
};
|
|
503
281
|
}
|
|
504
|
-
function getAssetsDev(nitro) {
|
|
505
|
-
return `
|
|
506
|
-
import { createStorage } from 'unstorage'
|
|
507
|
-
import fsDriver from 'unstorage/drivers/fs'
|
|
508
|
-
|
|
509
|
-
const serverAssets = ${JSON.stringify(nitro.options.serverAssets)}
|
|
510
282
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
283
|
+
//#endregion
|
|
284
|
+
//#region src/build/plugins/sourcemap-min.ts
|
|
285
|
+
function sourcemapMinify() {
|
|
286
|
+
return {
|
|
287
|
+
name: "nitro:sourcemap-minify",
|
|
288
|
+
generateBundle(_options, bundle) {
|
|
289
|
+
for (const [key, asset] of Object.entries(bundle)) {
|
|
290
|
+
if (!key.endsWith(".map") || !("source" in asset) || typeof asset.source !== "string") continue;
|
|
291
|
+
const sourcemap = JSON.parse(asset.source);
|
|
292
|
+
delete sourcemap.sourcesContent;
|
|
293
|
+
delete sourcemap.x_google_ignoreList;
|
|
294
|
+
if ((sourcemap.sources || []).some((s) => s.includes("node_modules"))) sourcemap.mappings = "";
|
|
295
|
+
asset.source = JSON.stringify(sourcemap);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
};
|
|
516
299
|
}
|
|
517
|
-
function getAssetProd(assets) {
|
|
518
|
-
return `
|
|
519
|
-
const _assets = {\n${Object.entries(assets).map(([id, asset]) => ` [${JSON.stringify(normalizeKey(id))}]: {\n import: () => import(${JSON.stringify("raw:" + asset.fsPath)}).then(r => r.default || r),\n meta: ${JSON.stringify(asset.meta)}\n }`).join(",\n")}\n}
|
|
520
|
-
|
|
521
|
-
const normalizeKey = ${normalizeKey.toString()}
|
|
522
300
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
301
|
+
//#endregion
|
|
302
|
+
//#region src/build/plugins/raw.ts
|
|
303
|
+
const HELPER_ID = "\0nitro-raw-helpers";
|
|
304
|
+
const RESOLVED_PREFIX = "\0nitro:raw:";
|
|
305
|
+
const PREFIX = "raw:";
|
|
306
|
+
function raw() {
|
|
307
|
+
return {
|
|
308
|
+
name: "nitro:raw",
|
|
309
|
+
resolveId: {
|
|
310
|
+
order: "pre",
|
|
311
|
+
filter: { id: [/* @__PURE__ */ new RegExp(`^${HELPER_ID}$`), /* @__PURE__ */ new RegExp(`^${PREFIX}`)] },
|
|
312
|
+
async handler(id, importer, resolveOpts) {
|
|
313
|
+
if (id === HELPER_ID) return id;
|
|
314
|
+
if (id.startsWith(PREFIX)) {
|
|
315
|
+
const resolvedId = (await this.resolve(id.slice(4), importer, resolveOpts))?.id;
|
|
316
|
+
if (!resolvedId) return null;
|
|
317
|
+
return { id: RESOLVED_PREFIX + resolvedId };
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
load: {
|
|
322
|
+
order: "pre",
|
|
323
|
+
filter: { id: [/* @__PURE__ */ new RegExp(`^${HELPER_ID}$`), /* @__PURE__ */ new RegExp(`^${RESOLVED_PREFIX}`)] },
|
|
324
|
+
handler(id) {
|
|
325
|
+
if (id === HELPER_ID) return getHelpers();
|
|
326
|
+
if (id.startsWith(RESOLVED_PREFIX)) return promises.readFile(id.slice(11), isBinary(id) ? "binary" : "utf8");
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
transform: {
|
|
330
|
+
order: "pre",
|
|
331
|
+
filter: { id: /* @__PURE__ */ new RegExp(`^${RESOLVED_PREFIX}`) },
|
|
332
|
+
handler(code, id) {
|
|
333
|
+
const path = id.slice(11);
|
|
334
|
+
if (isBinary(id)) return {
|
|
335
|
+
code: `import {base64ToUint8Array } from "${HELPER_ID}" \n export default base64ToUint8Array("${Buffer.from(code, "binary").toString("base64")}")`,
|
|
336
|
+
map: rawAssetMap(path)
|
|
337
|
+
};
|
|
338
|
+
return {
|
|
339
|
+
code: `export default ${JSON.stringify(code)}`,
|
|
340
|
+
map: rawAssetMap(path),
|
|
341
|
+
moduleType: "js"
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
function isBinary(id) {
|
|
348
|
+
const idMime = src_default.getType(id) || "";
|
|
349
|
+
if (idMime.startsWith("text/")) return false;
|
|
350
|
+
if (/application\/(json|sql|xml|yaml)/.test(idMime)) return false;
|
|
351
|
+
return true;
|
|
352
|
+
}
|
|
353
|
+
function getHelpers() {
|
|
354
|
+
return `
|
|
355
|
+
export function base64ToUint8Array(str) {
|
|
356
|
+
const data = atob(str);
|
|
357
|
+
const size = data.length;
|
|
358
|
+
const bytes = new Uint8Array(size);
|
|
359
|
+
for (let i = 0; i < size; i++) {
|
|
360
|
+
bytes[i] = data.charCodeAt(i);
|
|
538
361
|
}
|
|
362
|
+
return bytes;
|
|
539
363
|
}
|
|
540
|
-
`;
|
|
364
|
+
`;
|
|
365
|
+
}
|
|
366
|
+
function rawAssetMap(id) {
|
|
367
|
+
return {
|
|
368
|
+
version: 3,
|
|
369
|
+
file: id,
|
|
370
|
+
sources: [id],
|
|
371
|
+
sourcesContent: [],
|
|
372
|
+
names: [],
|
|
373
|
+
mappings: ""
|
|
374
|
+
};
|
|
541
375
|
}
|
|
542
376
|
|
|
543
377
|
//#endregion
|
|
544
|
-
//#region src/build/
|
|
545
|
-
function
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
driver: builtinDrivers[mount.driver] || mount.driver,
|
|
556
|
-
opts: mount
|
|
557
|
-
});
|
|
558
|
-
}
|
|
559
|
-
const driverImports = [...new Set(mounts.map((m) => m.driver))];
|
|
560
|
-
return virtual({ "#nitro-internal-virtual/storage": `
|
|
561
|
-
import { createStorage } from 'unstorage'
|
|
562
|
-
import { assets } from '#nitro-internal-virtual/server-assets'
|
|
563
|
-
|
|
564
|
-
${driverImports.map((i) => genImport(i, genSafeVariableName(i))).join("\n")}
|
|
378
|
+
//#region src/build/virtual/database.ts
|
|
379
|
+
function database(nitro) {
|
|
380
|
+
return {
|
|
381
|
+
id: "#nitro-internal-virtual/database",
|
|
382
|
+
template: () => {
|
|
383
|
+
if (!nitro.options.experimental.database) return `export const connectionConfigs = {};`;
|
|
384
|
+
const dbConfigs = nitro.options.dev && nitro.options.devDatabase || nitro.options.database;
|
|
385
|
+
const connectorsNames = [...new Set(Object.values(dbConfigs || {}).map((config) => config?.connector))].filter(Boolean);
|
|
386
|
+
for (const name of connectorsNames) if (!connectors[name]) throw new Error(`Database connector "${name}" is invalid.`);
|
|
387
|
+
return `
|
|
388
|
+
${connectorsNames.map((name) => `import ${camelCase(name)}Connector from "${connectors[name]}";`).join("\n")}
|
|
565
389
|
|
|
566
|
-
export
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
}
|
|
572
|
-
|
|
390
|
+
export const connectionConfigs = {
|
|
391
|
+
${Object.entries(dbConfigs || {}).filter(([, config]) => !!config?.connector).map(([name, { connector, options }]) => `${name}: {
|
|
392
|
+
connector: ${camelCase(connector)}Connector,
|
|
393
|
+
options: ${JSON.stringify(options)}
|
|
394
|
+
}`).join(",\n")}
|
|
395
|
+
};
|
|
396
|
+
`;
|
|
397
|
+
}
|
|
398
|
+
};
|
|
573
399
|
}
|
|
574
400
|
|
|
575
401
|
//#endregion
|
|
576
|
-
//#region src/build/
|
|
402
|
+
//#region src/build/virtual/error-handler.ts
|
|
577
403
|
function errorHandler(nitro) {
|
|
578
|
-
return
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
404
|
+
return {
|
|
405
|
+
id: "#nitro-internal-virtual/error-handler",
|
|
406
|
+
template: () => {
|
|
407
|
+
const errorHandlers = Array.isArray(nitro.options.errorHandler) ? nitro.options.errorHandler : [nitro.options.errorHandler];
|
|
408
|
+
const builtinHandler = join(runtimeDir, `internal/error/${nitro.options.dev ? "dev" : "prod"}`);
|
|
409
|
+
return `
|
|
582
410
|
${errorHandlers.map((h, i) => `import errorHandler$${i} from "${h}";`).join("\n")}
|
|
583
411
|
|
|
584
412
|
const errorHandlers = [${errorHandlers.map((_, i) => `errorHandler$${i}`).join(", ")}];
|
|
@@ -600,207 +428,517 @@ export default async function(error, event) {
|
|
|
600
428
|
// H3 will handle fallback
|
|
601
429
|
}
|
|
602
430
|
`;
|
|
603
|
-
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
//#endregion
|
|
436
|
+
//#region src/build/virtual/feature-flags.ts
|
|
437
|
+
function featureFlags(nitro) {
|
|
438
|
+
return {
|
|
439
|
+
id: "#nitro-internal-virtual/feature-flags",
|
|
440
|
+
template: () => {
|
|
441
|
+
const featureFlags$1 = {
|
|
442
|
+
hasRoutes: nitro.routing.routes.hasRoutes(),
|
|
443
|
+
hasRouteRules: nitro.routing.routeRules.hasRoutes(),
|
|
444
|
+
hasRoutedMiddleware: nitro.routing.routedMiddleware.hasRoutes(),
|
|
445
|
+
hasGlobalMiddleware: nitro.routing.globalMiddleware.length > 0,
|
|
446
|
+
hasPlugins: nitro.options.plugins.length > 0,
|
|
447
|
+
hasHooks: nitro.options.features?.runtimeHooks ?? nitro.options.plugins.length > 0,
|
|
448
|
+
hasWebSocket: nitro.options.features?.websocket ?? nitro.options.experimental.websocket ?? false
|
|
449
|
+
};
|
|
450
|
+
return Object.entries(featureFlags$1).map(([key, value]) => `export const ${key} = ${Boolean(value)};`).join("\n");
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
//#endregion
|
|
456
|
+
//#region src/build/virtual/plugins.ts
|
|
457
|
+
function plugins(nitro) {
|
|
458
|
+
return {
|
|
459
|
+
id: "#nitro-internal-virtual/plugins",
|
|
460
|
+
template: () => {
|
|
461
|
+
const nitroPlugins = [...new Set(nitro.options.plugins)];
|
|
462
|
+
return `
|
|
463
|
+
${nitroPlugins.map((plugin) => `import _${hash(plugin).replace(/-/g, "")} from "${plugin}";`).join("\n")}
|
|
464
|
+
|
|
465
|
+
export const plugins = [
|
|
466
|
+
${nitroPlugins.map((plugin) => `_${hash(plugin).replace(/-/g, "")}`).join(",\n")}
|
|
467
|
+
]
|
|
468
|
+
`;
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
//#endregion
|
|
474
|
+
//#region src/build/virtual/polyfills.ts
|
|
475
|
+
function polyfills(_nitro, polyfills$1) {
|
|
476
|
+
return {
|
|
477
|
+
id: "#nitro-internal-polyfills",
|
|
478
|
+
moduleSideEffects: true,
|
|
479
|
+
template: () => {
|
|
480
|
+
return polyfills$1.map((p) => `import '${p}';`).join("\n") || `/* No polyfills */`;
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
//#endregion
|
|
486
|
+
//#region src/build/virtual/public-assets.ts
|
|
487
|
+
var import_etag$1 = /* @__PURE__ */ __toESM(require_etag(), 1);
|
|
488
|
+
const readAssetHandler = {
|
|
489
|
+
true: "node",
|
|
490
|
+
node: "node",
|
|
491
|
+
false: "null",
|
|
492
|
+
deno: "deno",
|
|
493
|
+
inline: "inline"
|
|
494
|
+
};
|
|
495
|
+
function publicAssets(nitro) {
|
|
496
|
+
return [
|
|
497
|
+
{
|
|
498
|
+
id: "#nitro-internal-virtual/public-assets-data",
|
|
499
|
+
template: async () => {
|
|
500
|
+
const assets = {};
|
|
501
|
+
const files = await glob("**", {
|
|
502
|
+
cwd: nitro.options.output.publicDir,
|
|
503
|
+
absolute: false,
|
|
504
|
+
dot: true
|
|
505
|
+
});
|
|
506
|
+
for (const id of files) {
|
|
507
|
+
let mimeType = src_default.getType(id.replace(/\.(gz|br)$/, "")) || "text/plain";
|
|
508
|
+
if (mimeType.startsWith("text")) mimeType += "; charset=utf-8";
|
|
509
|
+
const fullPath = resolve(nitro.options.output.publicDir, id);
|
|
510
|
+
const assetData = await promises.readFile(fullPath);
|
|
511
|
+
const etag = (0, import_etag$1.default)(assetData);
|
|
512
|
+
const stat$2 = await promises.stat(fullPath);
|
|
513
|
+
const assetId = joinURL(nitro.options.baseURL, decodeURIComponent(id));
|
|
514
|
+
let encoding;
|
|
515
|
+
if (id.endsWith(".gz")) encoding = "gzip";
|
|
516
|
+
else if (id.endsWith(".br")) encoding = "br";
|
|
517
|
+
assets[assetId] = {
|
|
518
|
+
type: nitro._prerenderMeta?.[assetId]?.contentType || mimeType,
|
|
519
|
+
encoding,
|
|
520
|
+
etag,
|
|
521
|
+
mtime: stat$2.mtime.toJSON(),
|
|
522
|
+
size: stat$2.size,
|
|
523
|
+
path: relative(nitro.options.output.serverDir, fullPath),
|
|
524
|
+
data: nitro.options.serveStatic === "inline" ? assetData.toString("base64") : void 0
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
return `export default ${JSON.stringify(assets, null, 2)};`;
|
|
528
|
+
}
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
id: "#nitro-internal-virtual/public-assets",
|
|
532
|
+
template: () => {
|
|
533
|
+
const publicAssetBases = Object.fromEntries(nitro.options.publicAssets.filter((dir) => !dir.fallthrough && dir.baseURL !== "/").map((dir) => [withTrailingSlash(joinURL(nitro.options.baseURL, dir.baseURL || "/")), { maxAge: dir.maxAge }]));
|
|
534
|
+
return `
|
|
535
|
+
import assets from '#nitro-internal-virtual/public-assets-data'
|
|
536
|
+
export { readAsset } from "${`#nitro-internal-virtual/public-assets-${readAssetHandler[nitro.options.serveStatic] || "null"}`}"
|
|
537
|
+
export const publicAssetBases = ${JSON.stringify(publicAssetBases)}
|
|
538
|
+
|
|
539
|
+
export function isPublicAssetURL(id = '') {
|
|
540
|
+
if (assets[id]) {
|
|
541
|
+
return true
|
|
542
|
+
}
|
|
543
|
+
for (const base in publicAssetBases) {
|
|
544
|
+
if (id.startsWith(base)) { return true }
|
|
545
|
+
}
|
|
546
|
+
return false
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
export function getPublicAssetMeta(id = '') {
|
|
550
|
+
for (const base in publicAssetBases) {
|
|
551
|
+
if (id.startsWith(base)) { return publicAssetBases[base] }
|
|
552
|
+
}
|
|
553
|
+
return {}
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
export function getAsset (id) {
|
|
557
|
+
return assets[id]
|
|
558
|
+
}
|
|
559
|
+
`;
|
|
560
|
+
}
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
id: "#nitro-internal-virtual/public-assets-node",
|
|
564
|
+
template: () => {
|
|
565
|
+
return `
|
|
566
|
+
import { promises as fsp } from 'node:fs'
|
|
567
|
+
import { fileURLToPath } from 'node:url'
|
|
568
|
+
import { resolve, dirname } from 'node:path'
|
|
569
|
+
import assets from '#nitro-internal-virtual/public-assets-data'
|
|
570
|
+
export function readAsset (id) {
|
|
571
|
+
const serverDir = dirname(fileURLToPath(globalThis.__nitro_main__))
|
|
572
|
+
return fsp.readFile(resolve(serverDir, assets[id].path))
|
|
573
|
+
}`;
|
|
574
|
+
}
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
id: "#nitro-internal-virtual/public-assets-deno",
|
|
578
|
+
template: () => {
|
|
579
|
+
return `
|
|
580
|
+
import assets from '#nitro-internal-virtual/public-assets-data'
|
|
581
|
+
export function readAsset (id) {
|
|
582
|
+
// https://deno.com/deploy/docs/serve-static-assets
|
|
583
|
+
const path = '.' + decodeURIComponent(new URL(\`../public\${id}\`, 'file://').pathname)
|
|
584
|
+
return Deno.readFile(path);
|
|
585
|
+
}`;
|
|
586
|
+
}
|
|
587
|
+
},
|
|
588
|
+
{
|
|
589
|
+
id: "#nitro-internal-virtual/public-assets-null",
|
|
590
|
+
template: () => {
|
|
591
|
+
return `
|
|
592
|
+
export function readAsset (id) {
|
|
593
|
+
return Promise.resolve(null);
|
|
594
|
+
}`;
|
|
595
|
+
}
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
id: "#nitro-internal-virtual/public-assets-inline",
|
|
599
|
+
template: () => {
|
|
600
|
+
return `
|
|
601
|
+
import assets from '#nitro-internal-virtual/public-assets-data'
|
|
602
|
+
export function readAsset (id) {
|
|
603
|
+
if (!assets[id]) { return undefined }
|
|
604
|
+
if (assets[id]._data) { return assets[id]._data }
|
|
605
|
+
if (!assets[id].data) { return assets[id].data }
|
|
606
|
+
assets[id]._data = Uint8Array.from(atob(assets[id].data), (c) => c.charCodeAt(0))
|
|
607
|
+
return assets[id]._data
|
|
608
|
+
}`;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
];
|
|
604
612
|
}
|
|
605
613
|
|
|
606
614
|
//#endregion
|
|
607
|
-
//#region src/build/
|
|
615
|
+
//#region src/build/virtual/renderer-template.ts
|
|
608
616
|
function rendererTemplate(nitro) {
|
|
609
|
-
return
|
|
610
|
-
|
|
611
|
-
|
|
617
|
+
return {
|
|
618
|
+
id: "#nitro-internal-virtual/renderer-template",
|
|
619
|
+
template: async () => {
|
|
620
|
+
const template = nitro.options.renderer?.template;
|
|
621
|
+
if (typeof template !== "string") return `
|
|
612
622
|
export const rendererTemplate = () => '<!-- renderer.template is not set -->';
|
|
613
623
|
export const rendererTemplateFile = undefined;
|
|
614
624
|
export const isStaticTemplate = true;`;
|
|
615
|
-
|
|
625
|
+
if (nitro.options.dev) return `
|
|
616
626
|
import { readFile } from 'node:fs/promises';
|
|
617
627
|
export const rendererTemplate = () => readFile(${JSON.stringify(template)}, "utf8");
|
|
618
628
|
export const rendererTemplateFile = ${JSON.stringify(template)};
|
|
619
629
|
export const isStaticTemplate = ${JSON.stringify(nitro.options.renderer?.static)};
|
|
620
630
|
`;
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
631
|
+
else {
|
|
632
|
+
const html = await readFile(template, "utf8");
|
|
633
|
+
if (nitro.options.renderer?.static ?? !hasTemplateSyntax(html)) return `
|
|
624
634
|
import { HTTPResponse } from "h3";
|
|
625
635
|
export const rendererTemplate = () => new HTTPResponse(${JSON.stringify(html)}, { headers: { "content-type": "text/html; charset=utf-8" } });
|
|
626
636
|
`;
|
|
627
|
-
|
|
637
|
+
else return `
|
|
628
638
|
import { renderToResponse } from 'rendu'
|
|
629
639
|
import { serverFetch } from 'nitro/app'
|
|
630
640
|
const template = ${compileTemplateToString(html, { contextKeys: [...RENDER_CONTEXT_KEYS] })};
|
|
631
641
|
export const rendererTemplate = (request) => renderToResponse(template, { request, context: { serverFetch } })
|
|
632
642
|
`;
|
|
643
|
+
}
|
|
633
644
|
}
|
|
634
|
-
}
|
|
645
|
+
};
|
|
635
646
|
}
|
|
636
647
|
|
|
637
648
|
//#endregion
|
|
638
|
-
//#region src/build/
|
|
639
|
-
function
|
|
640
|
-
return
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
}
|
|
649
|
+
//#region src/build/virtual/routing-meta.ts
|
|
650
|
+
function routingMeta(nitro) {
|
|
651
|
+
return {
|
|
652
|
+
id: "#nitro-internal-virtual/routing-meta",
|
|
653
|
+
template: () => {
|
|
654
|
+
const routeHandlers = uniqueBy$1(Object.values(nitro.routing.routes.routes).flatMap((h) => h.data), "_importHash");
|
|
655
|
+
return `
|
|
656
|
+
${routeHandlers.map((h) => `import ${h._importHash}Meta from "${h.handler}?meta";`).join("\n")}
|
|
657
|
+
export const handlersMeta = [
|
|
658
|
+
${routeHandlers.map((h) => `{ route: ${JSON.stringify(h.route)}, method: ${JSON.stringify(h.method?.toLowerCase())}, meta: ${h._importHash}Meta }`).join(",\n")}
|
|
659
|
+
];
|
|
660
|
+
`.trim();
|
|
661
|
+
}
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
function uniqueBy$1(arr, key) {
|
|
665
|
+
return [...new Map(arr.map((item) => [item[key], item])).values()];
|
|
652
666
|
}
|
|
653
667
|
|
|
654
668
|
//#endregion
|
|
655
|
-
//#region src/build/
|
|
656
|
-
const
|
|
657
|
-
"
|
|
658
|
-
"
|
|
659
|
-
"
|
|
660
|
-
|
|
661
|
-
|
|
669
|
+
//#region src/build/virtual/routing.ts
|
|
670
|
+
const RuntimeRouteRules = [
|
|
671
|
+
"headers",
|
|
672
|
+
"redirect",
|
|
673
|
+
"proxy",
|
|
674
|
+
"cache"
|
|
675
|
+
];
|
|
676
|
+
function routing(nitro) {
|
|
662
677
|
return {
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
678
|
+
id: "#nitro-internal-virtual/routing",
|
|
679
|
+
template: () => {
|
|
680
|
+
const allHandlers = uniqueBy([
|
|
681
|
+
...Object.values(nitro.routing.routes.routes).flatMap((h) => h.data),
|
|
682
|
+
...Object.values(nitro.routing.routedMiddleware.routes).map((h) => h.data),
|
|
683
|
+
...nitro.routing.globalMiddleware
|
|
684
|
+
], "_importHash");
|
|
685
|
+
return `
|
|
686
|
+
import * as __routeRules__ from "nitro/~internal/runtime/route-rules";
|
|
687
|
+
import * as srvxNode from "srvx/node"
|
|
688
|
+
import * as h3 from "h3";
|
|
689
|
+
|
|
690
|
+
export const findRouteRules = ${nitro.routing.routeRules.compileToString({
|
|
691
|
+
serialize: serializeRouteRule,
|
|
692
|
+
matchAll: true
|
|
693
|
+
})}
|
|
694
|
+
|
|
695
|
+
const multiHandler = (...handlers) => {
|
|
696
|
+
const final = handlers.pop()
|
|
697
|
+
const middleware = handlers.filter(Boolean).map(h => h3.toMiddleware(h));
|
|
698
|
+
return (ev) => h3.callMiddleware(ev, middleware, final);
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
${allHandlers.filter((h) => !h.lazy).map((h) => `import ${h._importHash} from "${h.handler}";`).join("\n")}
|
|
702
|
+
|
|
703
|
+
${allHandlers.filter((h) => h.lazy).map((h) => `const ${h._importHash} = h3.defineLazyEventHandler(() => import("${h.handler}")${h.format === "node" ? ".then(m => srvxNode.toFetchHandler(m.default))" : ""});`).join("\n")}
|
|
704
|
+
|
|
705
|
+
export const findRoute = ${nitro.routing.routes.compileToString({ serialize: serializeHandler })}
|
|
706
|
+
|
|
707
|
+
export const findRoutedMiddleware = ${nitro.routing.routedMiddleware.compileToString({
|
|
708
|
+
serialize: serializeHandler,
|
|
709
|
+
matchAll: true
|
|
710
|
+
})};
|
|
711
|
+
|
|
712
|
+
export const globalMiddleware = [
|
|
713
|
+
${nitro.routing.globalMiddleware.map((h) => h.lazy ? h._importHash : `h3.toEventHandler(${h._importHash})`).join(",")}
|
|
714
|
+
].filter(Boolean);
|
|
715
|
+
`;
|
|
671
716
|
}
|
|
672
717
|
};
|
|
673
718
|
}
|
|
719
|
+
function uniqueBy(arr, key) {
|
|
720
|
+
return [...new Map(arr.map((item) => [item[key], item])).values()];
|
|
721
|
+
}
|
|
722
|
+
function serializeHandler(h) {
|
|
723
|
+
const meta = Array.isArray(h) ? h[0] : h;
|
|
724
|
+
return `{${[
|
|
725
|
+
`route:${JSON.stringify(meta.route)}`,
|
|
726
|
+
meta.method && `method:${JSON.stringify(meta.method)}`,
|
|
727
|
+
meta.meta && `meta:${JSON.stringify(meta.meta)}`,
|
|
728
|
+
`handler:${Array.isArray(h) ? `multiHandler(${h.map((handler) => serializeHandlerFn(handler)).join(",")})` : serializeHandlerFn(h)}`
|
|
729
|
+
].filter(Boolean).join(",")}}`;
|
|
730
|
+
}
|
|
731
|
+
function serializeHandlerFn(h) {
|
|
732
|
+
let code = h._importHash;
|
|
733
|
+
if (!h.lazy) {
|
|
734
|
+
if (h.format === "node") code = `srvxNode.toFetchHandler(${code})`;
|
|
735
|
+
code = `h3.toEventHandler(${code})`;
|
|
736
|
+
}
|
|
737
|
+
return code;
|
|
738
|
+
}
|
|
739
|
+
function serializeRouteRule(h) {
|
|
740
|
+
return `[${Object.entries(h).filter(([name, options]) => options !== void 0 && name[0] !== "_").map(([name, options]) => {
|
|
741
|
+
return `{${[
|
|
742
|
+
`name:${JSON.stringify(name)}`,
|
|
743
|
+
`route:${JSON.stringify(h._route)}`,
|
|
744
|
+
h._method && `method:${JSON.stringify(h._method)}`,
|
|
745
|
+
RuntimeRouteRules.includes(name) && `handler:__routeRules__.${name}`,
|
|
746
|
+
`options:${JSON.stringify(options)}`
|
|
747
|
+
].filter(Boolean).join(",")}}`;
|
|
748
|
+
}).join(",")}]`;
|
|
749
|
+
}
|
|
674
750
|
|
|
675
751
|
//#endregion
|
|
676
|
-
//#region src/build/
|
|
677
|
-
function
|
|
752
|
+
//#region src/build/virtual/runtime-config.ts
|
|
753
|
+
function runtimeConfig(nitro) {
|
|
678
754
|
return {
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
if (!key.endsWith(".map") || !("source" in asset) || typeof asset.source !== "string") continue;
|
|
683
|
-
const sourcemap = JSON.parse(asset.source);
|
|
684
|
-
delete sourcemap.sourcesContent;
|
|
685
|
-
delete sourcemap.x_google_ignoreList;
|
|
686
|
-
if ((sourcemap.sources || []).some((s) => s.includes("node_modules"))) sourcemap.mappings = "";
|
|
687
|
-
asset.source = JSON.stringify(sourcemap);
|
|
688
|
-
}
|
|
755
|
+
id: "#nitro-internal-virtual/runtime-config",
|
|
756
|
+
template: () => {
|
|
757
|
+
return `export const runtimeConfig = ${JSON.stringify(nitro.options.runtimeConfig || {})};`;
|
|
689
758
|
}
|
|
690
759
|
};
|
|
691
760
|
}
|
|
692
761
|
|
|
693
762
|
//#endregion
|
|
694
|
-
//#region src/build/
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
function raw() {
|
|
763
|
+
//#region src/build/virtual/server-assets.ts
|
|
764
|
+
var import_etag = /* @__PURE__ */ __toESM(require_etag(), 1);
|
|
765
|
+
function serverAssets(nitro) {
|
|
698
766
|
return {
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
767
|
+
id: "#nitro-internal-virtual/server-assets",
|
|
768
|
+
template: async () => {
|
|
769
|
+
if (nitro.options.dev || nitro.options.preset === "nitro-prerender") return `
|
|
770
|
+
import { createStorage } from 'unstorage'
|
|
771
|
+
import fsDriver from 'unstorage/drivers/fs'
|
|
772
|
+
const serverAssets = ${JSON.stringify(nitro.options.serverAssets)}
|
|
773
|
+
export const assets = createStorage()
|
|
774
|
+
for (const asset of serverAssets) {
|
|
775
|
+
assets.mount(asset.baseName, fsDriver({ base: asset.dir, ignore: (asset?.ignore || []) }))
|
|
776
|
+
}`;
|
|
777
|
+
const assets = {};
|
|
778
|
+
for (const asset of nitro.options.serverAssets) {
|
|
779
|
+
const files = await glob(asset.pattern || "**/*", {
|
|
780
|
+
cwd: asset.dir,
|
|
781
|
+
absolute: false,
|
|
782
|
+
ignore: asset.ignore
|
|
783
|
+
});
|
|
784
|
+
for (const _id of files) {
|
|
785
|
+
const fsPath = resolve(asset.dir, _id);
|
|
786
|
+
const id = asset.baseName + "/" + _id;
|
|
787
|
+
assets[id] = {
|
|
788
|
+
fsPath,
|
|
789
|
+
meta: {}
|
|
790
|
+
};
|
|
791
|
+
let type = src_default.getType(id) || "text/plain";
|
|
792
|
+
if (type.startsWith("text")) type += "; charset=utf-8";
|
|
793
|
+
const etag = (0, import_etag.default)(await promises.readFile(fsPath));
|
|
794
|
+
const mtime = await promises.stat(fsPath).then((s) => s.mtime.toJSON());
|
|
795
|
+
assets[id].meta = {
|
|
796
|
+
type,
|
|
797
|
+
etag,
|
|
798
|
+
mtime
|
|
799
|
+
};
|
|
800
|
+
}
|
|
728
801
|
}
|
|
802
|
+
return `
|
|
803
|
+
const _assets = {\n${Object.entries(assets).map(([id, asset]) => ` [${JSON.stringify(normalizeKey(id))}]: {\n import: () => import(${JSON.stringify("raw:" + asset.fsPath)}).then(r => r.default || r),\n meta: ${JSON.stringify(asset.meta)}\n }`).join(",\n")}\n}
|
|
804
|
+
|
|
805
|
+
const normalizeKey = ${normalizeKey.toString()}
|
|
806
|
+
|
|
807
|
+
export const assets = {
|
|
808
|
+
getKeys() {
|
|
809
|
+
return Promise.resolve(Object.keys(_assets))
|
|
810
|
+
},
|
|
811
|
+
hasItem (id) {
|
|
812
|
+
id = normalizeKey(id)
|
|
813
|
+
return Promise.resolve(id in _assets)
|
|
814
|
+
},
|
|
815
|
+
getItem (id) {
|
|
816
|
+
id = normalizeKey(id)
|
|
817
|
+
return Promise.resolve(_assets[id] ? _assets[id].import() : null)
|
|
818
|
+
},
|
|
819
|
+
getMeta (id) {
|
|
820
|
+
id = normalizeKey(id)
|
|
821
|
+
return Promise.resolve(_assets[id] ? _assets[id].meta : {})
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
`;
|
|
729
825
|
}
|
|
730
826
|
};
|
|
731
827
|
}
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
return
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
828
|
+
|
|
829
|
+
//#endregion
|
|
830
|
+
//#region src/build/virtual/storage.ts
|
|
831
|
+
function storage(nitro) {
|
|
832
|
+
return {
|
|
833
|
+
id: "#nitro-internal-virtual/storage",
|
|
834
|
+
template: () => {
|
|
835
|
+
const mounts = [];
|
|
836
|
+
const storageMounts = nitro.options.dev || nitro.options.preset === "nitro-prerender" ? {
|
|
837
|
+
...nitro.options.storage,
|
|
838
|
+
...nitro.options.devStorage
|
|
839
|
+
} : nitro.options.storage;
|
|
840
|
+
for (const path in storageMounts) {
|
|
841
|
+
const { driver: driverName, ...driverOpts } = storageMounts[path];
|
|
842
|
+
mounts.push({
|
|
843
|
+
path,
|
|
844
|
+
driver: builtinDrivers[driverName] || driverName,
|
|
845
|
+
opts: driverOpts
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
return `
|
|
849
|
+
import { createStorage } from 'unstorage'
|
|
850
|
+
import { assets } from '#nitro-internal-virtual/server-assets'
|
|
851
|
+
|
|
852
|
+
${[...new Set(mounts.map((m) => m.driver))].map((i) => genImport(i, genSafeVariableName(i))).join("\n")}
|
|
853
|
+
|
|
854
|
+
export function initStorage() {
|
|
855
|
+
const storage = createStorage({})
|
|
856
|
+
storage.mount('/assets', assets)
|
|
857
|
+
${mounts.map((m) => `storage.mount('${m.path}', ${genSafeVariableName(m.driver)}(${JSON.stringify(m.opts)}))`).join("\n")}
|
|
858
|
+
return storage
|
|
748
859
|
}
|
|
749
|
-
|
|
860
|
+
`;
|
|
861
|
+
}
|
|
862
|
+
};
|
|
750
863
|
}
|
|
751
|
-
|
|
864
|
+
|
|
865
|
+
//#endregion
|
|
866
|
+
//#region src/build/virtual/tasks.ts
|
|
867
|
+
function tasks(nitro) {
|
|
752
868
|
return {
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
869
|
+
id: "#nitro-internal-virtual/tasks",
|
|
870
|
+
template: () => {
|
|
871
|
+
const _scheduledTasks = Object.entries(nitro.options.scheduledTasks || {}).map(([cron, _tasks]) => {
|
|
872
|
+
return {
|
|
873
|
+
cron,
|
|
874
|
+
tasks: (Array.isArray(_tasks) ? _tasks : [_tasks]).filter((name) => {
|
|
875
|
+
if (!nitro.options.tasks[name]) {
|
|
876
|
+
nitro.logger.warn(`Scheduled task \`${name}\` is not defined!`);
|
|
877
|
+
return false;
|
|
878
|
+
}
|
|
879
|
+
return true;
|
|
880
|
+
})
|
|
881
|
+
};
|
|
882
|
+
}).filter((e) => e.tasks.length > 0);
|
|
883
|
+
const scheduledTasks = _scheduledTasks.length > 0 ? _scheduledTasks : false;
|
|
884
|
+
return `
|
|
885
|
+
export const scheduledTasks = ${JSON.stringify(scheduledTasks)};
|
|
886
|
+
|
|
887
|
+
export const tasks = {
|
|
888
|
+
${Object.entries(nitro.options.tasks).map(([name, task]) => `"${name}": {
|
|
889
|
+
meta: {
|
|
890
|
+
description: ${JSON.stringify(task.description)},
|
|
891
|
+
},
|
|
892
|
+
resolve: ${task.handler ? `() => import("${normalize(task.handler)}").then(r => r.default || r)` : "undefined"},
|
|
893
|
+
}`).join(",\n")}
|
|
894
|
+
};`;
|
|
895
|
+
}
|
|
759
896
|
};
|
|
760
897
|
}
|
|
761
898
|
|
|
762
899
|
//#endregion
|
|
763
|
-
//#region src/build/
|
|
764
|
-
function
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
900
|
+
//#region src/build/virtual/_all.ts
|
|
901
|
+
function virtualTemplates(nitro, _polyfills) {
|
|
902
|
+
const nitroTemplates = [
|
|
903
|
+
database,
|
|
904
|
+
errorHandler,
|
|
905
|
+
featureFlags,
|
|
906
|
+
plugins,
|
|
907
|
+
polyfills,
|
|
908
|
+
publicAssets,
|
|
909
|
+
rendererTemplate,
|
|
910
|
+
routingMeta,
|
|
911
|
+
routing,
|
|
912
|
+
runtimeConfig,
|
|
913
|
+
serverAssets,
|
|
914
|
+
storage,
|
|
915
|
+
tasks
|
|
916
|
+
].flatMap((t) => t(nitro, _polyfills));
|
|
917
|
+
const customTemplates = Object.entries(nitro.options.virtual).map(([id, template]) => ({
|
|
918
|
+
id,
|
|
919
|
+
template
|
|
920
|
+
}));
|
|
921
|
+
return [...nitroTemplates, ...customTemplates];
|
|
768
922
|
}
|
|
769
923
|
|
|
770
924
|
//#endregion
|
|
771
925
|
//#region src/build/plugins.ts
|
|
772
926
|
function baseBuildPlugins(nitro, base) {
|
|
773
|
-
const plugins = [];
|
|
774
|
-
if (nitro.options.imports) plugins.push(unplugin.rollup(nitro.options.imports));
|
|
775
|
-
if (nitro.options.wasm !== false) plugins.push(unwasm(nitro.options.wasm || {}));
|
|
776
|
-
plugins.push(serverMain(nitro));
|
|
777
|
-
|
|
778
|
-
plugins.push(
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
` }, nitro.vfs));
|
|
785
|
-
plugins.push(featureFlags(nitro));
|
|
786
|
-
plugins.push(nitroResolveIds());
|
|
787
|
-
plugins.push(serverAssets(nitro));
|
|
788
|
-
plugins.push(publicAssets(nitro));
|
|
789
|
-
plugins.push(storage(nitro));
|
|
790
|
-
plugins.push(database(nitro));
|
|
791
|
-
plugins.push(routing(nitro));
|
|
792
|
-
plugins.push(raw());
|
|
793
|
-
if (nitro.options.experimental.openAPI) plugins.push(routeMeta(nitro));
|
|
794
|
-
plugins.push(runtimeConfig(nitro));
|
|
795
|
-
plugins.push(errorHandler(nitro));
|
|
796
|
-
plugins.push(virtual({ "#nitro-internal-pollyfills": base.env.polyfill.map((p) => `import '${p}';`).join("\n") || `/* No polyfills */` }, nitro.vfs, { moduleSideEffects: true }));
|
|
797
|
-
plugins.push(virtual(nitro.options.virtual, nitro.vfs));
|
|
798
|
-
if (nitro.options.renderer?.template) plugins.push(rendererTemplate(nitro));
|
|
799
|
-
plugins.push(replace({
|
|
927
|
+
const plugins$1 = [];
|
|
928
|
+
if (nitro.options.imports) plugins$1.push(unplugin.rollup(nitro.options.imports));
|
|
929
|
+
if (nitro.options.wasm !== false) plugins$1.push(unwasm(nitro.options.wasm || {}));
|
|
930
|
+
plugins$1.push(serverMain(nitro));
|
|
931
|
+
plugins$1.push(nitroResolveIds());
|
|
932
|
+
plugins$1.push(raw());
|
|
933
|
+
if (nitro.options.experimental.openAPI) plugins$1.push(routeMeta(nitro));
|
|
934
|
+
const virtualPlugin = virtual(virtualTemplates(nitro, [...base.env.polyfill]));
|
|
935
|
+
nitro.vfs = virtualPlugin.api.modules;
|
|
936
|
+
plugins$1.push(virtualPlugin);
|
|
937
|
+
plugins$1.push(replace({
|
|
800
938
|
preventAssignment: true,
|
|
801
939
|
values: base.replacements
|
|
802
940
|
}));
|
|
803
|
-
if (!nitro.options.noExternals) plugins.push(rollupNodeFileTrace(defu(nitro.options.externals, {
|
|
941
|
+
if (!nitro.options.noExternals) plugins$1.push(rollupNodeFileTrace(defu(nitro.options.externals, {
|
|
804
942
|
outDir: nitro.options.output.serverDir,
|
|
805
943
|
moduleDirectories: nitro.options.nodeModulesDirs,
|
|
806
944
|
external: nitro.options.nodeModulesDirs,
|
|
@@ -817,8 +955,8 @@ function baseBuildPlugins(nitro, base) {
|
|
|
817
955
|
exportConditions: nitro.options.exportConditions,
|
|
818
956
|
writePackageJson: true
|
|
819
957
|
})));
|
|
820
|
-
if (nitro.options.sourcemap && !nitro.options.dev && nitro.options.experimental.sourcemapMinify !== false) plugins.push(sourcemapMinify());
|
|
821
|
-
return plugins;
|
|
958
|
+
if (nitro.options.sourcemap && !nitro.options.dev && nitro.options.experimental.sourcemapMinify !== false) plugins$1.push(sourcemapMinify());
|
|
959
|
+
return plugins$1;
|
|
822
960
|
}
|
|
823
961
|
|
|
824
962
|
//#endregion
|