nitro-nightly 3.0.261029-rc → 3.0.261102-rc
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/common.mjs +87 -57
- package/dist/_build/rolldown.mjs +5 -5
- package/dist/_build/rollup.mjs +7 -7
- package/dist/_build/shared.mjs +1 -1
- package/dist/_build/shared2.mjs +3 -3
- package/dist/_build/vite.dev.mjs +12 -2
- package/dist/_chunks/nitro.mjs +9 -6
- package/dist/_chunks/nitro3.mjs +10 -2
- package/dist/_chunks/nitro4.mjs +3 -3
- package/dist/_chunks/utils.mjs +2 -1
- package/dist/_dev.mjs +18 -3
- package/dist/_import.mjs +7 -5
- package/dist/_libs/undici+jsonc-parser.d.mts +2 -0
- package/dist/_presets.mjs +131 -17
- package/dist/_rpc.mjs +193 -3
- package/dist/_scan-watch.mjs +1 -1
- package/dist/_usage.mjs +1 -1
- package/dist/cli/_chunks/build.mjs +1 -1
- package/dist/cli/_chunks/create.mjs +3 -3
- package/dist/cli/_chunks/deploy.mjs +1 -1
- package/dist/cli/_chunks/dev.mjs +3 -3
- package/dist/cli/_chunks/fetch.mjs +2 -2
- package/dist/cli/_chunks/list.mjs +1 -1
- package/dist/cli/_chunks/preview.mjs +3 -2
- package/dist/cli/_chunks/run.mjs +1 -1
- package/dist/cli/_chunks/serve.mjs +2 -2
- package/dist/presets/node/runtime/node-cluster.mjs +6 -1
- package/dist/presets/node/runtime/node-server.mjs +4 -0
- package/dist/runtime/_meta.mjs +1 -1
- package/dist/runtime/internal/error/dev.d.mts +1 -1
- package/dist/runtime/internal/routes/openapi.mjs +1 -1
- package/dist/runtime/internal/task.mjs +1 -1
- package/dist/runtime/nitro.d.mts +2 -2
- package/dist/types/index.d.mts +40 -15
- package/dist/vite.mjs +118 -93
- package/package.json +12 -12
package/dist/_build/common.mjs
CHANGED
|
@@ -2599,7 +2599,7 @@ function getDepMeta(id) {
|
|
|
2599
2599
|
}
|
|
2600
2600
|
function ensureDep(depOpts) {
|
|
2601
2601
|
const opts = _resolveDepOptions(depOpts);
|
|
2602
|
-
const path = opts.paths?.[opts.id];
|
|
2602
|
+
const path = opts.deps?.paths?.[opts.id];
|
|
2603
2603
|
const key = `${path ? `path:${path}` : opts.projectOnly ? "project" : "any"}:${opts.dir}:${opts.id}`;
|
|
2604
2604
|
let pending = _pendingDeps.get(key);
|
|
2605
2605
|
if (!pending) {
|
|
@@ -2617,13 +2617,14 @@ function missingDepError(depOpts) {
|
|
|
2617
2617
|
const opts = _resolveDepOptions(depOpts);
|
|
2618
2618
|
if (_isInNodeModules(opts.dir)) return /* @__PURE__ */ new Error(`\`${opts.id}\` cannot be resolved from \`${opts.dir}\`, which is inside \`node_modules\`. It is required for ${opts.reason}. The package that configures Nitro with this \`rootDir\` must add \`${_depSpec(opts)}\` to its own dependencies (or provide it with the \`deps.paths\` option).`);
|
|
2619
2619
|
const dev = opts.dev === false ? "" : "dev ";
|
|
2620
|
-
|
|
2620
|
+
const ci = opts.deps?.install === void 0 && L$1 && !r$2 ? " Dependencies are not installed on demand in CI unless the `deps.install` option is enabled." : "";
|
|
2621
|
+
return /* @__PURE__ */ new Error(`\`${opts.id}\` is not installed. It is required for ${opts.reason}. Please add it to your ${dev}dependencies (e.g. \`npx nypm add ${dev ? "-D " : ""}${_depSpec(opts)}\`).${ci}`);
|
|
2621
2622
|
}
|
|
2622
2623
|
function isDepInstalled(id, opts) {
|
|
2623
2624
|
return !!resolveDep(id, opts);
|
|
2624
2625
|
}
|
|
2625
2626
|
function resolveDep(id, opts) {
|
|
2626
|
-
const path = opts.paths?.[depPackageName(id)];
|
|
2627
|
+
const path = opts.deps?.paths?.[depPackageName(id)];
|
|
2627
2628
|
if (path) return resolveFromDepPath(id, {
|
|
2628
2629
|
dir: opts.dir,
|
|
2629
2630
|
path
|
|
@@ -2658,14 +2659,18 @@ async function ensureLibDeps(users, opts) {
|
|
|
2658
2659
|
}
|
|
2659
2660
|
for (const [name, { version, users: names }] of required) {
|
|
2660
2661
|
const reason = `the ${[...names].map((n) => `\`${n}\``).join(", ")} ${opts.label}${names.size > 1 ? "s" : ""}`;
|
|
2661
|
-
|
|
2662
|
+
const depOpts = {
|
|
2662
2663
|
id: name,
|
|
2663
2664
|
version,
|
|
2664
2665
|
dir: opts.dir,
|
|
2666
|
+
deps: { install: opts.deps?.install },
|
|
2665
2667
|
reason,
|
|
2666
2668
|
dev: false,
|
|
2667
2669
|
projectOnly: true
|
|
2668
|
-
}
|
|
2670
|
+
};
|
|
2671
|
+
if (await ensureDep(depOpts)) continue;
|
|
2672
|
+
if (!r$2 && !_canInstall(opts.deps?.install) && !_isInNodeModules(opts.dir)) throw missingDepError(depOpts);
|
|
2673
|
+
consola.warn(`\`${name}\` is not installed. It is required for ${reason}.`);
|
|
2669
2674
|
}
|
|
2670
2675
|
}
|
|
2671
2676
|
function _resolveDepOptions(opts) {
|
|
@@ -2689,7 +2694,7 @@ async function _ensureDep(opts) {
|
|
|
2689
2694
|
}
|
|
2690
2695
|
if (_isInNodeModules(opts.dir)) return;
|
|
2691
2696
|
let shouldInstall;
|
|
2692
|
-
if (r$2) shouldInstall = false;
|
|
2697
|
+
if (r$2 || !_canInstall(opts.deps?.install)) shouldInstall = false;
|
|
2693
2698
|
else if (opts.autoInstall) {
|
|
2694
2699
|
consola.info(`\`${opts.id}\` is required for ${opts.reason}. Installing automatically...`);
|
|
2695
2700
|
shouldInstall = true;
|
|
@@ -2717,6 +2722,9 @@ async function _ensureDep(opts) {
|
|
|
2717
2722
|
else consola.warn(`Installed \`${opts.id}\` in ${opts.dir}, but it cannot be resolved from there.`);
|
|
2718
2723
|
return installed;
|
|
2719
2724
|
}
|
|
2725
|
+
function _canInstall(install) {
|
|
2726
|
+
return install ?? !L$1;
|
|
2727
|
+
}
|
|
2720
2728
|
function _isInNodeModules(dir) {
|
|
2721
2729
|
return `${normalize$2(dir)}/`.includes("/node_modules/");
|
|
2722
2730
|
}
|
|
@@ -2775,7 +2783,7 @@ async function resolveDatabaseConnections(options) {
|
|
|
2775
2783
|
if (entries.length === 0) return [];
|
|
2776
2784
|
const { connectors, connectorDependencies } = await importDb0({
|
|
2777
2785
|
dir: options.rootDir,
|
|
2778
|
-
|
|
2786
|
+
deps: options.deps,
|
|
2779
2787
|
reason: "the `database` config"
|
|
2780
2788
|
});
|
|
2781
2789
|
return entries.map(([name, { connector, options: connectorOpts }]) => {
|
|
@@ -3856,6 +3864,41 @@ function getProperty(object, path, value) {
|
|
|
3856
3864
|
}
|
|
3857
3865
|
return object === void 0 ? value : object;
|
|
3858
3866
|
}
|
|
3867
|
+
const pathSeparators = /* @__PURE__ */ new Set([
|
|
3868
|
+
"/",
|
|
3869
|
+
"\\",
|
|
3870
|
+
void 0
|
|
3871
|
+
]);
|
|
3872
|
+
const normalizedAliasSymbol = Symbol.for("pathe:normalizedAlias");
|
|
3873
|
+
function normalizeAliases(_aliases) {
|
|
3874
|
+
if (_aliases[normalizedAliasSymbol]) return _aliases;
|
|
3875
|
+
const aliases = Object.fromEntries(Object.entries(_aliases).sort(([a], [b]) => _compareAliases(a, b)));
|
|
3876
|
+
for (const key in aliases) for (const alias in aliases) {
|
|
3877
|
+
if (alias === key || key.startsWith(alias)) continue;
|
|
3878
|
+
if (aliases[key]?.startsWith(alias) && pathSeparators.has(aliases[key][alias.length])) aliases[key] = aliases[alias] + aliases[key].slice(alias.length);
|
|
3879
|
+
}
|
|
3880
|
+
Object.defineProperty(aliases, normalizedAliasSymbol, {
|
|
3881
|
+
value: true,
|
|
3882
|
+
enumerable: false
|
|
3883
|
+
});
|
|
3884
|
+
return aliases;
|
|
3885
|
+
}
|
|
3886
|
+
function resolveAlias(path, aliases) {
|
|
3887
|
+
const _path = normalizeWindowsPath(path);
|
|
3888
|
+
aliases = normalizeAliases(aliases);
|
|
3889
|
+
for (const [alias, to] of Object.entries(aliases)) {
|
|
3890
|
+
if (!_path.startsWith(alias)) continue;
|
|
3891
|
+
if (hasTrailingSlash(_path[(hasTrailingSlash(alias) ? alias.slice(0, -1) : alias).length])) return join$2(to, _path.slice(alias.length));
|
|
3892
|
+
}
|
|
3893
|
+
return _path;
|
|
3894
|
+
}
|
|
3895
|
+
function _compareAliases(a, b) {
|
|
3896
|
+
return b.split("/").length - a.split("/").length;
|
|
3897
|
+
}
|
|
3898
|
+
function hasTrailingSlash(path = "/") {
|
|
3899
|
+
const lastChar = path[path.length - 1];
|
|
3900
|
+
return lastChar === "/" || lastChar === "\\";
|
|
3901
|
+
}
|
|
3859
3902
|
function prettyPath(p, highlight = true) {
|
|
3860
3903
|
p = relative$2(process.cwd(), p);
|
|
3861
3904
|
return highlight ? colors.cyan(p) : p;
|
|
@@ -3863,7 +3906,7 @@ function prettyPath(p, highlight = true) {
|
|
|
3863
3906
|
function resolveNitroPath(path, nitroOptions, base) {
|
|
3864
3907
|
if (typeof path !== "string") throw new TypeError("Invalid path: " + path);
|
|
3865
3908
|
path = _compilePathTemplate(path)(nitroOptions);
|
|
3866
|
-
|
|
3909
|
+
path = resolveAlias(path, nitroOptions.alias);
|
|
3867
3910
|
if (/^[#\u0000]/.test(path)) return path;
|
|
3868
3911
|
return resolve$2(base || nitroOptions.rootDir, path);
|
|
3869
3912
|
}
|
|
@@ -3916,7 +3959,7 @@ async function resolveKVDrivers(options) {
|
|
|
3916
3959
|
if (mounts.length === 0) return [];
|
|
3917
3960
|
const { builtinDrivers, builtinDriverDependencies } = await importUnstorage({
|
|
3918
3961
|
dir: options.rootDir,
|
|
3919
|
-
|
|
3962
|
+
deps: options.deps,
|
|
3920
3963
|
reason: "the `kv` config"
|
|
3921
3964
|
});
|
|
3922
3965
|
return mounts.map((mount) => ({
|
|
@@ -8039,7 +8082,8 @@ function viteImportOptions(nitro) {
|
|
|
8039
8082
|
return {
|
|
8040
8083
|
dir: nitro.options.rootDir,
|
|
8041
8084
|
path: nitro.options.vite?.path || _runningVite.get(nitro),
|
|
8042
|
-
plugin: _runningVite.has(nitro)
|
|
8085
|
+
plugin: _runningVite.has(nitro),
|
|
8086
|
+
deps: nitro.options.deps
|
|
8043
8087
|
};
|
|
8044
8088
|
}
|
|
8045
8089
|
function viteDepPaths(nitro) {
|
|
@@ -8080,7 +8124,10 @@ function _viteDep(opts) {
|
|
|
8080
8124
|
dir: opts.dir,
|
|
8081
8125
|
reason: deps.vite.reason,
|
|
8082
8126
|
version: deps.vite.version,
|
|
8083
|
-
|
|
8127
|
+
deps: {
|
|
8128
|
+
...opts.deps,
|
|
8129
|
+
paths: opts.path ? { [id]: opts.path } : void 0
|
|
8130
|
+
}
|
|
8084
8131
|
};
|
|
8085
8132
|
}
|
|
8086
8133
|
function _resolveFromPath(id, { dir, path }) {
|
|
@@ -8122,41 +8169,6 @@ function getPrerenderMeta(nitro) {
|
|
|
8122
8169
|
}
|
|
8123
8170
|
return meta;
|
|
8124
8171
|
}
|
|
8125
|
-
const pathSeparators = /* @__PURE__ */ new Set([
|
|
8126
|
-
"/",
|
|
8127
|
-
"\\",
|
|
8128
|
-
void 0
|
|
8129
|
-
]);
|
|
8130
|
-
const normalizedAliasSymbol = Symbol.for("pathe:normalizedAlias");
|
|
8131
|
-
function normalizeAliases(_aliases) {
|
|
8132
|
-
if (_aliases[normalizedAliasSymbol]) return _aliases;
|
|
8133
|
-
const aliases = Object.fromEntries(Object.entries(_aliases).sort(([a], [b]) => _compareAliases(a, b)));
|
|
8134
|
-
for (const key in aliases) for (const alias in aliases) {
|
|
8135
|
-
if (alias === key || key.startsWith(alias)) continue;
|
|
8136
|
-
if (aliases[key]?.startsWith(alias) && pathSeparators.has(aliases[key][alias.length])) aliases[key] = aliases[alias] + aliases[key].slice(alias.length);
|
|
8137
|
-
}
|
|
8138
|
-
Object.defineProperty(aliases, normalizedAliasSymbol, {
|
|
8139
|
-
value: true,
|
|
8140
|
-
enumerable: false
|
|
8141
|
-
});
|
|
8142
|
-
return aliases;
|
|
8143
|
-
}
|
|
8144
|
-
function resolveAlias(path, aliases) {
|
|
8145
|
-
const _path = normalizeWindowsPath(path);
|
|
8146
|
-
aliases = normalizeAliases(aliases);
|
|
8147
|
-
for (const [alias, to] of Object.entries(aliases)) {
|
|
8148
|
-
if (!_path.startsWith(alias)) continue;
|
|
8149
|
-
if (hasTrailingSlash(_path[(hasTrailingSlash(alias) ? alias.slice(0, -1) : alias).length])) return join$2(to, _path.slice(alias.length));
|
|
8150
|
-
}
|
|
8151
|
-
return _path;
|
|
8152
|
-
}
|
|
8153
|
-
function _compareAliases(a, b) {
|
|
8154
|
-
return b.split("/").length - a.split("/").length;
|
|
8155
|
-
}
|
|
8156
|
-
function hasTrailingSlash(path = "/") {
|
|
8157
|
-
const lastChar = path[path.length - 1];
|
|
8158
|
-
return lastChar === "/" || lastChar === "\\";
|
|
8159
|
-
}
|
|
8160
8172
|
function escapeRegExp$1(string) {
|
|
8161
8173
|
return string.replace(/[-\\^$*+?.()|[\]{}]/g, String.raw`\$&`);
|
|
8162
8174
|
}
|
|
@@ -8279,7 +8291,7 @@ function unenv(nitro, env) {
|
|
|
8279
8291
|
const opts = {
|
|
8280
8292
|
id: "unenv",
|
|
8281
8293
|
dir: nitro.options.rootDir,
|
|
8282
|
-
|
|
8294
|
+
deps: nitro.options.deps,
|
|
8283
8295
|
reason: `Node.js compatibility (\`${id}\` import with the \`${nitro.options.preset}\` preset)`
|
|
8284
8296
|
};
|
|
8285
8297
|
if (!await ensureDep(opts)) throw missingDepError(opts);
|
|
@@ -8306,7 +8318,7 @@ function unenv(nitro, env) {
|
|
|
8306
8318
|
await ensureUnenv(id);
|
|
8307
8319
|
const path = resolveDep(target || id, {
|
|
8308
8320
|
dir: nitro.options.rootDir,
|
|
8309
|
-
|
|
8321
|
+
deps: nitro.options.deps
|
|
8310
8322
|
});
|
|
8311
8323
|
if (!path) throw new Error(`Cannot resolve \`${target || id}\` (for \`${id}\`). Please make sure \`unenv@${deps.unenv.version}\` is installed in your project.`);
|
|
8312
8324
|
return await this.resolve(path, importer, {
|
|
@@ -8363,8 +8375,9 @@ function mergeEnv(layers) {
|
|
|
8363
8375
|
return env;
|
|
8364
8376
|
}
|
|
8365
8377
|
function resolveEnvPaths(env, rootDir) {
|
|
8378
|
+
const aliases = normalizeAliases(env.alias);
|
|
8366
8379
|
const resolve = (id) => {
|
|
8367
|
-
id = resolveAlias(id,
|
|
8380
|
+
id = resolveAlias(id, aliases);
|
|
8368
8381
|
if (id.startsWith("node:") || isUnenvId(id)) return id;
|
|
8369
8382
|
if (builtinModules.includes(id)) return `node:${id}`;
|
|
8370
8383
|
const from = id.startsWith(".") ? [rootDir] : [import.meta.url, rootDir];
|
|
@@ -8466,10 +8479,11 @@ function libChunkName(id) {
|
|
|
8466
8479
|
const pkgName = pathToPkgName(id);
|
|
8467
8480
|
return pkgName ? `_libs/${pkgName}` : void 0;
|
|
8468
8481
|
}
|
|
8469
|
-
function libChunksGroup() {
|
|
8482
|
+
function libChunksGroup(nitro) {
|
|
8470
8483
|
const group = {
|
|
8471
8484
|
test: NODE_MODULES_RE$2,
|
|
8472
|
-
name: (id) => libChunkName(id)
|
|
8485
|
+
name: (id) => libChunkName(id),
|
|
8486
|
+
entriesAware: nitro.options.experimental.entriesAwareLibChunks !== false
|
|
8473
8487
|
};
|
|
8474
8488
|
Object.defineProperty(group, "debugName", { value: "libs" });
|
|
8475
8489
|
return group;
|
|
@@ -8481,6 +8495,10 @@ function pathToPkgName(path) {
|
|
|
8481
8495
|
}
|
|
8482
8496
|
function getChunkName(chunk, nitro) {
|
|
8483
8497
|
if (chunk.name === "rolldown-runtime") return "_runtime.mjs";
|
|
8498
|
+
if (chunk.name.startsWith("_libs/")) chunk = {
|
|
8499
|
+
...chunk,
|
|
8500
|
+
name: chunk.name.split("~")[0]
|
|
8501
|
+
};
|
|
8484
8502
|
if (chunk.moduleIds.every((id) => NODE_MODULES_RE$2.test(id))) {
|
|
8485
8503
|
const chunkName = joinPkgNames(chunk.moduleIds);
|
|
8486
8504
|
if (chunkName.length > 30) return `${chunk.name}+[...].mjs`;
|
|
@@ -9002,7 +9020,8 @@ function publicAssets(nitro) {
|
|
|
9002
9020
|
};
|
|
9003
9021
|
}, { concurrency: 25 });
|
|
9004
9022
|
if (errors.length > 0) throw new Error(`Failed to process public assets:\n${errors.join("\n")}`, { cause: errors });
|
|
9005
|
-
|
|
9023
|
+
const sorted = Object.fromEntries(Object.entries(assets).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
|
|
9024
|
+
return `export default ${JSON.stringify(sorted, null, 2)};`;
|
|
9006
9025
|
}
|
|
9007
9026
|
},
|
|
9008
9027
|
{
|
|
@@ -13658,17 +13677,19 @@ function externals(opts) {
|
|
|
13658
13677
|
consola.info(`Ensure your production environment matches the builder OS and architecture (\`${process.platform}-${process.arch}\`) to avoid native module issues.`);
|
|
13659
13678
|
}
|
|
13660
13679
|
},
|
|
13661
|
-
renderChunk(code, chunk, outputOpts) {
|
|
13680
|
+
renderChunk(code, chunk, outputOpts, meta) {
|
|
13662
13681
|
if (tracedIds.size === 0 || !code.includes(TRACED_ID_PREFIX)) return;
|
|
13663
13682
|
const outDir = outputOpts.dir || opts.trace && opts.trace.outDir || opts.rootDir;
|
|
13664
13683
|
const s = new MagicString$1(code);
|
|
13684
|
+
let helperFileName;
|
|
13665
13685
|
for (const match of code.matchAll(TRACED_ID_RE)) {
|
|
13666
13686
|
const traced = tracedIds.get(match[0]);
|
|
13667
13687
|
if (!traced) continue;
|
|
13688
|
+
const fileName = isRequireCall(code, match.index) ? helperFileName ??= requireHelperFileName(chunk, meta?.chunks) : chunk.fileName;
|
|
13668
13689
|
s.update(match.index, match.index + match[0].length, renderTracedId(traced, {
|
|
13669
13690
|
layout: tracedLayout,
|
|
13670
13691
|
outDir,
|
|
13671
|
-
fileName
|
|
13692
|
+
fileName
|
|
13672
13693
|
}));
|
|
13673
13694
|
}
|
|
13674
13695
|
if (!s.hasChanged()) return;
|
|
@@ -13707,6 +13728,15 @@ function resolveTraceDeps(traceDeps, opts = {}) {
|
|
|
13707
13728
|
}
|
|
13708
13729
|
const TRACED_ID_PREFIX = "nitro:traced/";
|
|
13709
13730
|
const TRACED_ID_RE = /(?<=["'`])nitro:traced\/\d+\/[^"'`]+(?=["'`])/g;
|
|
13731
|
+
const REQUIRE_CALL_RE = /\b__require(?:\$\d+)?\(\s*["'`]$/;
|
|
13732
|
+
const ROLLDOWN_RUNTIME_ID = "\0rolldown/runtime.js";
|
|
13733
|
+
function isRequireCall(code, index) {
|
|
13734
|
+
return REQUIRE_CALL_RE.test(code.slice(Math.max(0, index - 32), index));
|
|
13735
|
+
}
|
|
13736
|
+
function requireHelperFileName(chunk, chunks) {
|
|
13737
|
+
if (chunk.moduleIds.includes(ROLLDOWN_RUNTIME_ID)) return chunk.fileName;
|
|
13738
|
+
return Object.values(chunks || {}).find((c) => c.moduleIds.includes(ROLLDOWN_RUNTIME_ID))?.fileName ?? chunk.fileName;
|
|
13739
|
+
}
|
|
13710
13740
|
function renderTracedId(traced, opts) {
|
|
13711
13741
|
const outFile = opts.layout?.files[traced.path];
|
|
13712
13742
|
const version = outFile && Object.values(opts.layout.packages).flatMap((pkg) => Object.values(pkg.versions)).find((v) => outFile.startsWith(`${v.outPath}/`));
|
|
@@ -13810,7 +13840,7 @@ function runtimeDeps(nitro) {
|
|
|
13810
13840
|
await ensureRuntimeDep(nitro, id);
|
|
13811
13841
|
const path = resolveDep(id, {
|
|
13812
13842
|
dir: nitro.options.rootDir,
|
|
13813
|
-
|
|
13843
|
+
deps: nitro.options.deps
|
|
13814
13844
|
});
|
|
13815
13845
|
if (!path) {
|
|
13816
13846
|
const name = depPackageName(id);
|
|
@@ -13828,7 +13858,7 @@ function runtimeDepOptions(nitro, id) {
|
|
|
13828
13858
|
return {
|
|
13829
13859
|
id: depPackageName(id),
|
|
13830
13860
|
dir: nitro.options.rootDir,
|
|
13831
|
-
|
|
13861
|
+
deps: nitro.options.deps
|
|
13832
13862
|
};
|
|
13833
13863
|
}
|
|
13834
13864
|
function tsconfigPaths(nitro, aliases) {
|
|
@@ -14155,4 +14185,4 @@ async function oxc(nitro, options) {
|
|
|
14155
14185
|
}
|
|
14156
14186
|
};
|
|
14157
14187
|
}
|
|
14158
|
-
export { Builder, F, L$1 as L, LogLevels, MagicString, MagicString$1, N$1 as N, NODE_MODULES_RE$2 as NODE_MODULES_RE, OPTIONAL_RUNTIME_DEPS_RE, RESOLVED_PREFIX, RESOLVED_RE, T, _resolveFromPath, assetUrls, attachScopes, baseBuildConfig, baseBuildPlugins, basename$2 as basename, build, builtinExternals, builtins, chain, colors, compressPublicAssets, consola, copyPublicAssets, createFilter, dataToEsm, deps, dirname$2 as dirname, e, ensureDep, ensureLibDeps, ensureRuntimeDep, escapeRegExp$1 as escapeRegExp, excludeSourcemapSources, extendEnv, extname$3 as extname, extractAssignedNames, getBuildInfo, getChunkName, getDevBuildInfo, getPrerenderMeta, glob, globPublicAssets, hash, i, ie, importAttributes, importDep, importOXC, importUnstorage, importVite, isAbsolute$2 as isAbsolute, isCaseInsensitiveFS, isCompressibleFile, isDepInstalled, isRuntimeImporter, join$2 as join, joinURL, kebabCase, libChunkName, libChunksGroup, makeLegalIdentifier, missingRuntimeDepError, normalize$2 as normalize, normalizeAliases, oxc, parseURL, prepare, prettyPath, r$2 as r, raw, relative$2 as relative, replace$1 as replace, resolve$2 as resolve, resolveAlias, resolveBuildPlugins, resolveDatabaseConnections, resolveDep, resolveFromDepPath, resolveKVDrivers, resolveKVMounts, resolveModulePath, resolveModuleURL, resolveNitroPath, resolveUnenv, resolveViteModuleRunner, routeMeta, runParallel, s$1 as s, scanUnprefixedPublicAssets, setRunningVite, shims, src_default, stripAnsi$1 as stripAnsi, tsconfigPaths, tsconfigPathsNoExternal, unwasm, virtualTemplates, viteDepPaths, viteImportOptions, walk, walkAST, withBase, withBuildPlugins, withLeadingSlash, withQuery, withTrailingSlash, withoutBase, withoutLeadingSlash, withoutTrailingSlash, writeBuildInfo, writeDevBuildInfo, writeFile$1 as writeFile };
|
|
14188
|
+
export { Builder, F, L$1 as L, LogLevels, MagicString, MagicString$1, N$1 as N, NODE_MODULES_RE$2 as NODE_MODULES_RE, OPTIONAL_RUNTIME_DEPS_RE, RESOLVED_PREFIX, RESOLVED_RE, T, _resolveFromPath, assetUrls, attachScopes, baseBuildConfig, baseBuildPlugins, basename$2 as basename, build, builtinExternals, builtins, chain, colors, compressPublicAssets, consola, copyPublicAssets, createFilter, dataToEsm, deps, dirname$2 as dirname, e, ensureDep, ensureLibDeps, ensureRuntimeDep, escapeRegExp$1 as escapeRegExp, excludeSourcemapSources, extendEnv, extname$3 as extname, extractAssignedNames, getBuildInfo, getChunkName, getDevBuildInfo, getPrerenderMeta, glob, globPublicAssets, hash, i, ie, importAttributes, importDep, importOXC, importUnstorage, importVite, isAbsolute$2 as isAbsolute, isCaseInsensitiveFS, isCompressibleFile, isDepInstalled, isRuntimeImporter, join$2 as join, joinURL, kebabCase, libChunkName, libChunksGroup, makeLegalIdentifier, missingDepError, missingRuntimeDepError, normalize$2 as normalize, normalizeAliases, oxc, parseURL, prepare, prettyPath, r$2 as r, raw, relative$2 as relative, replace$1 as replace, resolve$2 as resolve, resolveAlias, resolveBuildPlugins, resolveDatabaseConnections, resolveDep, resolveFromDepPath, resolveKVDrivers, resolveKVMounts, resolveModulePath, resolveModuleURL, resolveNitroPath, resolveUnenv, resolveViteModuleRunner, routeMeta, runParallel, s$1 as s, scanUnprefixedPublicAssets, setRunningVite, shims, src_default, stripAnsi$1 as stripAnsi, tsconfigPaths, tsconfigPathsNoExternal, unwasm, virtualTemplates, viteDepPaths, viteImportOptions, walk, walkAST, withBase, withBuildPlugins, withLeadingSlash, withQuery, withTrailingSlash, withoutBase, withoutLeadingSlash, withoutTrailingSlash, writeBuildInfo, writeDevBuildInfo, writeFile$1 as writeFile };
|
package/dist/_build/rolldown.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { assetUrls, baseBuildConfig, baseBuildPlugins, basename, builtinExternals, builtins, compressPublicAssets, excludeSourcemapSources, getChunkName, join, libChunksGroup, relative, withBuildPlugins, writeBuildInfo } from "./common.mjs";
|
|
2
2
|
import { defu } from "../_libs/c12+rc9+defu+destr.mjs";
|
|
3
|
-
import { formatCompatibilityDate } from "../_libs/compatx.mjs";
|
|
4
3
|
import { importRolldown } from "../_import.mjs";
|
|
5
|
-
import { createWatcher, generateFSTree } from "../_chunks/utils.mjs";
|
|
6
|
-
import { scanHandlers } from "../_chunks/nitro2.mjs";
|
|
7
4
|
import { debounce } from "../_libs/perfect-debounce.mjs";
|
|
5
|
+
import { scanHandlers } from "../_chunks/nitro2.mjs";
|
|
6
|
+
import { createWatcher, generateFSTree } from "../_chunks/utils.mjs";
|
|
7
|
+
import { formatCompatibilityDate } from "../_libs/compatx.mjs";
|
|
8
8
|
const getRolldownConfig = async (nitro) => {
|
|
9
9
|
const base = await baseBuildConfig(nitro);
|
|
10
10
|
const tsc = nitro.options.typescript.tsConfig?.compilerOptions;
|
|
@@ -43,7 +43,7 @@ const getRolldownConfig = async (nitro) => {
|
|
|
43
43
|
entryFileNames: "index.mjs",
|
|
44
44
|
minifyInternalExports: false,
|
|
45
45
|
chunkFileNames: (chunk) => getChunkName(chunk, nitro),
|
|
46
|
-
codeSplitting: { groups: [libChunksGroup()] },
|
|
46
|
+
codeSplitting: { groups: [libChunksGroup(nitro)] },
|
|
47
47
|
dir: nitro.options.output.serverDir,
|
|
48
48
|
inlineDynamicImports: nitro.options.inlineDynamicImports,
|
|
49
49
|
minify: nitro.options.minify ? true : "dce-only",
|
|
@@ -149,7 +149,7 @@ async function buildProduction(nitro, config, rolldown) {
|
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
async function rolldownBuild(nitro) {
|
|
152
|
-
const rolldown = await importRolldown(nitro.options.rootDir, {
|
|
152
|
+
const rolldown = await importRolldown(nitro.options.rootDir, { deps: nitro.options.deps });
|
|
153
153
|
await nitro.hooks.callHook("build:before", nitro);
|
|
154
154
|
const config = await getRolldownConfig(nitro);
|
|
155
155
|
await nitro.hooks.callHook("build:config", nitro, {
|
package/dist/_build/rollup.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { NODE_MODULES_RE, assetUrls, baseBuildConfig, baseBuildPlugins, basename, compressPublicAssets, getChunkName, importDep, isAbsolute, join, libChunkName, oxc, relative, withBuildPlugins, writeBuildInfo } from "./common.mjs";
|
|
2
1
|
import { defu } from "../_libs/c12+rc9+defu+destr.mjs";
|
|
3
|
-
import { formatCompatibilityDate } from "../_libs/compatx.mjs";
|
|
4
|
-
import { createWatcher, generateFSTree } from "../_chunks/utils.mjs";
|
|
5
|
-
import { scanHandlers } from "../_chunks/nitro2.mjs";
|
|
6
|
-
import { debounce } from "../_libs/perfect-debounce.mjs";
|
|
7
2
|
import { alias } from "../_libs/plugin-alias.mjs";
|
|
8
|
-
import { inject } from "../_libs/plugin-inject.mjs";
|
|
9
3
|
import { commonjs } from "../_libs/commondir+is-reference.mjs";
|
|
4
|
+
import { inject } from "../_libs/plugin-inject.mjs";
|
|
10
5
|
import { json } from "../_libs/plugin-json.mjs";
|
|
11
6
|
import { nodeResolve } from "../_libs/hasown+resolve+deepmerge.mjs";
|
|
7
|
+
import { NODE_MODULES_RE, assetUrls, baseBuildConfig, baseBuildPlugins, basename, compressPublicAssets, getChunkName, importDep, isAbsolute, join, libChunkName, oxc, relative, withBuildPlugins, writeBuildInfo } from "./common.mjs";
|
|
8
|
+
import { debounce } from "../_libs/perfect-debounce.mjs";
|
|
9
|
+
import { scanHandlers } from "../_chunks/nitro2.mjs";
|
|
10
|
+
import { createWatcher, generateFSTree } from "../_chunks/utils.mjs";
|
|
11
|
+
import { formatCompatibilityDate } from "../_libs/compatx.mjs";
|
|
12
12
|
const getRollupConfig = async (nitro) => {
|
|
13
13
|
const base = await baseBuildConfig(nitro);
|
|
14
14
|
const tsc = nitro.options.typescript.tsConfig?.compilerOptions;
|
|
@@ -91,7 +91,7 @@ function importRollup(nitro) {
|
|
|
91
91
|
return importDep({
|
|
92
92
|
id: "rollup",
|
|
93
93
|
dir: nitro.options.rootDir,
|
|
94
|
-
|
|
94
|
+
deps: nitro.options.deps
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
async function watchDev(nitro, rollupConfig) {
|
package/dist/_build/shared.mjs
CHANGED
|
@@ -106,7 +106,7 @@ function runtimeDepsPlugin(nitro, sync) {
|
|
|
106
106
|
const resolve = () => this.resolve(source, join(nitro.options.rootDir, "_"));
|
|
107
107
|
if (resolveDep(source, {
|
|
108
108
|
dir: nitro.options.rootDir,
|
|
109
|
-
|
|
109
|
+
deps: nitro.options.deps
|
|
110
110
|
})) return resolve();
|
|
111
111
|
if (sync) throw missingRuntimeDepError(nitro, source);
|
|
112
112
|
return ensureRuntimeDep(nitro, source).then(resolve);
|
package/dist/_build/shared2.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { normalize, withTrailingSlash } from "./common.mjs";
|
|
2
1
|
import { formatCompatibilityDate } from "../_libs/compatx.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { scanHandlers } from "../_chunks/nitro2.mjs";
|
|
2
|
+
import { normalize, withTrailingSlash } from "./common.mjs";
|
|
5
3
|
import { debounce } from "../_libs/perfect-debounce.mjs";
|
|
4
|
+
import { scanHandlers } from "../_chunks/nitro2.mjs";
|
|
5
|
+
import { createWatcher } from "../_chunks/utils.mjs";
|
|
6
6
|
import { prepareUnbundledApp, unbundledPlugins } from "./shared.mjs";
|
|
7
7
|
const ignoredRe = /(?:^|\/)(?:node_modules|\.[^/]+)(?:\/|$)/;
|
|
8
8
|
const sourceRe = /\.(?:[cm]?[jt]sx?|json|wasm|txt|html|md|ya?ml|toml|sql)$/;
|
package/dist/_build/vite.dev.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _resolveFromPath, importVite, isAbsolute, join, relative, withBase, withoutBase, writeDevBuildInfo } from "./common.mjs";
|
|
2
2
|
import { debounce } from "../_libs/perfect-debounce.mjs";
|
|
3
|
-
import { handleDevRPC } from "../_rpc.mjs";
|
|
3
|
+
import { DevReloadSignal, handleDevRPC, withDevErrorRecovery } from "../_rpc.mjs";
|
|
4
4
|
import { _isWorkerdRunner, rescanHandlers, watchScanDirs } from "../_scan-watch.mjs";
|
|
5
5
|
import { statSync } from "node:fs";
|
|
6
6
|
import { readFile } from "node:fs/promises";
|
|
@@ -30,6 +30,7 @@ function getFetchableDevEnvironment(opts) {
|
|
|
30
30
|
function _defineFetchableDevEnvironment({ DevEnvironment }) {
|
|
31
31
|
return class FetchableDevEnvironment extends DevEnvironment {
|
|
32
32
|
devServer;
|
|
33
|
+
onClose;
|
|
33
34
|
#entry;
|
|
34
35
|
#workerd;
|
|
35
36
|
#onInit;
|
|
@@ -64,6 +65,7 @@ function _defineFetchableDevEnvironment({ DevEnvironment }) {
|
|
|
64
65
|
});
|
|
65
66
|
}
|
|
66
67
|
async close() {
|
|
68
|
+
this.onClose?.();
|
|
67
69
|
await super.close();
|
|
68
70
|
await this.devServer.close?.();
|
|
69
71
|
}
|
|
@@ -73,6 +75,9 @@ async function configureViteDevServer(ctx, server) {
|
|
|
73
75
|
const nitro = ctx.nitro;
|
|
74
76
|
const nitroEnv = server.environments.nitro;
|
|
75
77
|
const viteBase = server.config.base || "/";
|
|
78
|
+
const reloadSignal = new DevReloadSignal();
|
|
79
|
+
ctx.devApp.reloadSignal = reloadSignal;
|
|
80
|
+
nitroEnv.onClose = () => reloadSignal.close();
|
|
76
81
|
const nitroConfigFile = nitro.options._c12.configFile;
|
|
77
82
|
if (nitroConfigFile) server.config.configFileDependencies.push(nitroConfigFile);
|
|
78
83
|
const websocket = (nitro.options.features.websocket ?? nitro.options.experimental.websocket) || _isWorkerdRunner(ctx);
|
|
@@ -92,6 +97,7 @@ async function configureViteDevServer(ctx, server) {
|
|
|
92
97
|
const reload = debounce(async () => {
|
|
93
98
|
await rescanHandlers(nitro, nitroEnv);
|
|
94
99
|
nitroEnv.hot.send({ type: "full-reload" });
|
|
100
|
+
ctx.devApp?.reloadSignal.bump();
|
|
95
101
|
});
|
|
96
102
|
watchScanDirs(nitro, server, () => reload());
|
|
97
103
|
if (!server.config.server.middlewareMode) {
|
|
@@ -144,7 +150,11 @@ async function configureViteDevServer(ctx, server) {
|
|
|
144
150
|
await envRes.body?.cancel();
|
|
145
151
|
return next();
|
|
146
152
|
}
|
|
147
|
-
return await sendNodeResponse(nodeRes, envRes
|
|
153
|
+
return await sendNodeResponse(nodeRes, withDevErrorRecovery(req, envRes, {
|
|
154
|
+
signal: ctx.devApp.reloadSignal,
|
|
155
|
+
base: nitro.options.baseURL,
|
|
156
|
+
poll: true
|
|
157
|
+
}));
|
|
148
158
|
} catch (error) {
|
|
149
159
|
if (_isResponseDestroyed(nodeRes)) return;
|
|
150
160
|
return next(error);
|
package/dist/_chunks/nitro.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { consola, ensureDep, ensureLibDeps, hash, ie, importUnstorage, isAbsolute, isDepInstalled, join, joinURL, prettyPath, r, resolve, resolveDatabaseConnections, resolveKVDrivers, resolveKVMounts, resolveModulePath, resolveModuleURL, resolveNitroPath, resolveUnenv, s, withLeadingSlash, withTrailingSlash, withoutTrailingSlash } from "../_build/common.mjs";
|
|
1
|
+
import { consola, ensureDep, ensureLibDeps, hash, ie, importUnstorage, isAbsolute, isDepInstalled, join, joinURL, missingDepError, prettyPath, r, resolve, resolveDatabaseConnections, resolveKVDrivers, resolveKVMounts, resolveModulePath, resolveModuleURL, resolveNitroPath, resolveUnenv, s, withLeadingSlash, withTrailingSlash, withoutTrailingSlash } from "../_build/common.mjs";
|
|
2
2
|
import { Hookable, createDebugger, mergeHooks } from "../_libs/hookable.mjs";
|
|
3
3
|
import { createDefu, defu, loadConfig, watchConfig } from "../_libs/c12+rc9+defu+destr.mjs";
|
|
4
4
|
import { resolveCompatibilityDates, resolveCompatibilityDatesFromEnv } from "../_libs/compatx.mjs";
|
|
@@ -140,6 +140,7 @@ async function resolveDatabaseOptions(options) {
|
|
|
140
140
|
name: connection.connector
|
|
141
141
|
})), {
|
|
142
142
|
dir: options.rootDir,
|
|
143
|
+
deps: options.deps,
|
|
143
144
|
label: "database connector"
|
|
144
145
|
});
|
|
145
146
|
}
|
|
@@ -362,6 +363,7 @@ async function resolveKVOptions(options) {
|
|
|
362
363
|
if (options.devStorage && Object.keys(options.devStorage).length > 0) consola.warn(`"devStorage" option is deprecated. Please use "kv" inside "$development" (and "$prerender") config instead.`);
|
|
363
364
|
await ensureLibDeps(await resolveKVDrivers(options), {
|
|
364
365
|
dir: options.rootDir,
|
|
366
|
+
deps: options.deps,
|
|
365
367
|
label: "storage driver"
|
|
366
368
|
});
|
|
367
369
|
}
|
|
@@ -377,7 +379,7 @@ async function resolveCacheOptions(options) {
|
|
|
377
379
|
if (!cacheDrivers.has(options.cache.driver)) throw new Error(`Invalid \`cache.driver\`: ${JSON.stringify(options.cache.driver)}. Expected one of: ${[...cacheDrivers].map((d) => `"${d}"`).join(", ")}.`);
|
|
378
380
|
if (options.cache.driver === "kv") await importUnstorage({
|
|
379
381
|
dir: options.rootDir,
|
|
380
|
-
|
|
382
|
+
deps: options.deps,
|
|
381
383
|
reason: "`cache.driver: \"kv\"`"
|
|
382
384
|
});
|
|
383
385
|
if (options.cache.driver === "fs") {
|
|
@@ -422,16 +424,17 @@ async function resolveBuilder(options) {
|
|
|
422
424
|
if (!VALID_BUILDERS.includes(options.builder)) throw new Error(`Invalid nitro builder "${options.builder}". Valid builders are: ${VALID_BUILDERS.join(", ")}.`);
|
|
423
425
|
const pkg = options.builder;
|
|
424
426
|
if (pkg === "rolldown" || pkg === "vite") return;
|
|
425
|
-
|
|
427
|
+
const depOpts = {
|
|
426
428
|
id: pkg,
|
|
427
429
|
dir: options.rootDir,
|
|
428
|
-
|
|
429
|
-
}
|
|
430
|
+
deps: options.deps
|
|
431
|
+
};
|
|
432
|
+
if (!await ensureDep(depOpts)) throw missingDepError(depOpts);
|
|
430
433
|
return;
|
|
431
434
|
}
|
|
432
435
|
if (isDepInstalled("vite", {
|
|
433
436
|
dir: options.rootDir,
|
|
434
|
-
|
|
437
|
+
deps: options.deps
|
|
435
438
|
}) && hasNitroViteConfig(options)) {
|
|
436
439
|
if (!options.dev) {
|
|
437
440
|
options.builder = "vite";
|
package/dist/_chunks/nitro3.mjs
CHANGED
|
@@ -39,7 +39,7 @@ async function startPreview(opts) {
|
|
|
39
39
|
}
|
|
40
40
|
let fetchHandler = () => Promise.resolve(new Response("Not Found", { status: 404 }));
|
|
41
41
|
if (buildInfo.serverEntry) {
|
|
42
|
-
|
|
42
|
+
setUnsetEnv(dotEnvEntries);
|
|
43
43
|
const { loadServerEntry } = await import("srvx/loader");
|
|
44
44
|
const entry = await loadServerEntry({
|
|
45
45
|
entry: resolve(outputDir, buildInfo.serverEntry),
|
|
@@ -62,6 +62,11 @@ async function startPreview(opts) {
|
|
|
62
62
|
async close() {}
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
+
async function applyPreviewDotEnv(root) {
|
|
66
|
+
const entries = await loadPreviewDotEnv(root);
|
|
67
|
+
setUnsetEnv(entries);
|
|
68
|
+
return entries;
|
|
69
|
+
}
|
|
65
70
|
async function loadPreviewDotEnv(root) {
|
|
66
71
|
const { loadDotenv } = await import("../_libs/_.mjs");
|
|
67
72
|
const env = await loadDotenv({
|
|
@@ -146,4 +151,7 @@ async function warnOutdatedBuild(rootDir, buildDate) {
|
|
|
146
151
|
}
|
|
147
152
|
}
|
|
148
153
|
}
|
|
149
|
-
|
|
154
|
+
function setUnsetEnv(entries) {
|
|
155
|
+
for (const [key, val] of entries) if (!process.env[key]) process.env[key] = val;
|
|
156
|
+
}
|
|
157
|
+
export { applyPreviewDotEnv, startPreview };
|
package/dist/_chunks/nitro4.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { build, colors, compressPublicAssets, consola, getPrerenderMeta, isCaseInsensitiveFS, join, joinURL, parseURL, prettyPath, relative, resolve, runParallel, scanUnprefixedPublicAssets, src_default, viteDepPaths, withBase, withQuery, withTrailingSlash, withoutBase, writeFile as writeFile$1 } from "../_build/common.mjs";
|
|
2
|
-
import { defu } from "../_libs/c12+rc9+defu+destr.mjs";
|
|
3
1
|
import { createNitro } from "./nitro.mjs";
|
|
4
|
-
import {
|
|
2
|
+
import { build, colors, compressPublicAssets, consola, getPrerenderMeta, isCaseInsensitiveFS, join, joinURL, parseURL, prettyPath, relative, resolve, runParallel, scanUnprefixedPublicAssets, src_default, viteDepPaths, withBase, withQuery, withTrailingSlash, withoutBase, writeFile as writeFile$1 } from "../_build/common.mjs";
|
|
5
3
|
import "../_dev.mjs";
|
|
6
4
|
import "./nitro3.mjs";
|
|
5
|
+
import { defu } from "../_libs/c12+rc9+defu+destr.mjs";
|
|
6
|
+
import { resolveRolldown } from "../_import.mjs";
|
|
7
7
|
import { parse, walk } from "../_libs/ultrahtml.mjs";
|
|
8
8
|
import { existsSync } from "node:fs";
|
|
9
9
|
import { readFile } from "node:fs/promises";
|
package/dist/_chunks/utils.mjs
CHANGED
|
@@ -27,6 +27,7 @@ const envSuffixes = /* @__PURE__ */ new Set([
|
|
|
27
27
|
"prerender"
|
|
28
28
|
]);
|
|
29
29
|
const lastSuffixRe = /(?<=[^/])\.([a-z]+)$/;
|
|
30
|
+
const orderPrefixRe = /(?:^|\/)\d+$/;
|
|
30
31
|
function parseScanPath(nitro, file, opts = {}) {
|
|
31
32
|
const result = { name: file.path.replace(/\.[A-Za-z]+$/, "") };
|
|
32
33
|
const env = result.name.match(lastSuffixRe)?.[1];
|
|
@@ -40,7 +41,7 @@ function parseScanPath(nitro, file, opts = {}) {
|
|
|
40
41
|
result.name = result.name.slice(0, -method.length - 1);
|
|
41
42
|
}
|
|
42
43
|
const suffix = result.name.match(lastSuffixRe)?.[1];
|
|
43
|
-
if (!suffix || opts.method && methodSuffixes.has(suffix) || opts.env && envSuffixes.has(suffix) || src_default.getType(suffix) || nitro.options.scanSuffixes?.includes(suffix)) return result;
|
|
44
|
+
if (!suffix || opts.method && methodSuffixes.has(suffix) || opts.env && envSuffixes.has(suffix) || src_default.getType(suffix) || nitro.options.scanSuffixes?.includes(suffix) || !methodSuffixes.has(suffix) && !envSuffixes.has(suffix) && orderPrefixRe.test(result.name.slice(0, -suffix.length - 1))) return result;
|
|
44
45
|
const filePath = `${file.dir}/${file.path}`;
|
|
45
46
|
const message = methodSuffixes.has(suffix) || envSuffixes.has(suffix) ? `The \`.${suffix}\` suffix is not supported in \`${file.dir}/\` (\`${filePath}\`).` : `Unknown suffix \`.${suffix}\` in \`${filePath}\`. Nitro reserves dotted suffixes in scanned file names; known file extensions (e.g. \`.json\`, \`.md\`) are kept as-is. Add \`"${suffix}"\` to the \`scanSuffixes\` config to keep it as part of the name.`;
|
|
46
47
|
if (nitro.options.dev) {
|
package/dist/_dev.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { L, basename, consola, dirname, extname, isCompressibleFile, join, joinURL, r, resolve, src_default, withoutBase, withoutTrailingSlash, writeDevBuildInfo } from "./_build/common.mjs";
|
|
2
|
-
import { createWatcher } from "./_chunks/utils.mjs";
|
|
3
2
|
import { debounce } from "./_libs/perfect-debounce.mjs";
|
|
4
3
|
import { createProxyServer, proxyFetch } from "./_libs/httpxy.mjs";
|
|
4
|
+
import { DEV_RELOAD_ROUTE, DevReloadSignal, handleDevRPC, resolveRunnerDeps, shutdownRunner, withDevErrorRecovery } from "./_rpc.mjs";
|
|
5
5
|
import { parse } from "./_libs/cookie-es.mjs";
|
|
6
6
|
import { js_default, js_template_literals, jsdoc, json_default, regex, todo, tokenize, ts_default } from "./_libs/rangi.mjs";
|
|
7
|
-
import {
|
|
7
|
+
import { createWatcher } from "./_chunks/utils.mjs";
|
|
8
8
|
import { createReadStream } from "node:fs";
|
|
9
9
|
import { mkdir, readFile, stat, writeFile } from "node:fs/promises";
|
|
10
10
|
import { randomUUID } from "node:crypto";
|
|
@@ -1008,6 +1008,7 @@ async function defaultHandler(error, event, opts) {
|
|
|
1008
1008
|
var NitroDevApp = class {
|
|
1009
1009
|
nitro;
|
|
1010
1010
|
fetch;
|
|
1011
|
+
reloadSignal = new DevReloadSignal();
|
|
1011
1012
|
#wsProxies;
|
|
1012
1013
|
#routes = createRouter();
|
|
1013
1014
|
constructor(nitro, catchAllHandler) {
|
|
@@ -1024,6 +1025,9 @@ var NitroDevApp = class {
|
|
|
1024
1025
|
return errorHandler$1(error, event, { defaultHandler });
|
|
1025
1026
|
}
|
|
1026
1027
|
});
|
|
1028
|
+
const reloadRoute = joinURL(this.nitro.options.baseURL, DEV_RELOAD_ROUTE);
|
|
1029
|
+
app.get(reloadRoute, (event) => this.reloadSignal.handle(event));
|
|
1030
|
+
this.#addRoute("GET", reloadRoute);
|
|
1027
1031
|
for (const h of this.nitro.options.devHandlers) {
|
|
1028
1032
|
const handler = toEventHandler(h.handler);
|
|
1029
1033
|
if (!handler) {
|
|
@@ -1205,6 +1209,11 @@ var DevServer = class DevServer extends NitroDevApp {
|
|
|
1205
1209
|
const value = this[key];
|
|
1206
1210
|
if (typeof value === "function" && key !== "constructor") this[key] = value.bind(this);
|
|
1207
1211
|
}
|
|
1212
|
+
const appFetch = this.fetch;
|
|
1213
|
+
this.fetch = async (req) => withDevErrorRecovery(req, await appFetch(req), {
|
|
1214
|
+
signal: this.reloadSignal,
|
|
1215
|
+
base: nitro.options.baseURL
|
|
1216
|
+
});
|
|
1208
1217
|
nitro.fetch = this.fetch.bind(this);
|
|
1209
1218
|
this.#entry = resolve(nitro.options.output.dir, nitro.options.output.serverDir, "index.mjs");
|
|
1210
1219
|
this.#manager = new RunnerManager();
|
|
@@ -1224,7 +1233,7 @@ var DevServer = class DevServer extends NitroDevApp {
|
|
|
1224
1233
|
this.#workerError = cause;
|
|
1225
1234
|
if (this.#workerRetries++ < 3) {
|
|
1226
1235
|
this.nitro.logger.info("Restarting dev worker...", cause ? `Cause: ${cause}` : "");
|
|
1227
|
-
this
|
|
1236
|
+
this.#queueReload();
|
|
1228
1237
|
} else this.nitro.logger.error("Dev worker failed after 3 retries.", cause ? `Last cause: ${cause}` : "");
|
|
1229
1238
|
});
|
|
1230
1239
|
this.#manager.onMessage((message) => handleDevRPC(message, {
|
|
@@ -1247,6 +1256,7 @@ var DevServer = class DevServer extends NitroDevApp {
|
|
|
1247
1256
|
nitro.hooks.hook("dev:error", (cause) => {
|
|
1248
1257
|
this.#buildError = cause;
|
|
1249
1258
|
this.#building = false;
|
|
1259
|
+
this.reloadSignal.bump();
|
|
1250
1260
|
});
|
|
1251
1261
|
const devWatch = nitro.options.devServer.watch;
|
|
1252
1262
|
if (devWatch && devWatch.length > 0) {
|
|
@@ -1289,6 +1299,7 @@ var DevServer = class DevServer extends NitroDevApp {
|
|
|
1289
1299
|
}
|
|
1290
1300
|
async close() {
|
|
1291
1301
|
this.#closing = true;
|
|
1302
|
+
this.reloadSignal.close();
|
|
1292
1303
|
await this.#reloadPromise?.catch(() => {});
|
|
1293
1304
|
const drain = this.nitro.options.devServer.drain;
|
|
1294
1305
|
if (!drain) await this.#shutdownWorker();
|
|
@@ -1305,11 +1316,15 @@ var DevServer = class DevServer extends NitroDevApp {
|
|
|
1305
1316
|
})));
|
|
1306
1317
|
}
|
|
1307
1318
|
reload() {
|
|
1319
|
+
this.#queueReload()?.catch(() => {}).finally(() => this.reloadSignal.bump());
|
|
1320
|
+
}
|
|
1321
|
+
#queueReload() {
|
|
1308
1322
|
if (this.#closing) return;
|
|
1309
1323
|
const nextReload = (this.#reloadPromise ?? Promise.resolve()).catch(() => {}).then(() => this.#reload());
|
|
1310
1324
|
this.#reloadPromise = nextReload.finally(() => {
|
|
1311
1325
|
if (this.#reloadPromise === nextReload) this.#reloadPromise = void 0;
|
|
1312
1326
|
});
|
|
1327
|
+
return nextReload;
|
|
1313
1328
|
}
|
|
1314
1329
|
async #reload() {
|
|
1315
1330
|
const drain = this.nitro.options.devServer.drain;
|