nitro-nightly 3.0.1-alpha.1 → 3.0.1-alpha.2
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/README.md +2 -0
- package/dist/_build/common.mjs +24924 -52
- package/dist/_build/rolldown.mjs +29 -63
- package/dist/_build/rollup.mjs +22 -110
- package/dist/_build/vite.build.mjs +3 -43
- package/dist/{_dev.mjs → _chunks/dev.mjs} +45 -43
- package/dist/_chunks/{B-D1JOIz.mjs → nitro.mjs} +144 -308
- package/dist/_chunks/nitro2.mjs +101 -0
- package/dist/_chunks/utils.mjs +254 -0
- package/dist/{_chunks/Bqks5huO.mjs → _common.mjs} +24 -10
- package/dist/_libs/c12+giget+readdirp+chokidar.d.mts +214 -0
- package/dist/_libs/citty.mjs +140 -110
- package/dist/_libs/{plugin-commonjs.mjs → commondir+is-reference.mjs} +59 -250
- package/dist/_libs/compatx.d.mts +47 -0
- package/dist/_libs/confbox.mjs +388 -799
- package/dist/_libs/esbuild.d.mts +20 -0
- package/dist/_libs/estree-walker.mjs +1 -144
- package/dist/_libs/{plugin-node-resolve.mjs → hasown+resolve+deepmerge.mjs} +497 -78
- package/dist/_libs/httpxy.d.mts +79 -0
- package/dist/_libs/httpxy.mjs +6 -1
- package/dist/_libs/magic-string.d.mts +220 -0
- package/dist/_libs/mlly.d.mts +57 -0
- package/dist/_libs/nypm+giget+tinyexec.mjs +3603 -0
- package/dist/_libs/pkg-types.d.mts +23 -0
- package/dist/_libs/plugin-alias.mjs +4 -2
- package/dist/_libs/plugin-inject.mjs +5 -5
- package/dist/_libs/plugin-json.mjs +2 -2
- package/dist/_libs/pluginutils+plugin-commonjs.d.mts +241 -0
- package/dist/_libs/{vite-plugin-fullstack.mjs → pluginutils.mjs} +244 -153
- package/dist/_libs/rc9+c12+dotenv.mjs +972 -0
- package/dist/_libs/{chokidar.mjs → readdirp+chokidar.mjs} +237 -187
- package/dist/_libs/remapping.mjs +1 -1
- package/dist/_libs/{gen-mapping.mjs → resolve-uri+gen-mapping.mjs} +2 -166
- package/dist/_libs/rou3.d.mts +43 -0
- package/dist/_libs/rou3.mjs +9 -6
- package/dist/_libs/std-env.d.mts +4 -0
- package/dist/_libs/tsconfck.mjs +3 -3
- package/dist/_libs/{unimport.mjs → unimport+unplugin.mjs} +226 -1961
- package/dist/_libs/unplugin+unimport.d.mts +426 -0
- package/dist/_libs/unwasm.d.mts +29 -0
- package/dist/_presets.mjs +130 -80
- package/dist/builder.d.mts +4 -4
- package/dist/builder.mjs +6 -30
- package/dist/cli/_chunks/build.mjs +1 -1
- package/dist/cli/_chunks/dev.mjs +5 -11
- package/dist/cli/_chunks/list.mjs +1 -1
- package/dist/cli/_chunks/prepare.mjs +1 -1
- package/dist/cli/_chunks/run.mjs +1 -1
- package/dist/node_modules/@poppinss/colors/build/index.js +130 -160
- package/dist/node_modules/@poppinss/colors/package.json +20 -18
- package/dist/node_modules/@poppinss/exception/build/index.js +36 -55
- package/dist/node_modules/@poppinss/exception/package.json +19 -16
- package/dist/node_modules/@sindresorhus/is/distribution/index.js +46 -5
- package/dist/node_modules/@sindresorhus/is/package.json +1 -1
- package/dist/node_modules/@speed-highlight/core/dist/index.js +1 -1
- package/dist/node_modules/@speed-highlight/core/dist/terminal.js +1 -1
- package/dist/node_modules/@speed-highlight/core/package.json +2 -2
- package/dist/node_modules/hookable/dist/index.mjs +5 -6
- package/dist/node_modules/hookable/package.json +13 -13
- package/dist/node_modules/ufo/dist/index.mjs +16 -9
- package/dist/node_modules/ufo/package.json +15 -14
- package/dist/node_modules/unctx/package.json +16 -16
- package/dist/node_modules/youch/build/{chunk-4XB2BYKC.js → chunk-7QV3D5YX.js} +2 -4
- package/dist/node_modules/youch/build/{chunk-PUHGL6HA.js → chunk-AUGPHE32.js} +2 -4
- package/dist/node_modules/youch/build/{chunk-F4I6KX4R.js → chunk-CM7DWJNZ.js} +2 -4
- package/dist/node_modules/youch/build/{chunk-YYEJ3AGB.js → chunk-EJH674NB.js} +2 -4
- package/dist/node_modules/youch/build/{chunk-EUJBVOYB.js → chunk-OIJ3WD7L.js} +2 -4
- package/dist/node_modules/youch/build/{chunk-HFSXRSKS.js → chunk-P36L72PL.js} +5 -3
- package/dist/node_modules/youch/build/{chunk-4YEN7HVQ.js → chunk-PE3GG3TN.js} +5 -1
- package/dist/node_modules/youch/build/{chunk-PINJDICN.js → chunk-X53OIOJH.js} +2 -4
- package/dist/node_modules/youch/build/index.js +8 -9
- package/dist/node_modules/youch/build/public/error_info/style.css +1 -0
- package/dist/node_modules/youch/build/public/error_metadata/style.css +3 -0
- package/dist/node_modules/youch/build/public/error_stack/style.css +2 -3
- package/dist/node_modules/youch/package.json +1 -1
- package/dist/presets/_nitro/runtime/nitro-dev.d.mts +1 -1
- package/dist/presets/_nitro/runtime/nitro-dev.mjs +5 -6
- 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 +2 -2
- 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/_utils.d.mts +0 -5
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +1 -1
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +9 -11
- 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 +7 -8
- package/dist/presets/cloudflare/runtime/_module-handler.d.mts +3 -3
- package/dist/presets/cloudflare/runtime/_module-handler.mjs +19 -17
- package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +1 -1
- package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +17 -16
- package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +1 -1
- package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +8 -9
- package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +1 -1
- package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +12 -18
- package/dist/presets/deno/runtime/deno-deploy.d.mts +1 -1
- package/dist/presets/deno/runtime/deno-deploy.mjs +4 -5
- package/dist/presets/deno/runtime/deno-server.d.mts +1 -1
- package/dist/presets/deno/runtime/deno-server.mjs +5 -6
- package/dist/presets/netlify/runtime/netlify-edge.d.mts +1 -2
- package/dist/presets/netlify/runtime/netlify-edge.mjs +3 -2
- package/dist/presets/netlify/runtime/netlify.d.mts +3 -2
- package/dist/presets/netlify/runtime/netlify.mjs +3 -1
- package/dist/presets/node/runtime/node-cluster.d.mts +1 -1
- package/dist/presets/node/runtime/node-cluster.mjs +5 -6
- package/dist/presets/node/runtime/node-middleware.d.mts +1 -1
- package/dist/presets/node/runtime/node-middleware.mjs +4 -5
- package/dist/presets/node/runtime/node-server.d.mts +1 -1
- package/dist/presets/node/runtime/node-server.mjs +5 -6
- 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/isr.d.mts +2 -0
- package/dist/presets/vercel/runtime/isr.mjs +19 -0
- package/dist/presets/vercel/runtime/vercel.node.d.mts +1 -1
- package/dist/presets/vercel/runtime/vercel.node.mjs +16 -7
- package/dist/presets/vercel/runtime/vercel.web.d.mts +1 -1
- package/dist/presets/vercel/runtime/vercel.web.mjs +18 -13
- package/dist/presets/winterjs/runtime/winterjs.d.mts +1 -2
- 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/app.d.mts +1 -1
- package/dist/runtime/app.mjs +1 -1
- package/dist/runtime/internal/app.d.mts +7 -3
- package/dist/runtime/internal/app.mjs +29 -22
- package/dist/runtime/internal/database.mjs +1 -1
- package/dist/runtime/internal/error/dev.d.mts +0 -1
- package/dist/runtime/internal/error/dev.mjs +1 -1
- package/dist/runtime/internal/route-rules.d.mts +0 -4
- package/dist/runtime/internal/routes/dev-tasks.mjs +1 -1
- package/dist/runtime/internal/routes/openapi.d.mts +0 -1
- package/dist/runtime/internal/routes/openapi.mjs +3 -3
- package/dist/runtime/internal/routes/renderer-template.dev.mjs +1 -1
- package/dist/runtime/internal/routes/renderer-template.mjs +1 -1
- package/dist/runtime/internal/routes/scalar.d.mts +0 -1
- package/dist/runtime/internal/routes/scalar.mjs +4 -4
- package/dist/runtime/internal/routes/swagger.d.mts +0 -1
- package/dist/runtime/internal/routes/swagger.mjs +3 -3
- package/dist/runtime/internal/runtime-config.mjs +8 -8
- package/dist/runtime/internal/static.mjs +1 -1
- package/dist/runtime/internal/storage.mjs +1 -1
- package/dist/runtime/internal/task.mjs +1 -1
- package/dist/runtime/internal/vite/dev-entry.mjs +3 -4
- package/dist/runtime/internal/vite/{dev-worker.mjs → node-runner.mjs} +51 -6
- package/dist/runtime/meta.d.mts +1 -1
- package/dist/runtime/meta.mjs +1 -1
- package/dist/runtime/nitro.d.mts +0 -3
- package/dist/runtime/nitro.mjs +1 -1
- package/dist/runtime/virtual/_runtime_warn.d.mts +1 -0
- package/dist/runtime/virtual/_runtime_warn.mjs +5 -0
- package/dist/runtime/virtual/database.d.mts +8 -0
- package/dist/runtime/virtual/database.mjs +2 -0
- package/dist/runtime/virtual/error-handler.d.mts +6 -0
- package/dist/runtime/virtual/error-handler.mjs +9 -0
- package/dist/runtime/virtual/feature-flags.d.mts +7 -0
- package/dist/runtime/virtual/feature-flags.mjs +7 -0
- package/dist/runtime/virtual/plugins.d.mts +3 -0
- package/dist/runtime/virtual/plugins.mjs +2 -0
- package/dist/runtime/virtual/polyfills.d.mts +3 -0
- package/dist/runtime/virtual/polyfills.mjs +2 -0
- package/dist/runtime/virtual/public-assets.d.mts +9 -0
- package/dist/runtime/virtual/public-assets.mjs +8 -0
- package/dist/runtime/virtual/renderer-template.d.mts +4 -0
- package/dist/runtime/virtual/renderer-template.mjs +7 -0
- package/dist/runtime/virtual/routing-meta.d.mts +7 -0
- package/dist/runtime/virtual/routing-meta.mjs +2 -0
- package/dist/runtime/virtual/routing.d.mts +8 -0
- package/dist/runtime/virtual/routing.mjs +11 -0
- package/dist/runtime/virtual/runtime-config.d.mts +3 -0
- package/dist/runtime/virtual/runtime-config.mjs +5 -0
- package/dist/runtime/virtual/server-assets.d.mts +6 -0
- package/dist/runtime/virtual/server-assets.mjs +12 -0
- package/dist/runtime/virtual/storage.d.mts +3 -0
- package/dist/runtime/virtual/storage.mjs +5 -0
- package/dist/runtime/virtual/tasks.d.mts +10 -0
- package/dist/runtime/virtual/tasks.mjs +3 -0
- package/dist/types/index.d.mts +292 -371
- package/dist/types/index.mjs +10 -0
- package/dist/vite.d.mts +7 -12
- package/dist/vite.mjs +734 -41
- package/lib/vite.types.d.mts +26 -0
- package/lib/vite.types.mjs +2 -0
- package/package.json +82 -53
- package/dist/_build/common2.mjs +0 -772
- package/dist/_build/vite.plugin.mjs +0 -768
- package/dist/_chunks/ANM1K1bE.mjs +0 -304
- package/dist/_chunks/BX9-zVkM.mjs +0 -59
- package/dist/_chunks/C7CbzoI1.mjs +0 -39
- package/dist/_libs/acorn.mjs +0 -5034
- package/dist/_libs/c12.mjs +0 -2858
- package/dist/_libs/commondir.mjs +0 -22
- package/dist/_libs/deepmerge.mjs +0 -86
- package/dist/_libs/dot-prop.mjs +0 -138
- package/dist/_libs/duplexer.mjs +0 -71
- package/dist/_libs/etag.mjs +0 -80
- package/dist/_libs/fdir.mjs +0 -514
- package/dist/_libs/function-bind.mjs +0 -63
- package/dist/_libs/giget.mjs +0 -19289
- package/dist/_libs/gzip-size.mjs +0 -21
- package/dist/_libs/hasown.mjs +0 -14
- package/dist/_libs/is-core-module.mjs +0 -220
- package/dist/_libs/is-module.mjs +0 -13
- package/dist/_libs/is-reference.mjs +0 -32
- package/dist/_libs/js-tokens.mjs +0 -382
- package/dist/_libs/knitwork.mjs +0 -124
- package/dist/_libs/local-pkg.mjs +0 -1686
- package/dist/_libs/magic-string.mjs +0 -939
- package/dist/_libs/mime.mjs +0 -1391
- package/dist/_libs/node-fetch-native.mjs +0 -173
- package/dist/_libs/path-parse.mjs +0 -47
- package/dist/_libs/pathe.mjs +0 -41
- package/dist/_libs/picomatch.mjs +0 -1673
- package/dist/_libs/plugin-replace.mjs +0 -104
- package/dist/_libs/pretty-bytes.mjs +0 -116
- package/dist/_libs/std-env.mjs +0 -158
- package/dist/_libs/strip-literal.mjs +0 -51
- package/dist/_libs/tinyglobby.mjs +0 -292
- package/dist/_libs/untyped.mjs +0 -271
- package/dist/_libs/unwasm.mjs +0 -5836
- package/dist/cli/_chunks/detect-acorn.mjs +0 -12
- package/dist/cli/_chunks/dist.mjs +0 -3
- package/dist/cli/_chunks/dist2.mjs +0 -3
- package/dist/cli/_chunks/dist3.mjs +0 -3
- package/dist/cli/_chunks/dist4.mjs +0 -4
- package/dist/cli/_chunks/dist5.mjs +0 -4
- package/dist/cli/_chunks/esm.mjs +0 -3
- package/dist/cli/_chunks/json5.mjs +0 -4
- package/dist/cli/_chunks/jsonc.mjs +0 -4
- package/dist/cli/_chunks/multipart-parser.mjs +0 -6
- package/dist/cli/_chunks/toml.mjs +0 -4
- package/dist/cli/_chunks/yaml.mjs +0 -4
- package/dist/node_modules/kleur/index.js +0 -110
- package/dist/node_modules/youch/build/chunk-OSUFJZHZ.js +0 -6
- package/lib/deps/ofetch.mjs +0 -1
- package/lib/deps/ofetch.mts +0 -1
- /package/dist/runtime/{vite-runtime.d.mts → vite.d.mts} +0 -0
- /package/dist/runtime/{vite-runtime.mjs → vite.mjs} +0 -0
- /package/lib/{deps/h3.d.mts → h3.d.mts} +0 -0
- /package/lib/{deps/h3.mjs → h3.mjs} +0 -0
package/dist/_build/rolldown.mjs
CHANGED
|
@@ -1,54 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "
|
|
3
|
-
import "../_libs/
|
|
4
|
-
import "../_libs/acorn.mjs";
|
|
5
|
-
import "../_libs/confbox.mjs";
|
|
6
|
-
import { f as sanitizeFilePath } from "../_libs/local-pkg.mjs";
|
|
7
|
-
import "../_libs/js-tokens.mjs";
|
|
8
|
-
import "../_libs/strip-literal.mjs";
|
|
9
|
-
import "../_libs/unimport.mjs";
|
|
10
|
-
import "../_libs/picomatch.mjs";
|
|
11
|
-
import "../_libs/fdir.mjs";
|
|
12
|
-
import "../_libs/tinyglobby.mjs";
|
|
1
|
+
import "../_common.mjs";
|
|
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";
|
|
13
4
|
import { t as formatCompatibilityDate } from "../_libs/compatx.mjs";
|
|
14
|
-
import "../
|
|
15
|
-
import "../_libs/
|
|
16
|
-
import "../_chunks/
|
|
17
|
-
import { i as scanHandlers, n as writeTypes } from "../_chunks/ANM1K1bE.mjs";
|
|
18
|
-
import "../_libs/mime.mjs";
|
|
19
|
-
import "../_libs/pathe.mjs";
|
|
20
|
-
import "../_libs/untyped.mjs";
|
|
21
|
-
import "../_libs/knitwork.mjs";
|
|
22
|
-
import { n as writeBuildInfo } from "./common.mjs";
|
|
23
|
-
import { i as watch$1 } from "../_libs/chokidar.mjs";
|
|
24
|
-
import "../_libs/estree-walker.mjs";
|
|
25
|
-
import "../_libs/plugin-commonjs.mjs";
|
|
26
|
-
import { n as baseBuildConfig, t as baseBuildPlugins } from "./common2.mjs";
|
|
27
|
-
import "../_libs/remapping.mjs";
|
|
28
|
-
import "../_libs/unwasm.mjs";
|
|
29
|
-
import "../_libs/plugin-replace.mjs";
|
|
30
|
-
import "../_libs/etag.mjs";
|
|
31
|
-
import "../_libs/duplexer.mjs";
|
|
32
|
-
import "../_libs/gzip-size.mjs";
|
|
33
|
-
import "../_libs/pretty-bytes.mjs";
|
|
34
|
-
import { t as generateFSTree } from "../_chunks/BX9-zVkM.mjs";
|
|
5
|
+
import { n as scanHandlers } from "../_chunks/nitro2.mjs";
|
|
6
|
+
import { n as watch$1 } from "../_libs/readdirp+chokidar.mjs";
|
|
7
|
+
import { t as generateFSTree } from "../_chunks/utils.mjs";
|
|
35
8
|
import { builtinModules } from "node:module";
|
|
36
9
|
import { watch } from "node:fs";
|
|
37
10
|
import { defu } from "defu";
|
|
38
|
-
import { runtimeDir } from "nitro/meta";
|
|
39
11
|
|
|
40
12
|
//#region src/build/rolldown/config.ts
|
|
41
|
-
const getRolldownConfig = (nitro) => {
|
|
13
|
+
const getRolldownConfig = async (nitro) => {
|
|
42
14
|
const base = baseBuildConfig(nitro);
|
|
43
|
-
const chunkNamePrefixes = [
|
|
44
|
-
[runtimeDir, "nitro"],
|
|
45
|
-
[base.presetsDir, "nitro"],
|
|
46
|
-
["\0raw:", "raw"],
|
|
47
|
-
["\0nitro-wasm:", "wasm"],
|
|
48
|
-
["\0", "virtual"]
|
|
49
|
-
];
|
|
50
15
|
const tsc = nitro.options.typescript.tsConfig?.compilerOptions;
|
|
51
16
|
let config = {
|
|
17
|
+
platform: nitro.options.node ? "node" : "neutral",
|
|
52
18
|
cwd: nitro.options.rootDir,
|
|
53
19
|
input: nitro.options.entry,
|
|
54
20
|
external: [
|
|
@@ -56,11 +22,10 @@ const getRolldownConfig = (nitro) => {
|
|
|
56
22
|
...builtinModules,
|
|
57
23
|
...builtinModules.map((m) => `node:${m}`)
|
|
58
24
|
],
|
|
59
|
-
plugins: [...baseBuildPlugins(nitro, base)],
|
|
25
|
+
plugins: [...await baseBuildPlugins(nitro, base)],
|
|
60
26
|
resolve: {
|
|
61
27
|
alias: base.aliases,
|
|
62
28
|
extensions: base.extensions,
|
|
63
|
-
mainFields: ["main"],
|
|
64
29
|
conditionNames: nitro.options.exportConditions
|
|
65
30
|
},
|
|
66
31
|
transform: {
|
|
@@ -74,36 +39,35 @@ const getRolldownConfig = (nitro) => {
|
|
|
74
39
|
}
|
|
75
40
|
},
|
|
76
41
|
onwarn(warning, warn) {
|
|
77
|
-
if (!
|
|
42
|
+
if (!base.ignoreWarningCodes.has(warning.code || "")) {
|
|
43
|
+
console.log(warning.code);
|
|
44
|
+
warn(warning);
|
|
45
|
+
}
|
|
78
46
|
},
|
|
79
47
|
treeshake: { moduleSideEffects(id) {
|
|
80
48
|
return nitro.options.moduleSideEffects.some((p) => id.startsWith(p));
|
|
81
49
|
} },
|
|
50
|
+
optimization: { inlineConst: true },
|
|
82
51
|
output: {
|
|
83
|
-
|
|
52
|
+
format: "esm",
|
|
84
53
|
entryFileNames: "index.mjs",
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (Object.entries(nitro.options.tasks).find(([_, task]) => task.handler === id)) return `chunks/tasks/[name].mjs`;
|
|
92
|
-
return `chunks/_/[name].mjs`;
|
|
93
|
-
},
|
|
54
|
+
chunkFileNames: (chunk) => getChunkName(chunk, nitro),
|
|
55
|
+
codeSplitting: { groups: [{
|
|
56
|
+
test: NODE_MODULES_RE,
|
|
57
|
+
name: (id) => libChunkName(id)
|
|
58
|
+
}] },
|
|
59
|
+
dir: nitro.options.output.serverDir,
|
|
94
60
|
inlineDynamicImports: nitro.options.inlineDynamicImports,
|
|
95
|
-
|
|
96
|
-
exports: "auto",
|
|
97
|
-
intro: "",
|
|
98
|
-
outro: "",
|
|
99
|
-
sanitizeFileName: sanitizeFilePath,
|
|
61
|
+
minify: nitro.options.minify ? true : "dce-only",
|
|
100
62
|
sourcemap: nitro.options.sourcemap,
|
|
101
63
|
sourcemapIgnoreList(relativePath) {
|
|
102
64
|
return relativePath.includes("node_modules");
|
|
103
65
|
}
|
|
104
66
|
}
|
|
105
67
|
};
|
|
106
|
-
config = defu(nitro.options.rollupConfig, config);
|
|
68
|
+
config = defu(nitro.options.rolldownConfig, nitro.options.rollupConfig, config);
|
|
69
|
+
const outputConfig = config.output;
|
|
70
|
+
if (outputConfig.inlineDynamicImports || outputConfig.format === "iife") delete outputConfig.codeSplitting;
|
|
107
71
|
return config;
|
|
108
72
|
};
|
|
109
73
|
|
|
@@ -161,7 +125,9 @@ async function watchDev(nitro, config) {
|
|
|
161
125
|
if (nitro$1.options.logging.buildSuccess) nitro$1.logger.success(`Server built`, start ? `in ${Date.now() - start}ms` : "");
|
|
162
126
|
nitro$1.hooks.callHook("dev:reload");
|
|
163
127
|
break;
|
|
164
|
-
case "ERROR":
|
|
128
|
+
case "ERROR":
|
|
129
|
+
nitro$1.logger.error(event.error);
|
|
130
|
+
nitro$1.hooks.callHook("dev:error", event.error);
|
|
165
131
|
}
|
|
166
132
|
});
|
|
167
133
|
return watcher$1;
|
|
@@ -197,7 +163,7 @@ async function buildProduction(nitro, config) {
|
|
|
197
163
|
//#region src/build/rolldown/build.ts
|
|
198
164
|
async function rolldownBuild(nitro) {
|
|
199
165
|
await nitro.hooks.callHook("build:before", nitro);
|
|
200
|
-
const config = getRolldownConfig(nitro);
|
|
166
|
+
const config = await getRolldownConfig(nitro);
|
|
201
167
|
await nitro.hooks.callHook("rollup:before", nitro, config);
|
|
202
168
|
return nitro.options.dev ? watchDev(nitro, config) : buildProduction(nitro, config);
|
|
203
169
|
}
|
package/dist/_build/rollup.mjs
CHANGED
|
@@ -1,97 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "
|
|
3
|
-
import "../_libs/
|
|
4
|
-
import "../_libs/acorn.mjs";
|
|
5
|
-
import "../_libs/confbox.mjs";
|
|
6
|
-
import { f as sanitizeFilePath } from "../_libs/local-pkg.mjs";
|
|
7
|
-
import "../_libs/js-tokens.mjs";
|
|
8
|
-
import "../_libs/strip-literal.mjs";
|
|
9
|
-
import "../_libs/unimport.mjs";
|
|
10
|
-
import "../_libs/picomatch.mjs";
|
|
11
|
-
import "../_libs/fdir.mjs";
|
|
12
|
-
import "../_libs/tinyglobby.mjs";
|
|
1
|
+
import "../_common.mjs";
|
|
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";
|
|
13
4
|
import { t as formatCompatibilityDate } from "../_libs/compatx.mjs";
|
|
14
|
-
import "../
|
|
15
|
-
import "../_libs/
|
|
16
|
-
import "../_chunks/C7CbzoI1.mjs";
|
|
17
|
-
import { i as scanHandlers, n as writeTypes } from "../_chunks/ANM1K1bE.mjs";
|
|
18
|
-
import "../_libs/mime.mjs";
|
|
19
|
-
import "../_libs/pathe.mjs";
|
|
20
|
-
import "../_libs/untyped.mjs";
|
|
21
|
-
import "../_libs/knitwork.mjs";
|
|
22
|
-
import { n as writeBuildInfo } from "./common.mjs";
|
|
23
|
-
import { i as watch$1 } from "../_libs/chokidar.mjs";
|
|
5
|
+
import { n as scanHandlers } from "../_chunks/nitro2.mjs";
|
|
6
|
+
import { n as watch$1 } from "../_libs/readdirp+chokidar.mjs";
|
|
24
7
|
import { t as alias } from "../_libs/plugin-alias.mjs";
|
|
25
|
-
import "../_libs/
|
|
26
|
-
import { t as
|
|
27
|
-
import { t as
|
|
28
|
-
import { n as baseBuildConfig, t as baseBuildPlugins } from "./common2.mjs";
|
|
29
|
-
import "../_libs/remapping.mjs";
|
|
30
|
-
import "../_libs/unwasm.mjs";
|
|
31
|
-
import "../_libs/plugin-replace.mjs";
|
|
32
|
-
import "../_libs/etag.mjs";
|
|
33
|
-
import "../_libs/duplexer.mjs";
|
|
34
|
-
import "../_libs/gzip-size.mjs";
|
|
35
|
-
import "../_libs/pretty-bytes.mjs";
|
|
36
|
-
import { t as generateFSTree } from "../_chunks/BX9-zVkM.mjs";
|
|
37
|
-
import "../_libs/commondir.mjs";
|
|
38
|
-
import "../_libs/is-reference.mjs";
|
|
8
|
+
import { n as inject } from "../_libs/plugin-inject.mjs";
|
|
9
|
+
import { t as generateFSTree } from "../_chunks/utils.mjs";
|
|
10
|
+
import { t as commonjs } from "../_libs/commondir+is-reference.mjs";
|
|
39
11
|
import { t as json } from "../_libs/plugin-json.mjs";
|
|
40
|
-
import "../_libs/deepmerge.mjs";
|
|
41
|
-
import "../_libs/is-module.mjs";
|
|
42
|
-
import { t as nodeResolve } from "../_libs/plugin-node-resolve.mjs";
|
|
43
|
-
import "../_libs/path-parse.mjs";
|
|
44
|
-
import "../_libs/function-bind.mjs";
|
|
45
|
-
import "../_libs/hasown.mjs";
|
|
46
|
-
import "../_libs/is-core-module.mjs";
|
|
12
|
+
import { t as nodeResolve } from "../_libs/hasown+resolve+deepmerge.mjs";
|
|
47
13
|
import { watch } from "node:fs";
|
|
48
14
|
import { defu } from "defu";
|
|
49
|
-
import { runtimeDir } from "nitro/meta";
|
|
50
|
-
import { transform } from "oxc-transform";
|
|
51
|
-
import { minify } from "oxc-minify";
|
|
52
15
|
|
|
53
|
-
//#region src/build/plugins/oxc.ts
|
|
54
|
-
function oxc(options) {
|
|
55
|
-
const filter = (id) => !/node_modules/.test(id) && /\.[mj]?[jt]sx?$/.test(id);
|
|
56
|
-
return {
|
|
57
|
-
name: "nitro:oxc",
|
|
58
|
-
async transform(code, id) {
|
|
59
|
-
if (!filter(id)) return null;
|
|
60
|
-
return transform(id, code, {
|
|
61
|
-
sourcemap: options.sourcemap,
|
|
62
|
-
...options.transform
|
|
63
|
-
});
|
|
64
|
-
},
|
|
65
|
-
async renderChunk(code, chunk) {
|
|
66
|
-
if (options.minify) return minify(chunk.fileName, code, {
|
|
67
|
-
sourcemap: options.sourcemap,
|
|
68
|
-
...typeof options.minify === "object" ? options.minify : {}
|
|
69
|
-
});
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
//#endregion
|
|
76
16
|
//#region src/build/rollup/config.ts
|
|
77
|
-
const getRollupConfig = (nitro) => {
|
|
17
|
+
const getRollupConfig = async (nitro) => {
|
|
78
18
|
const base = baseBuildConfig(nitro);
|
|
79
|
-
const chunkNamePrefixes = [
|
|
80
|
-
[runtimeDir, "nitro"],
|
|
81
|
-
[base.presetsDir, "nitro"],
|
|
82
|
-
["\0raw:", "raw"],
|
|
83
|
-
["\0nitro-wasm:", "wasm"],
|
|
84
|
-
["\0", "virtual"]
|
|
85
|
-
];
|
|
86
|
-
function getChunkGroup(id) {
|
|
87
|
-
if (id.startsWith(runtimeDir) || id.startsWith(base.presetsDir)) return "nitro";
|
|
88
|
-
}
|
|
89
19
|
const tsc = nitro.options.typescript.tsConfig?.compilerOptions;
|
|
90
20
|
let config = {
|
|
91
21
|
input: nitro.options.entry,
|
|
92
22
|
external: [...base.env.external],
|
|
93
23
|
plugins: [
|
|
94
|
-
...baseBuildPlugins(nitro, base),
|
|
24
|
+
...await baseBuildPlugins(nitro, base),
|
|
95
25
|
oxc({
|
|
96
26
|
sourcemap: !!nitro.options.sourcemap,
|
|
97
27
|
minify: nitro.options.minify ? { ...nitro.options.oxc?.minify } : false,
|
|
@@ -114,8 +44,6 @@ const getRollupConfig = (nitro) => {
|
|
|
114
44
|
extensions: base.extensions,
|
|
115
45
|
preferBuiltins: !!nitro.options.node,
|
|
116
46
|
rootDir: nitro.options.rootDir,
|
|
117
|
-
modulePaths: nitro.options.nodeModulesDirs,
|
|
118
|
-
mainFields: ["main"],
|
|
119
47
|
exportConditions: nitro.options.exportConditions
|
|
120
48
|
}),
|
|
121
49
|
commonjs({ ...nitro.options.commonJS }),
|
|
@@ -123,45 +51,29 @@ const getRollupConfig = (nitro) => {
|
|
|
123
51
|
inject(base.env.inject)
|
|
124
52
|
],
|
|
125
53
|
onwarn(warning, rollupWarn) {
|
|
126
|
-
if (!
|
|
127
|
-
"EVAL",
|
|
128
|
-
"CIRCULAR_DEPENDENCY",
|
|
129
|
-
"THIS_IS_UNDEFINED"
|
|
130
|
-
].includes(warning.code || "") && !warning.message.includes("Unsupported source map comment")) rollupWarn(warning);
|
|
54
|
+
if (!base.ignoreWarningCodes.has(warning.code || "")) rollupWarn(warning);
|
|
131
55
|
},
|
|
132
56
|
treeshake: { moduleSideEffects(id) {
|
|
133
57
|
return nitro.options.moduleSideEffects.some((p) => id.startsWith(p));
|
|
134
58
|
} },
|
|
135
59
|
output: {
|
|
136
|
-
|
|
60
|
+
format: "esm",
|
|
137
61
|
entryFileNames: "index.mjs",
|
|
138
|
-
chunkFileNames(chunk)
|
|
139
|
-
|
|
140
|
-
for (const [dir, name] of chunkNamePrefixes) if (id.startsWith(dir)) return `chunks/${name}/[name].mjs`;
|
|
141
|
-
const routeHandler = nitro.options.handlers.find((h) => id.startsWith(h.handler)) || nitro.scannedHandlers.find((h) => id.startsWith(h.handler));
|
|
142
|
-
if (routeHandler?.route) return `chunks/routes${routeHandler.route.replace(/:([^/]+)/g, "_$1").replace(/\/[^/]+$/g, "") || "/"}/[name].mjs`;
|
|
143
|
-
if (Object.entries(nitro.options.tasks).find(([_, task]) => task.handler === id)) return `chunks/tasks/[name].mjs`;
|
|
144
|
-
return `chunks/_/[name].mjs`;
|
|
145
|
-
},
|
|
146
|
-
manualChunks(id) {
|
|
147
|
-
return getChunkGroup(id);
|
|
148
|
-
},
|
|
62
|
+
chunkFileNames: (chunk) => getChunkName(chunk, nitro),
|
|
63
|
+
dir: nitro.options.output.serverDir,
|
|
149
64
|
inlineDynamicImports: nitro.options.inlineDynamicImports,
|
|
150
|
-
format: "esm",
|
|
151
|
-
exports: "auto",
|
|
152
|
-
intro: "",
|
|
153
|
-
outro: "",
|
|
154
65
|
generatedCode: { constBindings: true },
|
|
155
|
-
sanitizeFileName: sanitizeFilePath,
|
|
156
66
|
sourcemap: nitro.options.sourcemap,
|
|
157
67
|
sourcemapExcludeSources: true,
|
|
158
|
-
sourcemapIgnoreList(
|
|
159
|
-
|
|
68
|
+
sourcemapIgnoreList: (id) => id.includes("node_modules"),
|
|
69
|
+
manualChunks(id) {
|
|
70
|
+
if (NODE_MODULES_RE.test(id)) return libChunkName(id);
|
|
160
71
|
}
|
|
161
72
|
}
|
|
162
73
|
};
|
|
163
74
|
config = defu(nitro.options.rollupConfig, config);
|
|
164
|
-
|
|
75
|
+
const outputConfig = config.output;
|
|
76
|
+
if (outputConfig.inlineDynamicImports || outputConfig.format === "iife") delete outputConfig.manualChunks;
|
|
165
77
|
return config;
|
|
166
78
|
};
|
|
167
79
|
|
|
@@ -211,7 +123,7 @@ async function watchDev(nitro, rollupConfig) {
|
|
|
211
123
|
"unlink",
|
|
212
124
|
"unlinkDir"
|
|
213
125
|
]);
|
|
214
|
-
const scanDirsWatcher = watch$1(scanDirs, { ignoreInitial: true }).on("all", (event, path, stat) => {
|
|
126
|
+
const scanDirsWatcher = watch$1(scanDirs, { ignoreInitial: true }).on("all", (event, path, stat$1) => {
|
|
215
127
|
if (watchReloadEvents.has(event)) reload();
|
|
216
128
|
});
|
|
217
129
|
const rootDirWatcher = watch(nitro.options.rootDir, { persistent: false }, (_event, filename) => {
|
|
@@ -280,7 +192,7 @@ async function buildProduction(nitro, rollupConfig) {
|
|
|
280
192
|
//#region src/build/rollup/build.ts
|
|
281
193
|
async function rollupBuild(nitro) {
|
|
282
194
|
await nitro.hooks.callHook("build:before", nitro);
|
|
283
|
-
const config = getRollupConfig(nitro);
|
|
195
|
+
const config = await getRollupConfig(nitro);
|
|
284
196
|
await nitro.hooks.callHook("rollup:before", nitro, config);
|
|
285
197
|
return nitro.options.dev ? watchDev(nitro, config) : buildProduction(nitro, config);
|
|
286
198
|
}
|
|
@@ -1,50 +1,10 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import "
|
|
3
|
-
import "../_libs/magic-string.mjs";
|
|
4
|
-
import "../_libs/acorn.mjs";
|
|
5
|
-
import "../_libs/confbox.mjs";
|
|
6
|
-
import "../_libs/local-pkg.mjs";
|
|
7
|
-
import "../_libs/js-tokens.mjs";
|
|
8
|
-
import "../_libs/strip-literal.mjs";
|
|
9
|
-
import "../_libs/unimport.mjs";
|
|
10
|
-
import "../_libs/picomatch.mjs";
|
|
11
|
-
import "../_libs/fdir.mjs";
|
|
12
|
-
import "../_libs/tinyglobby.mjs";
|
|
13
|
-
import "../_libs/compatx.mjs";
|
|
14
|
-
import "../_libs/klona.mjs";
|
|
15
|
-
import { r as a } from "../_libs/std-env.mjs";
|
|
16
|
-
import "../_chunks/B-D1JOIz.mjs";
|
|
17
|
-
import "../_libs/escape-string-regexp.mjs";
|
|
18
|
-
import "../_libs/tsconfck.mjs";
|
|
19
|
-
import "../_libs/dot-prop.mjs";
|
|
20
|
-
import "../_chunks/C7CbzoI1.mjs";
|
|
21
|
-
import "../_chunks/ANM1K1bE.mjs";
|
|
22
|
-
import "../_libs/rou3.mjs";
|
|
23
|
-
import "../_libs/mime.mjs";
|
|
24
|
-
import "../_libs/pathe.mjs";
|
|
25
|
-
import "../_libs/untyped.mjs";
|
|
26
|
-
import "../_libs/knitwork.mjs";
|
|
27
|
-
import "./common.mjs";
|
|
28
|
-
import "../_libs/httpxy.mjs";
|
|
29
|
-
import "../_dev.mjs";
|
|
30
|
-
import "../_libs/chokidar.mjs";
|
|
31
|
-
import "../_libs/ultrahtml.mjs";
|
|
32
|
-
import "../_libs/plugin-alias.mjs";
|
|
33
|
-
import "../_libs/estree-walker.mjs";
|
|
34
|
-
import "../_libs/plugin-commonjs.mjs";
|
|
35
|
-
import "../_libs/plugin-inject.mjs";
|
|
36
|
-
import "./common2.mjs";
|
|
37
|
-
import "../_libs/remapping.mjs";
|
|
38
|
-
import "../_libs/unwasm.mjs";
|
|
39
|
-
import "../_libs/plugin-replace.mjs";
|
|
40
|
-
import "../_libs/etag.mjs";
|
|
41
|
-
import { t as nitro } from "./vite.plugin.mjs";
|
|
42
|
-
import "../_libs/vite-plugin-fullstack.mjs";
|
|
1
|
+
import { V as a } from "./common.mjs";
|
|
2
|
+
import { nitro } from "nitro/vite";
|
|
43
3
|
|
|
44
4
|
//#region src/build/vite/build.ts
|
|
45
5
|
async function viteBuild(nitro$1) {
|
|
46
6
|
if (nitro$1.options.dev) throw new Error("Nitro dev CLI does not supports vite. Please use `vite dev` instead.");
|
|
47
|
-
const { createBuilder } = nitro$1.options.
|
|
7
|
+
const { createBuilder } = await import(nitro$1.options.__vitePkg__ || "vite");
|
|
48
8
|
await (await createBuilder({
|
|
49
9
|
base: nitro$1.options.rootDir,
|
|
50
10
|
plugins: [await nitro({ _nitro: nitro$1 })],
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
5
|
-
import { n as createProxyServer } from "./_libs/httpxy.mjs";
|
|
6
|
-
import { i as watch$1 } from "./_libs/chokidar.mjs";
|
|
1
|
+
import { B as T, V as a, at as join$1, ct as resolve$1, g as writeDevBuildInfo, j as src_default, rt as extname$1 } from "../_build/common.mjs";
|
|
2
|
+
import { i as debounce } from "../_libs/rc9+c12+dotenv.mjs";
|
|
3
|
+
import { t as createProxyServer } from "../_libs/httpxy.mjs";
|
|
4
|
+
import { n as watch$1 } from "../_libs/readdirp+chokidar.mjs";
|
|
7
5
|
import consola$1 from "consola";
|
|
8
|
-
import { dirname, resolve } from "node:path";
|
|
9
6
|
import { createReadStream, existsSync } from "node:fs";
|
|
7
|
+
import { readFile, rm, stat as stat$1 } from "node:fs/promises";
|
|
8
|
+
import { dirname, resolve } from "node:path";
|
|
10
9
|
import { joinURL } from "ufo";
|
|
11
|
-
import { readFile, rm, stat } from "node:fs/promises";
|
|
12
10
|
import { createBrotliCompress, createGzip } from "node:zlib";
|
|
13
11
|
import { Worker } from "node:worker_threads";
|
|
14
12
|
import { H3, HTTPError, defineHandler, fromNodeHandler, getRequestIP, getRequestURL, serveStatic, toEventHandler } from "h3";
|
|
@@ -19,7 +17,7 @@ import { Youch } from "youch";
|
|
|
19
17
|
import { SourceMapConsumer } from "source-map";
|
|
20
18
|
import { FastResponse } from "srvx";
|
|
21
19
|
|
|
22
|
-
//#region src/
|
|
20
|
+
//#region src/runner/proxy.ts
|
|
23
21
|
function createHTTPProxy(defaults = {}) {
|
|
24
22
|
const proxy = createProxyServer(defaults);
|
|
25
23
|
proxy.on("proxyReq", (proxyReq, req) => {
|
|
@@ -51,7 +49,7 @@ function createHTTPProxy(defaults = {}) {
|
|
|
51
49
|
}
|
|
52
50
|
};
|
|
53
51
|
}
|
|
54
|
-
function fetchAddress(addr, input, inputInit) {
|
|
52
|
+
async function fetchAddress(addr, input, inputInit) {
|
|
55
53
|
let url;
|
|
56
54
|
let init;
|
|
57
55
|
if (input instanceof Request) {
|
|
@@ -71,16 +69,25 @@ function fetchAddress(addr, input, inputInit) {
|
|
|
71
69
|
redirect: "manual",
|
|
72
70
|
...init
|
|
73
71
|
};
|
|
72
|
+
let res;
|
|
74
73
|
if (addr.socketPath) {
|
|
75
74
|
url.protocol = "http:";
|
|
76
|
-
|
|
75
|
+
res = await fetch(url, {
|
|
77
76
|
...init,
|
|
78
77
|
...fetchSocketOptions(addr.socketPath)
|
|
79
78
|
});
|
|
79
|
+
} else {
|
|
80
|
+
const origin = `http://${addr.host}${addr.port ? `:${addr.port}` : ""}`;
|
|
81
|
+
const outURL = new URL(url.pathname + url.search, origin);
|
|
82
|
+
res = await fetch(outURL, init);
|
|
80
83
|
}
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
return
|
|
84
|
+
const headers = new Headers(res.headers);
|
|
85
|
+
headers.delete("transfer-encoding");
|
|
86
|
+
return new Response(res.body, {
|
|
87
|
+
status: res.status,
|
|
88
|
+
statusText: res.statusText,
|
|
89
|
+
headers
|
|
90
|
+
});
|
|
84
91
|
}
|
|
85
92
|
function fetchSocketOptions(socketPath) {
|
|
86
93
|
if ("Bun" in globalThis) return { unix: socketPath };
|
|
@@ -92,8 +99,8 @@ function fetchSocketOptions(socketPath) {
|
|
|
92
99
|
}
|
|
93
100
|
|
|
94
101
|
//#endregion
|
|
95
|
-
//#region src/
|
|
96
|
-
var
|
|
102
|
+
//#region src/runner/node.ts
|
|
103
|
+
var NodeEnvRunner = class {
|
|
97
104
|
closed = false;
|
|
98
105
|
#name;
|
|
99
106
|
#entry;
|
|
@@ -107,7 +114,7 @@ var NodeDevWorker = class {
|
|
|
107
114
|
this.#name = opts.name;
|
|
108
115
|
this.#entry = opts.entry;
|
|
109
116
|
this.#data = opts.data;
|
|
110
|
-
this.#hooks = opts.hooks;
|
|
117
|
+
this.#hooks = opts.hooks || {};
|
|
111
118
|
this.#proxy = createHTTPProxy();
|
|
112
119
|
this.#messageListeners = /* @__PURE__ */ new Set();
|
|
113
120
|
this.#initWorker();
|
|
@@ -117,7 +124,7 @@ var NodeDevWorker = class {
|
|
|
117
124
|
}
|
|
118
125
|
async fetch(input, init) {
|
|
119
126
|
for (let i = 0; i < 5 && !(this.#address && this.#proxy); i++) await new Promise((r) => setTimeout(r, 100 * Math.pow(2, i)));
|
|
120
|
-
if (!(this.#address && this.#proxy)) return new Response("
|
|
127
|
+
if (!(this.#address && this.#proxy)) return new Response("Node env runner worker is unavailable", { status: 503 });
|
|
121
128
|
return fetchAddress(this.#address, input, init);
|
|
122
129
|
}
|
|
123
130
|
upgrade(req, socket, head) {
|
|
@@ -130,7 +137,7 @@ var NodeDevWorker = class {
|
|
|
130
137
|
});
|
|
131
138
|
}
|
|
132
139
|
sendMessage(message) {
|
|
133
|
-
if (!this.#worker) throw new Error("
|
|
140
|
+
if (!this.#worker) throw new Error("Node env worker should be initialized before sending messages.");
|
|
134
141
|
this.#worker.postMessage(message);
|
|
135
142
|
}
|
|
136
143
|
onMessage(listener) {
|
|
@@ -151,7 +158,7 @@ var NodeDevWorker = class {
|
|
|
151
158
|
}
|
|
152
159
|
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
153
160
|
const status = this.closed ? "closed" : this.ready ? "ready" : "pending";
|
|
154
|
-
return `
|
|
161
|
+
return `NodeEnvRunner#${this.#name}(${status})`;
|
|
155
162
|
}
|
|
156
163
|
#initWorker() {
|
|
157
164
|
if (!existsSync(this.#entry)) {
|
|
@@ -197,7 +204,8 @@ var NodeDevWorker = class {
|
|
|
197
204
|
if (!this.#worker._exitCode && !a && !T) await new Promise((resolve$2) => {
|
|
198
205
|
const gracefulShutdownTimeoutMs = Number.parseInt(process.env.NITRO_SHUTDOWN_TIMEOUT || "", 10) || 5e3;
|
|
199
206
|
const timeout = setTimeout(() => {
|
|
200
|
-
|
|
207
|
+
consola$1.warn(`force closing node env runner worker...`);
|
|
208
|
+
resolve$2();
|
|
201
209
|
}, gracefulShutdownTimeoutMs);
|
|
202
210
|
this.#worker?.on("message", (message) => {
|
|
203
211
|
if (message.event === "exit") {
|
|
@@ -224,22 +232,17 @@ function createVFSHandler(nitro) {
|
|
|
224
232
|
statusText: `Forbidden IP: "${ip || "?"}"`,
|
|
225
233
|
status: 403
|
|
226
234
|
});
|
|
227
|
-
const vfsEntries = {
|
|
228
|
-
...nitro.vfs,
|
|
229
|
-
...nitro.options.virtual
|
|
230
|
-
};
|
|
231
235
|
const url = event.context.params?._ || "";
|
|
232
236
|
const isJson = url.endsWith(".json") || event.req.headers.get("accept")?.includes("application/json");
|
|
233
237
|
const id = decodeURIComponent(url.replace(/^(\.json)?\/?/, "") || "");
|
|
234
|
-
if (id && !(id
|
|
238
|
+
if (id && !nitro.vfs.has(id)) throw new HTTPError({
|
|
235
239
|
message: "File not found",
|
|
236
240
|
status: 404
|
|
237
241
|
});
|
|
238
|
-
|
|
239
|
-
if (typeof content === "function") content = await content();
|
|
242
|
+
const content = id ? await nitro.vfs.get(id)?.render() : void 0;
|
|
240
243
|
if (isJson) return {
|
|
241
244
|
rootDir: nitro.options.rootDir,
|
|
242
|
-
entries:
|
|
245
|
+
entries: [...nitro.vfs.keys()].map((id$1) => ({
|
|
243
246
|
id: id$1,
|
|
244
247
|
path: "/_vfs.json/" + encodeURIComponent(id$1)
|
|
245
248
|
})),
|
|
@@ -249,7 +252,7 @@ function createVFSHandler(nitro) {
|
|
|
249
252
|
} : null
|
|
250
253
|
};
|
|
251
254
|
const directories = { [nitro.options.rootDir]: {} };
|
|
252
|
-
const fpaths =
|
|
255
|
+
const fpaths = [...nitro.vfs.keys()];
|
|
253
256
|
for (const item of fpaths) {
|
|
254
257
|
const segments = item.replace(nitro.options.rootDir, "").split("/").filter(Boolean);
|
|
255
258
|
let currentDir = item.startsWith(nitro.options.rootDir) ? directories[nitro.options.rootDir] : directories;
|
|
@@ -386,7 +389,7 @@ async function defaultHandler(error, event, opts) {
|
|
|
386
389
|
const ansiError = await (await youch.toANSI(error)).replaceAll(process.cwd(), ".");
|
|
387
390
|
consola$1.error(`[request error] ${tags} [${event.req.method}] ${url}\n\n`, ansiError);
|
|
388
391
|
}
|
|
389
|
-
const useJSON = opts?.json
|
|
392
|
+
const useJSON = opts?.json ?? !event.req.headers.get("accept")?.includes("text/html");
|
|
390
393
|
const headers = {
|
|
391
394
|
"content-type": useJSON ? "application/json" : "text/html",
|
|
392
395
|
"x-content-type-options": "nosniff",
|
|
@@ -508,7 +511,7 @@ function serveStaticDir(event, opts) {
|
|
|
508
511
|
getMeta: async (id) => {
|
|
509
512
|
const path$1 = r(id);
|
|
510
513
|
if (!path$1) return;
|
|
511
|
-
const s = await stat(path$1).catch(() => null);
|
|
514
|
+
const s = await stat$1(path$1).catch(() => null);
|
|
512
515
|
if (!s?.isFile()) return;
|
|
513
516
|
const ext = extname$1(path$1);
|
|
514
517
|
return {
|
|
@@ -583,9 +586,10 @@ var NitroDevServer = class NitroDevServer extends NitroDevApp {
|
|
|
583
586
|
this.#building = false;
|
|
584
587
|
for (const worker of this.#workers) worker.close();
|
|
585
588
|
});
|
|
586
|
-
|
|
589
|
+
const devWatch = nitro.options.devServer.watch;
|
|
590
|
+
if (devWatch && devWatch.length > 0) {
|
|
587
591
|
const debouncedReload = debounce(() => this.reload());
|
|
588
|
-
this.#watcher = watch$1(
|
|
592
|
+
this.#watcher = watch$1(devWatch, nitro.options.watchOptions);
|
|
589
593
|
this.#watcher.on("add", debouncedReload).on("change", debouncedReload);
|
|
590
594
|
}
|
|
591
595
|
}
|
|
@@ -595,6 +599,10 @@ var NitroDevServer = class NitroDevServer extends NitroDevApp {
|
|
|
595
599
|
status: 503,
|
|
596
600
|
statusText: "No worker available."
|
|
597
601
|
});
|
|
602
|
+
if (!worker.upgrade) throw new HTTPError({
|
|
603
|
+
status: 501,
|
|
604
|
+
statusText: "Worker does not support upgrades."
|
|
605
|
+
});
|
|
598
606
|
return worker.upgrade(req, socket, head);
|
|
599
607
|
}
|
|
600
608
|
listen(opts) {
|
|
@@ -624,16 +632,10 @@ var NitroDevServer = class NitroDevServer extends NitroDevApp {
|
|
|
624
632
|
}
|
|
625
633
|
reload() {
|
|
626
634
|
for (const worker$1 of this.#workers) worker$1.close();
|
|
627
|
-
const worker = new
|
|
635
|
+
const worker = new NodeEnvRunner({
|
|
628
636
|
name: `Nitro_${this.#workerIdCtr++}`,
|
|
629
637
|
entry: this.#entry,
|
|
630
|
-
data:
|
|
631
|
-
...this.#workerData,
|
|
632
|
-
globals: {
|
|
633
|
-
__NITRO_RUNTIME_CONFIG__: this.nitro.options.runtimeConfig,
|
|
634
|
-
...this.#workerData.globals
|
|
635
|
-
}
|
|
636
|
-
},
|
|
638
|
+
data: this.#workerData,
|
|
637
639
|
hooks: {
|
|
638
640
|
onClose: (worker$1, cause) => {
|
|
639
641
|
this.#workerError = cause;
|
|
@@ -702,4 +704,4 @@ var NitroDevServer = class NitroDevServer extends NitroDevApp {
|
|
|
702
704
|
};
|
|
703
705
|
|
|
704
706
|
//#endregion
|
|
705
|
-
export {
|
|
707
|
+
export { NodeEnvRunner as i, createDevServer as n, NitroDevApp as r, NitroDevServer as t };
|