nitro 3.0.1-alpha.2 → 3.0.260311-beta
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/LICENSE +6 -0
- package/README.md +2 -2
- package/dist/THIRD-PARTY-LICENSES.md +1646 -0
- package/dist/_build/common.mjs +6977 -2556
- package/dist/_build/rolldown.mjs +32 -31
- package/dist/_build/rollup.mjs +28 -35
- package/dist/_build/vite.build.mjs +10 -8
- package/dist/_chunks/nitro.mjs +80 -112
- package/dist/_chunks/nitro2.mjs +8 -7
- package/dist/_chunks/nitro3.mjs +129 -0
- package/dist/_chunks/utils.mjs +42 -24
- package/dist/_common.mjs +14 -24
- package/dist/{_chunks/dev.mjs → _dev.mjs} +132 -320
- package/dist/_libs/_.mjs +3 -0
- package/dist/_libs/_2.mjs +2 -0
- package/dist/_libs/_3.mjs +3 -0
- package/dist/_libs/_4.mjs +2 -0
- package/dist/_libs/_5.mjs +3 -0
- package/dist/_libs/_6.mjs +4 -0
- package/dist/_libs/_7.mjs +5 -0
- package/dist/_libs/c12+rc9.mjs +812 -0
- package/dist/_libs/{c12+giget+readdirp+chokidar.d.mts → c12+readdirp+chokidar.d.mts} +52 -36
- package/dist/_libs/citty.mjs +10 -12
- package/dist/_libs/commondir+is-reference.mjs +60 -49
- package/dist/_libs/compatx.mjs +1 -2
- package/dist/_libs/esbuild.d.mts +1 -1
- package/dist/_libs/escape-string-regexp.mjs +1 -2
- package/dist/_libs/{pluginutils+plugin-commonjs.d.mts → estree+pluginutils.d.mts} +2 -2
- package/dist/_libs/estree-walker.mjs +1 -4
- package/dist/_libs/exsolve.d.mts +1 -0
- package/dist/_libs/hasown+resolve+deepmerge.mjs +146 -169
- package/dist/_libs/httpxy.d.mts +12 -9
- package/dist/_libs/httpxy.mjs +299 -43
- package/dist/_libs/js-tokens.d.mts +1 -0
- package/dist/_libs/klona.mjs +1 -2
- package/dist/_libs/mlly.d.mts +1 -1
- package/dist/_libs/nypm+tinyexec.mjs +845 -0
- package/dist/_libs/perfect-debounce.mjs +88 -0
- package/dist/_libs/plugin-alias.mjs +2 -4
- package/dist/_libs/plugin-inject.mjs +2 -6
- package/dist/_libs/plugin-json.mjs +2 -4
- package/dist/_libs/pluginutils.mjs +5 -11
- package/dist/_libs/readdirp+chokidar.mjs +187 -192
- package/dist/_libs/remapping.mjs +1 -3
- package/dist/_libs/resolve-uri+gen-mapping.mjs +15 -21
- package/dist/_libs/rou3.d.mts +3 -2
- package/dist/_libs/rou3.mjs +225 -51
- package/dist/_libs/std-env.d.mts +10 -2
- package/dist/_libs/strip-literal.d.mts +1 -0
- package/dist/_libs/tsconfck.mjs +21 -40
- package/dist/_libs/ultrahtml.mjs +3 -14
- package/dist/_libs/unimport+unplugin.mjs +250 -351
- package/dist/_libs/unplugin+unimport.d.mts +7 -10
- package/dist/_presets.mjs +389 -432
- package/dist/builder.d.mts +5 -4
- package/dist/builder.mjs +12 -6
- package/dist/cli/_chunks/build.mjs +22 -23
- package/dist/cli/_chunks/common.mjs +1 -2
- package/dist/cli/_chunks/deploy.mjs +40 -0
- package/dist/cli/_chunks/dev.mjs +9 -9
- package/dist/cli/_chunks/docs.mjs +30 -0
- package/dist/cli/_chunks/list.mjs +4 -6
- package/dist/cli/_chunks/prepare.mjs +2 -4
- package/dist/cli/_chunks/preview.mjs +51 -0
- package/dist/cli/_chunks/run.mjs +7 -9
- package/dist/cli/_chunks/task.mjs +1 -3
- package/dist/cli/index.mjs +5 -4
- package/dist/node_modules/@poppinss/dumper/build/formatters/html/main.js +8 -0
- package/dist/node_modules/@poppinss/dumper/package.json +1 -1
- package/dist/node_modules/croner/dist/croner.js +1 -1
- package/dist/node_modules/croner/package.json +11 -1
- package/dist/node_modules/youch/build/helpers-B9BQYaS6.js +23 -0
- package/dist/node_modules/youch/build/index.js +204 -351
- package/dist/node_modules/youch/build/public/error_info/script.js +1 -1
- package/dist/node_modules/youch/build/public_dir-C5bujZKB.js +25 -0
- package/dist/node_modules/youch/build/src/templates/error_cause/main.js +44 -0
- package/dist/node_modules/youch/build/src/templates/error_info/main.js +72 -0
- package/dist/node_modules/youch/build/src/templates/error_metadata/main.js +65 -0
- package/dist/node_modules/youch/build/src/templates/error_stack/main.js +152 -0
- package/dist/node_modules/youch/build/src/templates/error_stack_source/main.js +46 -0
- package/dist/node_modules/youch/build/src/templates/header/main.js +24 -0
- package/dist/node_modules/youch/build/src/templates/layout/main.js +27 -0
- package/dist/node_modules/youch/package.json +34 -31
- package/dist/presets/_nitro/runtime/nitro-dev.mjs +9 -56
- package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +1 -0
- package/dist/presets/_nitro/runtime/service-worker.mjs +0 -1
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +3 -1
- package/dist/presets/bun/runtime/bun.mjs +4 -3
- package/dist/presets/deno/runtime/deno-server.mjs +4 -3
- package/dist/presets/netlify/runtime/netlify-edge.mjs +0 -1
- package/dist/presets/netlify/runtime/netlify.mjs +1 -1
- package/dist/presets/node/runtime/node-cluster.mjs +3 -2
- package/dist/presets/node/runtime/node-server.mjs +3 -2
- package/dist/presets/stormkit/runtime/stormkit.mjs +0 -1
- package/dist/presets/vercel/runtime/cron-handler.mjs +25 -0
- package/dist/presets/vercel/runtime/vercel.web.mjs +2 -4
- package/dist/presets/zephyr/runtime/server.mjs +3 -0
- package/dist/runtime/internal/cache.d.mts +0 -4
- package/dist/runtime/internal/cache.mjs +32 -256
- package/dist/runtime/internal/context.d.mts +3 -1
- package/dist/runtime/internal/error/dev.d.mts +5 -4
- package/dist/runtime/internal/error/dev.mjs +38 -40
- package/dist/runtime/internal/error/hooks.d.mts +1 -1
- package/dist/runtime/internal/error/prod.d.mts +2 -5
- package/dist/runtime/internal/error/prod.mjs +19 -33
- package/dist/runtime/internal/error/utils.d.mts +4 -4
- package/dist/runtime/internal/meta.d.mts +1 -1
- package/dist/runtime/internal/plugin.d.mts +2 -2
- package/dist/runtime/internal/route-rules.d.mts +9 -4
- package/dist/runtime/internal/route-rules.mjs +9 -1
- package/dist/runtime/internal/routes/dev-tasks.d.mts +3 -2
- package/dist/runtime/internal/routes/dev-tasks.mjs +6 -2
- package/dist/runtime/internal/routes/renderer-template.d.mts +1 -1
- package/dist/runtime/internal/routes/renderer-template.dev.d.mts +2 -1
- package/dist/runtime/internal/runtime-config.d.mts +1 -1
- package/dist/runtime/internal/static.mjs +5 -4
- package/dist/runtime/internal/task.d.mts +3 -1
- package/dist/runtime/internal/task.mjs +2 -2
- package/dist/runtime/internal/vite/dev-entry.mjs +6 -3
- package/dist/runtime/internal/vite/dev-worker.mjs +264 -0
- package/dist/runtime/meta.mjs +1 -0
- package/dist/runtime/nitro.d.mts +2 -0
- package/dist/runtime/nitro.mjs +2 -0
- package/dist/runtime/virtual/error-handler.mjs +1 -1
- package/dist/runtime/virtual/server-assets.d.mts +2 -1
- package/dist/runtime/vite.d.mts +1 -1
- package/dist/types/index.d.mts +68 -117
- package/dist/types/index.mjs +1 -11
- package/dist/vite.d.mts +3 -3
- package/dist/vite.mjs +236 -233
- package/package.json +83 -68
- package/skills/nitro/SKILL.md +10 -0
- package/skills/nitro/docs/TOC.md +83 -0
- package/skills/nitro/docs/_navigation.json +679 -0
- package/skills/nitro/docs/config/index.md +1147 -0
- package/skills/nitro/docs/deploy/index.md +64 -0
- package/skills/nitro/docs/deploy/providers/alwaysdata.md +50 -0
- package/skills/nitro/docs/deploy/providers/aws-amplify.md +81 -0
- package/skills/nitro/docs/deploy/providers/aws.md +47 -0
- package/skills/nitro/docs/deploy/providers/azure.md +72 -0
- package/skills/nitro/docs/deploy/providers/cleavr.md +33 -0
- package/skills/nitro/docs/deploy/providers/cloudflare.md +375 -0
- package/skills/nitro/docs/deploy/providers/deno-deploy.md +66 -0
- package/skills/nitro/docs/deploy/providers/digitalocean.md +46 -0
- package/skills/nitro/docs/deploy/providers/firebase.md +32 -0
- package/skills/nitro/docs/deploy/providers/flightcontrol.md +67 -0
- package/skills/nitro/docs/deploy/providers/genezio.md +67 -0
- package/skills/nitro/docs/deploy/providers/github-pages.md +68 -0
- package/skills/nitro/docs/deploy/providers/gitlab-pages.md +37 -0
- package/skills/nitro/docs/deploy/providers/heroku.md +84 -0
- package/skills/nitro/docs/deploy/providers/iis.md +38 -0
- package/skills/nitro/docs/deploy/providers/koyeb.md +109 -0
- package/skills/nitro/docs/deploy/providers/netlify.md +47 -0
- package/skills/nitro/docs/deploy/providers/platform-sh.md +37 -0
- package/skills/nitro/docs/deploy/providers/render.md +37 -0
- package/skills/nitro/docs/deploy/providers/stormkit.md +24 -0
- package/skills/nitro/docs/deploy/providers/vercel.md +179 -0
- package/skills/nitro/docs/deploy/providers/zeabur.md +19 -0
- package/skills/nitro/docs/deploy/providers/zephyr.md +99 -0
- package/skills/nitro/docs/deploy/providers/zerops.md +102 -0
- package/skills/nitro/docs/deploy/runtimes/bun.md +15 -0
- package/skills/nitro/docs/deploy/runtimes/deno.md +19 -0
- package/skills/nitro/docs/deploy/runtimes/node.md +63 -0
- package/skills/nitro/docs/docs/assets.md +166 -0
- package/skills/nitro/docs/docs/cache.md +408 -0
- package/skills/nitro/docs/docs/configuration.md +256 -0
- package/skills/nitro/docs/docs/database.md +185 -0
- package/skills/nitro/docs/docs/index.md +56 -0
- package/skills/nitro/docs/docs/lifecycle.md +204 -0
- package/skills/nitro/docs/docs/migration.md +215 -0
- package/skills/nitro/docs/docs/nightly.md +31 -0
- package/skills/nitro/docs/docs/plugins.md +164 -0
- package/skills/nitro/docs/docs/quick-start.md +110 -0
- package/skills/nitro/docs/docs/renderer.md +322 -0
- package/skills/nitro/docs/docs/routing.md +711 -0
- package/skills/nitro/docs/docs/server-entry.md +239 -0
- package/skills/nitro/docs/docs/storage.md +261 -0
- package/skills/nitro/docs/docs/tasks.md +277 -0
- package/skills/nitro/docs/examples/api-routes.md +145 -0
- package/skills/nitro/docs/examples/auto-imports.md +93 -0
- package/skills/nitro/docs/examples/cached-handler.md +81 -0
- package/skills/nitro/docs/examples/custom-error-handler.md +98 -0
- package/skills/nitro/docs/examples/database.md +157 -0
- package/skills/nitro/docs/examples/elysia.md +70 -0
- package/skills/nitro/docs/examples/express.md +78 -0
- package/skills/nitro/docs/examples/fastify.md +79 -0
- package/skills/nitro/docs/examples/hello-world.md +68 -0
- package/skills/nitro/docs/examples/hono.md +74 -0
- package/skills/nitro/docs/examples/import-alias.md +100 -0
- package/skills/nitro/docs/examples/index.md +3 -0
- package/skills/nitro/docs/examples/middleware.md +91 -0
- package/skills/nitro/docs/examples/mono-jsx.md +68 -0
- package/skills/nitro/docs/examples/nano-jsx.md +70 -0
- package/skills/nitro/docs/examples/plugins.md +91 -0
- package/skills/nitro/docs/examples/renderer.md +113 -0
- package/skills/nitro/docs/examples/runtime-config.md +97 -0
- package/skills/nitro/docs/examples/server-fetch.md +87 -0
- package/skills/nitro/docs/examples/shiki.md +198 -0
- package/skills/nitro/docs/examples/virtual-routes.md +74 -0
- package/skills/nitro/docs/examples/vite-nitro-plugin.md +79 -0
- package/skills/nitro/docs/examples/vite-rsc.md +1041 -0
- package/skills/nitro/docs/examples/vite-ssr-html.md +217 -0
- package/skills/nitro/docs/examples/vite-ssr-preact.md +247 -0
- package/skills/nitro/docs/examples/vite-ssr-react.md +226 -0
- package/skills/nitro/docs/examples/vite-ssr-solid.md +256 -0
- package/skills/nitro/docs/examples/vite-ssr-tsr-react.md +442 -0
- package/skills/nitro/docs/examples/vite-ssr-tss-react.md +444 -0
- package/skills/nitro/docs/examples/vite-ssr-vue-router.md +616 -0
- package/skills/nitro/docs/examples/vite-trpc.md +335 -0
- package/skills/nitro/docs/examples/websocket.md +282 -0
- package/skills/nitro/docs/index.md +121 -0
- package/dist/_libs/confbox.mjs +0 -2509
- package/dist/_libs/nypm+giget+tinyexec.mjs +0 -3603
- package/dist/_libs/rc9+c12+dotenv.mjs +0 -972
- package/dist/node_modules/hookable/dist/index.mjs +0 -266
- package/dist/node_modules/hookable/package.json +0 -52
- package/dist/node_modules/youch/build/chunk-4L7RY2JA.js +0 -42
- package/dist/node_modules/youch/build/chunk-7QV3D5YX.js +0 -83
- package/dist/node_modules/youch/build/chunk-AUGPHE32.js +0 -39
- package/dist/node_modules/youch/build/chunk-CM7DWJNZ.js +0 -44
- package/dist/node_modules/youch/build/chunk-EJH674NB.js +0 -223
- package/dist/node_modules/youch/build/chunk-OIJ3WD7L.js +0 -81
- package/dist/node_modules/youch/build/chunk-P36L72PL.js +0 -87
- package/dist/node_modules/youch/build/chunk-PE3GG3TN.js +0 -65
- package/dist/node_modules/youch/build/chunk-X53OIOJH.js +0 -70
- package/dist/presets/_nitro/runtime/nitro-dev.d.mts +0 -2
- package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +0 -3
- package/dist/presets/_nitro/runtime/service-worker.d.mts +0 -2
- package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +0 -2
- package/dist/presets/aws-lambda/runtime/_utils.d.mts +0 -8
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +0 -2
- package/dist/presets/aws-lambda/runtime/aws-lambda.d.mts +0 -3
- package/dist/presets/azure/runtime/_utils.d.mts +0 -2
- package/dist/presets/azure/runtime/azure-swa.d.mts +0 -5
- package/dist/presets/bun/runtime/bun.d.mts +0 -3
- package/dist/presets/cloudflare/runtime/_module-handler.d.mts +0 -16
- package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +0 -11
- package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +0 -3
- package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +0 -20
- package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +0 -3
- package/dist/presets/deno/runtime/deno-deploy.d.mts +0 -5
- package/dist/presets/deno/runtime/deno-server.d.mts +0 -3
- package/dist/presets/netlify/runtime/netlify-edge.d.mts +0 -3
- package/dist/presets/netlify/runtime/netlify.d.mts +0 -4
- package/dist/presets/node/runtime/node-cluster.d.mts +0 -3
- package/dist/presets/node/runtime/node-middleware.d.mts +0 -3
- package/dist/presets/node/runtime/node-server.d.mts +0 -3
- package/dist/presets/standard/runtime/server.d.mts +0 -3
- package/dist/presets/stormkit/runtime/stormkit.d.mts +0 -21
- package/dist/presets/vercel/runtime/isr.d.mts +0 -2
- package/dist/presets/vercel/runtime/vercel.node.d.mts +0 -3
- package/dist/presets/vercel/runtime/vercel.web.d.mts +0 -8
- package/dist/presets/winterjs/runtime/winterjs.d.mts +0 -2
- package/dist/presets/zeabur/runtime/zeabur.d.mts +0 -3
- package/dist/runtime/internal/vite/node-runner.mjs +0 -359
package/dist/_build/rolldown.mjs
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import { _ as writeTypes, at as join, d as libChunkName, f as baseBuildConfig, h as writeBuildInfo, l as NODE_MODULES_RE, n as baseBuildPlugins, st as relative, u as getChunkName } from "./common.mjs";
|
|
3
|
-
import { i as debounce } from "../_libs/rc9+c12+dotenv.mjs";
|
|
1
|
+
import { _ as writeTypes, ct as join, d as libChunkName, f as baseBuildConfig, h as writeBuildInfo, it as basename, l as NODE_MODULES_RE, n as baseBuildPlugins, u as getChunkName, ut as relative } from "./common.mjs";
|
|
4
2
|
import { t as formatCompatibilityDate } from "../_libs/compatx.mjs";
|
|
5
3
|
import { n as scanHandlers } from "../_chunks/nitro2.mjs";
|
|
6
|
-
import { n as watch
|
|
7
|
-
import { t as
|
|
4
|
+
import { n as watch } from "../_libs/readdirp+chokidar.mjs";
|
|
5
|
+
import { t as debounce } from "../_libs/perfect-debounce.mjs";
|
|
6
|
+
import { n as generateFSTree } from "../_chunks/utils.mjs";
|
|
8
7
|
import { builtinModules } from "node:module";
|
|
9
|
-
import { watch } from "node:fs";
|
|
10
8
|
import { defu } from "defu";
|
|
11
|
-
|
|
12
9
|
//#region src/build/rolldown/config.ts
|
|
13
10
|
const getRolldownConfig = async (nitro) => {
|
|
14
11
|
const base = baseBuildConfig(nitro);
|
|
@@ -67,10 +64,12 @@ const getRolldownConfig = async (nitro) => {
|
|
|
67
64
|
};
|
|
68
65
|
config = defu(nitro.options.rolldownConfig, nitro.options.rollupConfig, config);
|
|
69
66
|
const outputConfig = config.output;
|
|
70
|
-
if (outputConfig.inlineDynamicImports || outputConfig.format === "iife")
|
|
67
|
+
if (outputConfig.inlineDynamicImports || outputConfig.format === "iife") {
|
|
68
|
+
delete outputConfig.inlineDynamicImports;
|
|
69
|
+
outputConfig.codeSplitting = false;
|
|
70
|
+
}
|
|
71
71
|
return config;
|
|
72
72
|
};
|
|
73
|
-
|
|
74
73
|
//#endregion
|
|
75
74
|
//#region src/build/rolldown/dev.ts
|
|
76
75
|
async function watchDev(nitro, config) {
|
|
@@ -97,11 +96,15 @@ async function watchDev(nitro, config) {
|
|
|
97
96
|
"unlink",
|
|
98
97
|
"unlinkDir"
|
|
99
98
|
]);
|
|
100
|
-
const scanDirsWatcher = watch
|
|
99
|
+
const scanDirsWatcher = watch(scanDirs, { ignoreInitial: true }).on("all", (event) => {
|
|
101
100
|
if (watchReloadEvents.has(event)) reload();
|
|
102
101
|
});
|
|
103
|
-
const
|
|
104
|
-
|
|
102
|
+
const serverEntryRe = /^server\.[mc]?[jt]sx?$/;
|
|
103
|
+
const rootDirWatcher = watch(nitro.options.rootDir, {
|
|
104
|
+
ignoreInitial: true,
|
|
105
|
+
depth: 0
|
|
106
|
+
}).on("all", (event, path) => {
|
|
107
|
+
if (watchReloadEvents.has(event) && serverEntryRe.test(basename(path))) reload();
|
|
105
108
|
});
|
|
106
109
|
nitro.hooks.hook("close", () => {
|
|
107
110
|
watcher.close();
|
|
@@ -109,31 +112,30 @@ async function watchDev(nitro, config) {
|
|
|
109
112
|
rootDirWatcher.close();
|
|
110
113
|
});
|
|
111
114
|
nitro.hooks.hook("rollup:reload", () => reload());
|
|
115
|
+
nitro.logger.info(`Starting dev watcher (builder: \`rolldown\`, preset: \`${nitro.options.preset}\`, compatibility date: \`${formatCompatibilityDate(nitro.options.compatibilityDate)}\`)`);
|
|
112
116
|
await load();
|
|
113
|
-
function startWatcher(nitro
|
|
114
|
-
const watcher
|
|
117
|
+
function startWatcher(nitro, config) {
|
|
118
|
+
const watcher = rolldown.watch(config);
|
|
115
119
|
let start;
|
|
116
|
-
watcher
|
|
120
|
+
watcher.on("event", (event) => {
|
|
117
121
|
switch (event.code) {
|
|
118
122
|
case "START":
|
|
119
123
|
start = Date.now();
|
|
120
|
-
nitro
|
|
121
|
-
nitro$1.hooks.callHook("dev:start");
|
|
124
|
+
nitro.hooks.callHook("dev:start");
|
|
122
125
|
break;
|
|
123
126
|
case "BUNDLE_END":
|
|
124
|
-
nitro
|
|
125
|
-
if (nitro
|
|
126
|
-
nitro
|
|
127
|
+
nitro.hooks.callHook("compiled", nitro);
|
|
128
|
+
if (nitro.options.logging.buildSuccess) nitro.logger.success(`Server built`, start ? `in ${Date.now() - start}ms` : "");
|
|
129
|
+
nitro.hooks.callHook("dev:reload");
|
|
127
130
|
break;
|
|
128
131
|
case "ERROR":
|
|
129
|
-
nitro
|
|
130
|
-
nitro
|
|
132
|
+
nitro.logger.error(event.error);
|
|
133
|
+
nitro.hooks.callHook("dev:error", event.error);
|
|
131
134
|
}
|
|
132
135
|
});
|
|
133
|
-
return watcher
|
|
136
|
+
return watcher;
|
|
134
137
|
}
|
|
135
138
|
}
|
|
136
|
-
|
|
137
139
|
//#endregion
|
|
138
140
|
//#region src/build/rolldown/prod.ts
|
|
139
141
|
async function buildProduction(nitro, config) {
|
|
@@ -141,11 +143,12 @@ async function buildProduction(nitro, config) {
|
|
|
141
143
|
const buildStartTime = Date.now();
|
|
142
144
|
await scanHandlers(nitro);
|
|
143
145
|
await writeTypes(nitro);
|
|
146
|
+
let output;
|
|
144
147
|
if (!nitro.options.static) {
|
|
145
148
|
nitro.logger.info(`Building server (builder: \`rolldown\`, preset: \`${nitro.options.preset}\`, compatibility date: \`${formatCompatibilityDate(nitro.options.compatibilityDate)}\`)`);
|
|
146
|
-
await (await rolldown.rolldown(config)).write(config.output);
|
|
149
|
+
output = await (await rolldown.rolldown(config)).write(config.output);
|
|
147
150
|
}
|
|
148
|
-
const buildInfo = await writeBuildInfo(nitro);
|
|
151
|
+
const buildInfo = await writeBuildInfo(nitro, output);
|
|
149
152
|
if (!nitro.options.static) {
|
|
150
153
|
if (nitro.options.logging.buildSuccess) nitro.logger.success(`Server built in ${Date.now() - buildStartTime}ms`);
|
|
151
154
|
if (nitro.options.logLevel > 1) process.stdout.write(await generateFSTree(nitro.options.output.serverDir, { compressedSizes: nitro.options.logging.compressedSizes }) || "");
|
|
@@ -155,10 +158,9 @@ async function buildProduction(nitro, config) {
|
|
|
155
158
|
const rewriteRelativePaths = (input) => {
|
|
156
159
|
return input.replace(/([\s:])\.\/(\S*)/g, `$1${rOutput}/$2`);
|
|
157
160
|
};
|
|
158
|
-
|
|
159
|
-
if (buildInfo.commands.deploy) nitro.logger.success(
|
|
161
|
+
nitro.logger.success("You can preview this build using `npx nitro preview`");
|
|
162
|
+
if (buildInfo.commands.deploy) nitro.logger.success(rewriteRelativePaths("You can deploy this build using `npx nitro deploy --prebuilt`"));
|
|
160
163
|
}
|
|
161
|
-
|
|
162
164
|
//#endregion
|
|
163
165
|
//#region src/build/rolldown/build.ts
|
|
164
166
|
async function rolldownBuild(nitro) {
|
|
@@ -167,6 +169,5 @@ async function rolldownBuild(nitro) {
|
|
|
167
169
|
await nitro.hooks.callHook("rollup:before", nitro, config);
|
|
168
170
|
return nitro.options.dev ? watchDev(nitro, config) : buildProduction(nitro, config);
|
|
169
171
|
}
|
|
170
|
-
|
|
171
172
|
//#endregion
|
|
172
|
-
export { rolldownBuild };
|
|
173
|
+
export { rolldownBuild };
|
package/dist/_build/rollup.mjs
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import { _ as writeTypes, at as join, d as libChunkName, f as baseBuildConfig, h as writeBuildInfo, it as isAbsolute, l as NODE_MODULES_RE, n as baseBuildPlugins, st as relative, t as oxc, u as getChunkName } from "./common.mjs";
|
|
3
|
-
import { i as debounce } from "../_libs/rc9+c12+dotenv.mjs";
|
|
1
|
+
import { _ as writeTypes, ct as join, d as libChunkName, f as baseBuildConfig, h as writeBuildInfo, it as basename, l as NODE_MODULES_RE, n as baseBuildPlugins, st as isAbsolute, t as oxc, u as getChunkName, ut as relative } from "./common.mjs";
|
|
4
2
|
import { t as formatCompatibilityDate } from "../_libs/compatx.mjs";
|
|
5
3
|
import { n as scanHandlers } from "../_chunks/nitro2.mjs";
|
|
6
|
-
import { n as watch
|
|
4
|
+
import { n as watch } from "../_libs/readdirp+chokidar.mjs";
|
|
5
|
+
import { t as debounce } from "../_libs/perfect-debounce.mjs";
|
|
7
6
|
import { t as alias } from "../_libs/plugin-alias.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { t as inject } from "../_libs/plugin-inject.mjs";
|
|
8
|
+
import { n as generateFSTree } from "../_chunks/utils.mjs";
|
|
10
9
|
import { t as commonjs } from "../_libs/commondir+is-reference.mjs";
|
|
11
10
|
import { t as json } from "../_libs/plugin-json.mjs";
|
|
12
11
|
import { t as nodeResolve } from "../_libs/hasown+resolve+deepmerge.mjs";
|
|
13
|
-
import { watch } from "node:fs";
|
|
14
12
|
import { defu } from "defu";
|
|
15
|
-
|
|
16
13
|
//#region src/build/rollup/config.ts
|
|
17
14
|
const getRollupConfig = async (nitro) => {
|
|
18
15
|
const base = baseBuildConfig(nitro);
|
|
@@ -22,7 +19,7 @@ const getRollupConfig = async (nitro) => {
|
|
|
22
19
|
external: [...base.env.external],
|
|
23
20
|
plugins: [
|
|
24
21
|
...await baseBuildPlugins(nitro, base),
|
|
25
|
-
oxc({
|
|
22
|
+
await oxc({
|
|
26
23
|
sourcemap: !!nitro.options.sourcemap,
|
|
27
24
|
minify: nitro.options.minify ? { ...nitro.options.oxc?.minify } : false,
|
|
28
25
|
transform: {
|
|
@@ -76,7 +73,6 @@ const getRollupConfig = async (nitro) => {
|
|
|
76
73
|
if (outputConfig.inlineDynamicImports || outputConfig.format === "iife") delete outputConfig.manualChunks;
|
|
77
74
|
return config;
|
|
78
75
|
};
|
|
79
|
-
|
|
80
76
|
//#endregion
|
|
81
77
|
//#region src/build/rollup/error.ts
|
|
82
78
|
function formatRollupError(_error) {
|
|
@@ -96,7 +92,6 @@ function formatRollupError(_error) {
|
|
|
96
92
|
return _error?.toString();
|
|
97
93
|
}
|
|
98
94
|
}
|
|
99
|
-
|
|
100
95
|
//#endregion
|
|
101
96
|
//#region src/build/rollup/dev.ts
|
|
102
97
|
async function watchDev(nitro, rollupConfig) {
|
|
@@ -123,11 +118,15 @@ async function watchDev(nitro, rollupConfig) {
|
|
|
123
118
|
"unlink",
|
|
124
119
|
"unlinkDir"
|
|
125
120
|
]);
|
|
126
|
-
const scanDirsWatcher = watch
|
|
121
|
+
const scanDirsWatcher = watch(scanDirs, { ignoreInitial: true }).on("all", (event, path, stat) => {
|
|
127
122
|
if (watchReloadEvents.has(event)) reload();
|
|
128
123
|
});
|
|
129
|
-
const
|
|
130
|
-
|
|
124
|
+
const serverEntryRe = /^server\.[mc]?[jt]sx?$/;
|
|
125
|
+
const rootDirWatcher = watch(nitro.options.rootDir, {
|
|
126
|
+
ignoreInitial: true,
|
|
127
|
+
depth: 0
|
|
128
|
+
}).on("all", (event, path) => {
|
|
129
|
+
if (watchReloadEvents.has(event) && serverEntryRe.test(basename(path))) reload();
|
|
131
130
|
});
|
|
132
131
|
nitro.hooks.hook("close", () => {
|
|
133
132
|
rollupWatcher.close();
|
|
@@ -135,31 +134,30 @@ async function watchDev(nitro, rollupConfig) {
|
|
|
135
134
|
rootDirWatcher.close();
|
|
136
135
|
});
|
|
137
136
|
nitro.hooks.hook("rollup:reload", () => reload());
|
|
137
|
+
nitro.logger.info(`Starting dev watcher (builder: \`rollup\`, preset: \`${nitro.options.preset}\`, compatibility date: \`${formatCompatibilityDate(nitro.options.compatibilityDate)}\`)`);
|
|
138
138
|
await load();
|
|
139
|
-
function startRollupWatcher(nitro
|
|
140
|
-
const watcher = rollup.watch(defu(rollupConfig
|
|
139
|
+
function startRollupWatcher(nitro, rollupConfig) {
|
|
140
|
+
const watcher = rollup.watch(defu(rollupConfig, { watch: { chokidar: nitro.options.watchOptions } }));
|
|
141
141
|
let start;
|
|
142
142
|
watcher.on("event", (event) => {
|
|
143
143
|
switch (event.code) {
|
|
144
144
|
case "START":
|
|
145
145
|
start = Date.now();
|
|
146
|
-
nitro
|
|
147
|
-
nitro$1.hooks.callHook("dev:start");
|
|
146
|
+
nitro.hooks.callHook("dev:start");
|
|
148
147
|
break;
|
|
149
148
|
case "BUNDLE_END":
|
|
150
|
-
nitro
|
|
151
|
-
if (nitro
|
|
152
|
-
nitro
|
|
149
|
+
nitro.hooks.callHook("compiled", nitro);
|
|
150
|
+
if (nitro.options.logging.buildSuccess) nitro.logger.success(`Server built`, start ? `in ${Date.now() - start}ms` : "");
|
|
151
|
+
nitro.hooks.callHook("dev:reload");
|
|
153
152
|
break;
|
|
154
153
|
case "ERROR":
|
|
155
|
-
nitro
|
|
156
|
-
nitro
|
|
154
|
+
nitro.logger.error(formatRollupError(event.error));
|
|
155
|
+
nitro.hooks.callHook("dev:error", event.error);
|
|
157
156
|
}
|
|
158
157
|
});
|
|
159
158
|
return watcher;
|
|
160
159
|
}
|
|
161
160
|
}
|
|
162
|
-
|
|
163
161
|
//#endregion
|
|
164
162
|
//#region src/build/rollup/prod.ts
|
|
165
163
|
async function buildProduction(nitro, rollupConfig) {
|
|
@@ -167,27 +165,23 @@ async function buildProduction(nitro, rollupConfig) {
|
|
|
167
165
|
const buildStartTime = Date.now();
|
|
168
166
|
await scanHandlers(nitro);
|
|
169
167
|
await writeTypes(nitro);
|
|
168
|
+
let output;
|
|
170
169
|
if (!nitro.options.static) {
|
|
171
170
|
nitro.logger.info(`Building server (builder: \`rollup\`, preset: \`${nitro.options.preset}\`, compatibility date: \`${formatCompatibilityDate(nitro.options.compatibilityDate)}\`)`);
|
|
172
|
-
await (await rollup.rollup(rollupConfig).catch((error) => {
|
|
171
|
+
output = await (await rollup.rollup(rollupConfig).catch((error) => {
|
|
173
172
|
nitro.logger.error(formatRollupError(error));
|
|
174
173
|
throw error;
|
|
175
174
|
})).write(rollupConfig.output);
|
|
176
175
|
}
|
|
177
|
-
const buildInfo = await writeBuildInfo(nitro);
|
|
176
|
+
const buildInfo = await writeBuildInfo(nitro, output);
|
|
178
177
|
if (!nitro.options.static) {
|
|
179
178
|
if (nitro.options.logging.buildSuccess) nitro.logger.success(`Server built in ${Date.now() - buildStartTime}ms`);
|
|
180
179
|
if (nitro.options.logLevel > 1) process.stdout.write(await generateFSTree(nitro.options.output.serverDir, { compressedSizes: nitro.options.logging.compressedSizes }) || "");
|
|
181
180
|
}
|
|
182
181
|
await nitro.hooks.callHook("compiled", nitro);
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
return input.replace(/([\s:])\.\/(\S*)/g, `$1${rOutput}/$2`);
|
|
186
|
-
};
|
|
187
|
-
if (buildInfo.commands.preview) nitro.logger.success(`You can preview this build using \`${rewriteRelativePaths(buildInfo.commands.preview)}\``);
|
|
188
|
-
if (buildInfo.commands.deploy) nitro.logger.success(`You can deploy this build using \`${rewriteRelativePaths(buildInfo.commands.deploy)}\``);
|
|
182
|
+
nitro.logger.success("You can preview this build using `npx nitro preview`");
|
|
183
|
+
if (buildInfo.commands.deploy) nitro.logger.success("You can deploy this build using `npx nitro deploy --prebuilt`");
|
|
189
184
|
}
|
|
190
|
-
|
|
191
185
|
//#endregion
|
|
192
186
|
//#region src/build/rollup/build.ts
|
|
193
187
|
async function rollupBuild(nitro) {
|
|
@@ -196,6 +190,5 @@ async function rollupBuild(nitro) {
|
|
|
196
190
|
await nitro.hooks.callHook("rollup:before", nitro, config);
|
|
197
191
|
return nitro.options.dev ? watchDev(nitro, config) : buildProduction(nitro, config);
|
|
198
192
|
}
|
|
199
|
-
|
|
200
193
|
//#endregion
|
|
201
|
-
export { rollupBuild };
|
|
194
|
+
export { rollupBuild };
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { H as v } from "./common.mjs";
|
|
2
2
|
import { nitro } from "nitro/vite";
|
|
3
|
-
|
|
4
3
|
//#region src/build/vite/build.ts
|
|
5
4
|
async function viteBuild(nitro$1) {
|
|
6
5
|
if (nitro$1.options.dev) throw new Error("Nitro dev CLI does not supports vite. Please use `vite dev` instead.");
|
|
7
6
|
const { createBuilder } = await import(nitro$1.options.__vitePkg__ || "vite");
|
|
8
|
-
|
|
7
|
+
const pluginInstance = nitro({ _nitro: nitro$1 });
|
|
8
|
+
globalThis.__nitro_build__ = true;
|
|
9
|
+
const builder = await createBuilder({
|
|
9
10
|
base: nitro$1.options.rootDir,
|
|
10
|
-
plugins: [
|
|
11
|
-
logLevel:
|
|
12
|
-
})
|
|
11
|
+
plugins: [pluginInstance],
|
|
12
|
+
logLevel: v ? "warn" : void 0
|
|
13
|
+
});
|
|
14
|
+
delete globalThis.__nitro_build__;
|
|
15
|
+
await builder.buildApp();
|
|
13
16
|
}
|
|
14
|
-
|
|
15
17
|
//#endregion
|
|
16
|
-
export { viteBuild };
|
|
18
|
+
export { viteBuild };
|