nitro-nightly 3.1.0-20251028-004953-57503e42 → 3.1.0-20251028-090722-437659e4
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/assets.mjs +235 -0
- package/dist/_build/build.mjs +21 -0
- package/dist/_build/config.mjs +124 -0
- package/dist/_build/info.mjs +39 -0
- package/dist/_build/plugins.mjs +1041 -0
- package/dist/_build/prepare.mjs +17 -0
- package/dist/{_chunks/build2.mjs → _build/rolldown.mjs} +238 -64
- package/dist/_build/rollup.mjs +404 -0
- package/dist/_build/snapshot.mjs +61 -0
- package/dist/_build/types.mjs +268 -0
- package/dist/_build/vite.mjs +3266 -0
- package/dist/{cli → _cli}/build.mjs +2 -3
- package/dist/_cli/dev.mjs +205 -0
- package/dist/{cli/index2.mjs → _cli/index.mjs} +1 -2
- package/dist/{cli → _cli}/list.mjs +2 -3
- package/dist/{cli → _cli}/prepare.mjs +2 -3
- package/dist/{cli → _cli}/run.mjs +2 -3
- package/dist/_deps/@jridgewell/gen-mapping.mjs +189 -0
- package/dist/_deps/@jridgewell/remapping.mjs +137 -0
- package/dist/_deps/@jridgewell/resolve-uri.mjs +231 -0
- package/dist/_deps/@jridgewell/sourcemap-codec.mjs +173 -0
- package/dist/_deps/@jridgewell/trace-mapping.mjs +170 -0
- package/dist/_deps/@pi0/vite-plugin-fullstack.mjs +575 -0
- package/dist/_deps/@rollup/plugin-alias.mjs +89 -0
- package/dist/_deps/@rollup/plugin-commonjs.mjs +2376 -0
- package/dist/{_chunks/index2.mjs → _deps/@rollup/plugin-inject.mjs} +5 -90
- package/dist/_deps/@rollup/plugin-json.mjs +37 -0
- package/dist/_deps/@rollup/plugin-node-resolve.mjs +1386 -0
- package/dist/_deps/@rollup/plugin-replace.mjs +133 -0
- package/dist/_deps/@rollup/pluginutils.mjs +346 -0
- package/dist/_deps/acorn.mjs +6225 -0
- package/dist/_deps/c12.mjs +510 -0
- package/dist/_deps/chokidar.mjs +1428 -0
- package/dist/_deps/citty.mjs +460 -0
- package/dist/_deps/commondir.mjs +77 -0
- package/dist/_deps/compatx.mjs +76 -0
- package/dist/_deps/confbox.mjs +300 -0
- package/dist/_deps/debug.mjs +885 -0
- package/dist/_deps/deepmerge.mjs +147 -0
- package/dist/_deps/depd.mjs +550 -0
- package/dist/_deps/dot-prop.mjs +282 -0
- package/dist/_deps/dotenv.mjs +555 -0
- package/dist/_deps/duplexer.mjs +1 -0
- package/dist/_deps/ee-first.mjs +104 -0
- package/dist/_deps/encodeurl.mjs +69 -0
- package/dist/_deps/escape-html.mjs +87 -0
- package/dist/_deps/escape-string-regexp.mjs +13 -0
- package/dist/_deps/estree-walker.mjs +433 -0
- package/dist/_deps/etag.mjs +147 -0
- package/dist/_deps/exsolve.mjs +1416 -0
- package/dist/_deps/fdir.mjs +569 -0
- package/dist/_deps/fresh.mjs +145 -0
- package/dist/_deps/function-bind.mjs +106 -0
- package/dist/{_chunks/index4.mjs → _deps/giget.mjs} +21 -776
- package/dist/_deps/gzip-size.mjs +19 -0
- package/dist/_deps/hasown.mjs +19 -0
- package/dist/_deps/http-errors.mjs +307 -0
- package/dist/_deps/httpxy.mjs +580 -0
- package/dist/_deps/inherits.mjs +57 -0
- package/dist/_deps/is-core-module.mjs +596 -0
- package/dist/_deps/is-module.mjs +25 -0
- package/dist/_deps/is-reference.mjs +31 -0
- package/dist/_deps/js-tokens.mjs +411 -0
- package/dist/_deps/knitwork.mjs +172 -0
- package/dist/_deps/local-pkg.mjs +163 -0
- package/dist/_deps/magic-string.mjs +1296 -0
- package/dist/_deps/mime-db.mjs +11685 -0
- package/dist/_deps/mime-types.mjs +287 -0
- package/dist/_deps/mime.mjs +1172 -0
- package/dist/_deps/mlly.mjs +2413 -0
- package/dist/_deps/ms.mjs +172 -0
- package/dist/_deps/node-fetch-native.mjs +3 -0
- package/dist/_deps/nypm.mjs +219 -0
- package/dist/_deps/on-finished.mjs +246 -0
- package/dist/_deps/parseurl.mjs +168 -0
- package/dist/_deps/path-parse.mjs +85 -0
- package/dist/{_chunks/pathe.M-eThtNZ.mjs → _deps/pathe.mjs} +48 -1
- package/dist/_deps/perfect-debounce.mjs +88 -0
- package/dist/_deps/picomatch.mjs +2144 -0
- package/dist/_deps/pkg-types.mjs +247 -0
- package/dist/_deps/pretty-bytes.mjs +180 -0
- package/dist/_deps/quansync.mjs +99 -0
- package/dist/_deps/range-parser.mjs +171 -0
- package/dist/_deps/rc9.mjs +219 -0
- package/dist/_deps/readdirp.mjs +245 -0
- package/dist/_deps/resolve.mjs +1260 -0
- package/dist/_deps/rou3.mjs +326 -0
- package/dist/_deps/send.mjs +1022 -0
- package/dist/_deps/serve-static.mjs +228 -0
- package/dist/_deps/setprototypeof.mjs +26 -0
- package/dist/_deps/statuses.mjs +457 -0
- package/dist/_deps/strip-literal.mjs +67 -0
- package/dist/_deps/supports-color.mjs +44 -0
- package/dist/_deps/tinyexec.mjs +552 -0
- package/dist/_deps/tinyglobby.mjs +293 -0
- package/dist/_deps/toidentifier.mjs +41 -0
- package/dist/_deps/ultrahtml.mjs +3 -0
- package/dist/_deps/unimport.mjs +2267 -0
- package/dist/_deps/unplugin-utils.mjs +65 -0
- package/dist/_deps/unplugin.mjs +1294 -0
- package/dist/_deps/untyped.mjs +375 -0
- package/dist/{_chunks/info.mjs → _deps/unwasm.mjs} +8 -4122
- package/dist/_deps/webpack-virtual-modules.mjs +360 -0
- package/dist/_presets/_all.mjs +59 -0
- package/dist/_presets/_nitro.mjs +74 -0
- package/dist/_presets/_resolve.mjs +64 -0
- package/dist/_presets/_static.mjs +69 -0
- package/dist/_presets/_types.mjs +3 -0
- package/dist/_presets/_utils.mjs +31 -0
- package/dist/_presets/alwaysdata.mjs +17 -0
- package/dist/_presets/aws-amplify.mjs +111 -0
- package/dist/_presets/aws-lambda.mjs +23 -0
- package/dist/_presets/azure.mjs +162 -0
- package/dist/_presets/bun.mjs +19 -0
- package/dist/_presets/cleavr.mjs +15 -0
- package/dist/_presets/cloudflare.mjs +608 -0
- package/dist/_presets/deno.mjs +196 -0
- package/dist/_presets/digitalocean.mjs +14 -0
- package/dist/_presets/firebase.mjs +47 -0
- package/dist/_presets/flightcontrol.mjs +14 -0
- package/dist/_presets/genezio.mjs +13 -0
- package/dist/_presets/heroku.mjs +14 -0
- package/dist/_presets/iis.mjs +194 -0
- package/dist/_presets/index.mjs +62 -0
- package/dist/_presets/koyeb.mjs +14 -0
- package/dist/_presets/netlify.mjs +241 -0
- package/dist/_presets/node.mjs +54 -0
- package/dist/_presets/platform.mjs +14 -0
- package/dist/_presets/render.mjs +14 -0
- package/dist/_presets/standard.mjs +23 -0
- package/dist/_presets/stormkit.mjs +18 -0
- package/dist/_presets/vercel.mjs +365 -0
- package/dist/_presets/winterjs.mjs +22 -0
- package/dist/_presets/zeabur.mjs +69 -0
- package/dist/_presets/zerops.mjs +27 -0
- package/dist/cli/index.mjs +7 -464
- package/dist/index.mjs +122 -34
- package/dist/vite.mjs +118 -44
- package/package.json +1 -1
- package/dist/_chunks/app.mjs +0 -19797
- package/dist/_chunks/build.mjs +0 -86
- package/dist/_chunks/build3.mjs +0 -6538
- package/dist/_chunks/detect-acorn.mjs +0 -503
- package/dist/_chunks/index.mjs +0 -22256
- package/dist/_chunks/index3.mjs +0 -1062
- package/dist/_chunks/json5.mjs +0 -68
- package/dist/_chunks/jsonc.mjs +0 -51
- package/dist/_chunks/plugin.mjs +0 -1560
- package/dist/_chunks/server.mjs +0 -254
- package/dist/_chunks/snapshot.mjs +0 -376
- package/dist/_chunks/toml.mjs +0 -259
- package/dist/_chunks/yaml.mjs +0 -86
- package/dist/cli/dev.mjs +0 -95
- package/dist/presets.mjs +0 -2494
- /package/dist/{cli → _cli}/common.mjs +0 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { existsSync, promises } from 'node:fs';
|
|
2
|
+
import { g as glob } from '../_deps/tinyglobby.mjs';
|
|
3
|
+
import fsp, { stat, mkdir, writeFile as writeFile$1 } from 'node:fs/promises';
|
|
4
|
+
import consola from 'consola';
|
|
5
|
+
import { colors } from 'consola/utils';
|
|
6
|
+
import { g as getProperty } from '../_deps/dot-prop.mjs';
|
|
7
|
+
import { r as relative, a as resolve, d as dirname, j as join } from '../_deps/pathe.mjs';
|
|
8
|
+
import zlib from 'node:zlib';
|
|
9
|
+
import { m as mime } from '../_deps/mime.mjs';
|
|
10
|
+
|
|
11
|
+
function prettyPath(p, highlight = true) {
|
|
12
|
+
p = relative(process.cwd(), p);
|
|
13
|
+
return highlight ? colors.cyan(p) : p;
|
|
14
|
+
}
|
|
15
|
+
function resolveNitroPath(path, nitroOptions, base) {
|
|
16
|
+
if (typeof path !== "string") {
|
|
17
|
+
throw new TypeError("Invalid path: " + path);
|
|
18
|
+
}
|
|
19
|
+
path = _compilePathTemplate(path)(nitroOptions);
|
|
20
|
+
for (const base2 in nitroOptions.alias) {
|
|
21
|
+
if (path.startsWith(base2)) {
|
|
22
|
+
path = nitroOptions.alias[base2] + path.slice(base2.length);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return resolve(base || nitroOptions.srcDir, path);
|
|
26
|
+
}
|
|
27
|
+
function _compilePathTemplate(contents) {
|
|
28
|
+
return (params) => contents.replace(/{{ ?([\w.]+) ?}}/g, (_, match) => {
|
|
29
|
+
const val = getProperty(params, match);
|
|
30
|
+
if (!val) {
|
|
31
|
+
consola.warn(
|
|
32
|
+
`cannot resolve template param '${match}' in ${contents.slice(0, 20)}`
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
return val || `${match}`;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async function writeFile(file, contents, log = false) {
|
|
39
|
+
await mkdir(dirname(file), { recursive: true });
|
|
40
|
+
await writeFile$1(
|
|
41
|
+
file,
|
|
42
|
+
contents,
|
|
43
|
+
typeof contents === "string" ? "utf8" : void 0
|
|
44
|
+
);
|
|
45
|
+
if (log) {
|
|
46
|
+
consola.info("Generated", prettyPath(file));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async function isDirectory(path) {
|
|
50
|
+
try {
|
|
51
|
+
return (await stat(path)).isDirectory();
|
|
52
|
+
} catch {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function compressPublicAssets(nitro) {
|
|
58
|
+
const publicFiles = await glob("**", {
|
|
59
|
+
cwd: nitro.options.output.publicDir,
|
|
60
|
+
absolute: false,
|
|
61
|
+
dot: true,
|
|
62
|
+
ignore: ["**/*.gz", "**/*.br"]
|
|
63
|
+
});
|
|
64
|
+
await Promise.all(
|
|
65
|
+
publicFiles.map(async (fileName) => {
|
|
66
|
+
const filePath = resolve(nitro.options.output.publicDir, fileName);
|
|
67
|
+
if (existsSync(filePath + ".gz") || existsSync(filePath + ".br")) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const mimeType = mime.getType(fileName) || "text/plain";
|
|
71
|
+
const fileContents = await fsp.readFile(filePath);
|
|
72
|
+
if (fileContents.length < 1024 || fileName.endsWith(".map") || !isCompressibleMime(mimeType)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const { gzip, brotli } = nitro.options.compressPublicAssets || {};
|
|
76
|
+
const encodings = [
|
|
77
|
+
gzip !== false && "gzip",
|
|
78
|
+
brotli !== false && "br"
|
|
79
|
+
].filter(Boolean);
|
|
80
|
+
await Promise.all(
|
|
81
|
+
encodings.map(async (encoding) => {
|
|
82
|
+
const suffix = "." + (encoding === "gzip" ? "gz" : "br");
|
|
83
|
+
const compressedPath = filePath + suffix;
|
|
84
|
+
if (existsSync(compressedPath)) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const gzipOptions = { level: zlib.constants.Z_BEST_COMPRESSION };
|
|
88
|
+
const brotliOptions = {
|
|
89
|
+
[zlib.constants.BROTLI_PARAM_MODE]: isTextMime(mimeType) ? zlib.constants.BROTLI_MODE_TEXT : zlib.constants.BROTLI_MODE_GENERIC,
|
|
90
|
+
[zlib.constants.BROTLI_PARAM_QUALITY]: zlib.constants.BROTLI_MAX_QUALITY,
|
|
91
|
+
[zlib.constants.BROTLI_PARAM_SIZE_HINT]: fileContents.length
|
|
92
|
+
};
|
|
93
|
+
const compressedBuff = await new Promise(
|
|
94
|
+
(resolve2, reject) => {
|
|
95
|
+
const cb = (error, result) => error ? reject(error) : resolve2(result);
|
|
96
|
+
if (encoding === "gzip") {
|
|
97
|
+
zlib.gzip(fileContents, gzipOptions, cb);
|
|
98
|
+
} else {
|
|
99
|
+
zlib.brotliCompress(fileContents, brotliOptions, cb);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
await fsp.writeFile(compressedPath, compressedBuff);
|
|
104
|
+
})
|
|
105
|
+
);
|
|
106
|
+
})
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
function isTextMime(mimeType) {
|
|
110
|
+
return /text|javascript|json|xml/.test(mimeType);
|
|
111
|
+
}
|
|
112
|
+
const COMPRESSIBLE_MIMES_RE = /* @__PURE__ */ new Set([
|
|
113
|
+
"application/dash+xml",
|
|
114
|
+
"application/eot",
|
|
115
|
+
"application/font",
|
|
116
|
+
"application/font-sfnt",
|
|
117
|
+
"application/javascript",
|
|
118
|
+
"application/json",
|
|
119
|
+
"application/opentype",
|
|
120
|
+
"application/otf",
|
|
121
|
+
"application/pdf",
|
|
122
|
+
"application/pkcs7-mime",
|
|
123
|
+
"application/protobuf",
|
|
124
|
+
"application/rss+xml",
|
|
125
|
+
"application/truetype",
|
|
126
|
+
"application/ttf",
|
|
127
|
+
"application/vnd.apple.mpegurl",
|
|
128
|
+
"application/vnd.mapbox-vector-tile",
|
|
129
|
+
"application/vnd.ms-fontobject",
|
|
130
|
+
"application/wasm",
|
|
131
|
+
"application/xhtml+xml",
|
|
132
|
+
"application/xml",
|
|
133
|
+
"application/x-font-opentype",
|
|
134
|
+
"application/x-font-truetype",
|
|
135
|
+
"application/x-font-ttf",
|
|
136
|
+
"application/x-httpd-cgi",
|
|
137
|
+
"application/x-javascript",
|
|
138
|
+
"application/x-mpegurl",
|
|
139
|
+
"application/x-opentype",
|
|
140
|
+
"application/x-otf",
|
|
141
|
+
"application/x-perl",
|
|
142
|
+
"application/x-ttf",
|
|
143
|
+
"font/eot",
|
|
144
|
+
"font/opentype",
|
|
145
|
+
"font/otf",
|
|
146
|
+
"font/ttf",
|
|
147
|
+
"image/svg+xml",
|
|
148
|
+
"text/css",
|
|
149
|
+
"text/csv",
|
|
150
|
+
"text/html",
|
|
151
|
+
"text/javascript",
|
|
152
|
+
"text/js",
|
|
153
|
+
"text/plain",
|
|
154
|
+
"text/richtext",
|
|
155
|
+
"text/tab-separated-values",
|
|
156
|
+
"text/xml",
|
|
157
|
+
"text/x-component",
|
|
158
|
+
"text/x-java-source",
|
|
159
|
+
"text/x-script",
|
|
160
|
+
"vnd.apple.mpegurl"
|
|
161
|
+
]);
|
|
162
|
+
function isCompressibleMime(mimeType) {
|
|
163
|
+
return COMPRESSIBLE_MIMES_RE.has(mimeType);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const NEGATION_RE = /^(!?)(.*)$/;
|
|
167
|
+
const PARENT_DIR_GLOB_RE = /!?\.\.\//;
|
|
168
|
+
async function scanUnprefixedPublicAssets(nitro) {
|
|
169
|
+
const scannedPaths = [];
|
|
170
|
+
for (const asset of nitro.options.publicAssets) {
|
|
171
|
+
if (asset.baseURL && asset.baseURL !== "/" && !asset.fallthrough) {
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
if (!await isDirectory(asset.dir)) {
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
const includePatterns = getIncludePatterns(nitro, asset.dir);
|
|
178
|
+
const publicAssets = await glob(includePatterns, {
|
|
179
|
+
cwd: asset.dir,
|
|
180
|
+
absolute: false,
|
|
181
|
+
dot: true
|
|
182
|
+
});
|
|
183
|
+
scannedPaths.push(
|
|
184
|
+
...publicAssets.map((file) => join(asset.baseURL || "/", file))
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
return scannedPaths;
|
|
188
|
+
}
|
|
189
|
+
async function copyPublicAssets(nitro) {
|
|
190
|
+
if (nitro.options.noPublicDir) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
for (const asset of nitro.options.publicAssets) {
|
|
194
|
+
const srcDir = asset.dir;
|
|
195
|
+
const dstDir = join(nitro.options.output.publicDir, asset.baseURL);
|
|
196
|
+
if (await isDirectory(srcDir)) {
|
|
197
|
+
const includePatterns = getIncludePatterns(nitro, srcDir);
|
|
198
|
+
const publicAssets = await glob(includePatterns, {
|
|
199
|
+
cwd: srcDir,
|
|
200
|
+
absolute: false,
|
|
201
|
+
dot: true
|
|
202
|
+
});
|
|
203
|
+
await Promise.all(
|
|
204
|
+
publicAssets.map(async (file) => {
|
|
205
|
+
const src = join(srcDir, file);
|
|
206
|
+
const dst = join(dstDir, file);
|
|
207
|
+
if (!existsSync(dst)) {
|
|
208
|
+
await promises.cp(src, dst);
|
|
209
|
+
}
|
|
210
|
+
})
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (nitro.options.compressPublicAssets) {
|
|
215
|
+
await compressPublicAssets(nitro);
|
|
216
|
+
}
|
|
217
|
+
nitro.logger.success(
|
|
218
|
+
"Generated public " + prettyPath(nitro.options.output.publicDir)
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
function getIncludePatterns(nitro, srcDir) {
|
|
222
|
+
return [
|
|
223
|
+
"**",
|
|
224
|
+
...nitro.options.ignore.map((p) => {
|
|
225
|
+
const [_, negation, pattern] = p.match(NEGATION_RE) || [];
|
|
226
|
+
return (
|
|
227
|
+
// Convert ignore to include patterns
|
|
228
|
+
(negation ? "" : "!") + // Make non-glob patterns relative to publicAssetDir
|
|
229
|
+
(pattern.startsWith("*") ? pattern : relative(srcDir, resolve(nitro.options.srcDir, pattern)))
|
|
230
|
+
);
|
|
231
|
+
})
|
|
232
|
+
].filter((p) => !PARENT_DIR_GLOB_RE.test(p));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export { copyPublicAssets as a, compressPublicAssets as c, isDirectory as i, prettyPath as p, resolveNitroPath as r, scanUnprefixedPublicAssets as s, writeFile as w };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
async function build(nitro) {
|
|
2
|
+
switch (nitro.options.builder) {
|
|
3
|
+
case "rollup": {
|
|
4
|
+
const { rollupBuild } = await import('./rollup.mjs');
|
|
5
|
+
return rollupBuild(nitro);
|
|
6
|
+
}
|
|
7
|
+
case "rolldown": {
|
|
8
|
+
const { rolldownBuild } = await import('./rolldown.mjs').then(function (n) { return n.b; });
|
|
9
|
+
return rolldownBuild(nitro);
|
|
10
|
+
}
|
|
11
|
+
case "vite": {
|
|
12
|
+
const { viteBuild } = await import('./vite.mjs').then(function (n) { return n.d; });
|
|
13
|
+
return viteBuild(nitro);
|
|
14
|
+
}
|
|
15
|
+
default: {
|
|
16
|
+
throw new Error(`Unknown builder: ${nitro.options.builder}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { build as b };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { defineEnv } from 'unenv';
|
|
2
|
+
import { runtimeDir } from 'nitro/runtime/meta';
|
|
3
|
+
import { j as join, a as resolve } from '../_deps/pathe.mjs';
|
|
4
|
+
|
|
5
|
+
function baseBuildConfig(nitro) {
|
|
6
|
+
const buildServerDir = join(nitro.options.buildDir, "dist/server");
|
|
7
|
+
const presetsDir = resolve(runtimeDir, "../presets");
|
|
8
|
+
const extensions = [".ts", ".mjs", ".js", ".json", ".node", ".tsx", ".jsx"];
|
|
9
|
+
const isNodeless = nitro.options.node === false;
|
|
10
|
+
let NODE_ENV = nitro.options.dev ? "development" : "production";
|
|
11
|
+
if (nitro.options.preset === "nitro-prerender") {
|
|
12
|
+
NODE_ENV = "prerender";
|
|
13
|
+
}
|
|
14
|
+
const buildEnvVars = {
|
|
15
|
+
NODE_ENV,
|
|
16
|
+
prerender: nitro.options.preset === "nitro-prerender",
|
|
17
|
+
server: true,
|
|
18
|
+
client: false,
|
|
19
|
+
dev: String(nitro.options.dev),
|
|
20
|
+
DEBUG: nitro.options.dev
|
|
21
|
+
};
|
|
22
|
+
const staticFlags = {
|
|
23
|
+
dev: nitro.options.dev,
|
|
24
|
+
preset: nitro.options.preset,
|
|
25
|
+
prerender: nitro.options.preset === "nitro-prerender",
|
|
26
|
+
server: true,
|
|
27
|
+
client: false,
|
|
28
|
+
nitro: true,
|
|
29
|
+
baseURL: nitro.options.baseURL,
|
|
30
|
+
// @ts-expect-error
|
|
31
|
+
"versions.nitro": "",
|
|
32
|
+
"versions?.nitro": "",
|
|
33
|
+
// Internal
|
|
34
|
+
_asyncContext: nitro.options.experimental.asyncContext,
|
|
35
|
+
_websocket: nitro.options.experimental.websocket,
|
|
36
|
+
_tasks: nitro.options.experimental.tasks
|
|
37
|
+
};
|
|
38
|
+
const replaceDelimiters = [
|
|
39
|
+
String.raw`\b`,
|
|
40
|
+
String.raw`(?![\w.$])`
|
|
41
|
+
];
|
|
42
|
+
const replacements = {
|
|
43
|
+
"typeof window": '"undefined"',
|
|
44
|
+
_import_meta_url_: "import.meta.url",
|
|
45
|
+
"globalThis.process.": "process.",
|
|
46
|
+
"process.env.RUNTIME_CONFIG": () => JSON.stringify(nitro.options.runtimeConfig, null, 2),
|
|
47
|
+
...Object.fromEntries(
|
|
48
|
+
Object.entries(buildEnvVars).map(([key, val]) => [
|
|
49
|
+
`process.env.${key}`,
|
|
50
|
+
JSON.stringify(val)
|
|
51
|
+
])
|
|
52
|
+
),
|
|
53
|
+
...Object.fromEntries(
|
|
54
|
+
Object.entries(buildEnvVars).map(([key, val]) => [
|
|
55
|
+
`import.meta.env.${key}`,
|
|
56
|
+
JSON.stringify(val)
|
|
57
|
+
])
|
|
58
|
+
),
|
|
59
|
+
...Object.fromEntries(
|
|
60
|
+
Object.entries(staticFlags).map(([key, val]) => [
|
|
61
|
+
`process.${key}`,
|
|
62
|
+
JSON.stringify(val)
|
|
63
|
+
])
|
|
64
|
+
),
|
|
65
|
+
...Object.fromEntries(
|
|
66
|
+
Object.entries(staticFlags).map(([key, val]) => [
|
|
67
|
+
`import.meta.${key}`,
|
|
68
|
+
JSON.stringify(val)
|
|
69
|
+
])
|
|
70
|
+
),
|
|
71
|
+
...nitro.options.replace
|
|
72
|
+
};
|
|
73
|
+
const { env } = defineEnv({
|
|
74
|
+
nodeCompat: isNodeless,
|
|
75
|
+
npmShims: true,
|
|
76
|
+
resolve: true,
|
|
77
|
+
presets: nitro.options.unenv,
|
|
78
|
+
overrides: {
|
|
79
|
+
alias: nitro.options.alias
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
const aliases = resolveAliases({
|
|
83
|
+
"#internal/nitro": runtimeDir,
|
|
84
|
+
"nitro/runtime": runtimeDir,
|
|
85
|
+
"nitropack/runtime": runtimeDir,
|
|
86
|
+
// Backwards compatibility
|
|
87
|
+
...env.alias
|
|
88
|
+
});
|
|
89
|
+
return {
|
|
90
|
+
buildServerDir,
|
|
91
|
+
presetsDir,
|
|
92
|
+
extensions,
|
|
93
|
+
isNodeless,
|
|
94
|
+
buildEnvVars,
|
|
95
|
+
staticFlags,
|
|
96
|
+
replaceDelimiters,
|
|
97
|
+
replacements,
|
|
98
|
+
env,
|
|
99
|
+
aliases
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function resolveAliases(_aliases) {
|
|
103
|
+
const aliases = Object.fromEntries(
|
|
104
|
+
Object.entries(_aliases).sort(
|
|
105
|
+
([a], [b]) => b.split("/").length - a.split("/").length || b.length - a.length
|
|
106
|
+
)
|
|
107
|
+
);
|
|
108
|
+
for (const key in aliases) {
|
|
109
|
+
for (const alias in aliases) {
|
|
110
|
+
if (!["~", "@", "#"].includes(alias[0])) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (alias === "@" && !aliases[key].startsWith("@/")) {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if (aliases[key].startsWith(alias)) {
|
|
117
|
+
aliases[key] = aliases[alias] + aliases[key].slice(alias.length);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return aliases;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export { baseBuildConfig as b };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { version } from 'nitro/meta';
|
|
2
|
+
import { p as presetsWithConfig } from '../_presets/_types.mjs';
|
|
3
|
+
import { w as writeFile } from './assets.mjs';
|
|
4
|
+
import { mkdir, unlink, symlink } from 'node:fs/promises';
|
|
5
|
+
import { dirname } from 'node:path';
|
|
6
|
+
import { a as resolve } from '../_deps/pathe.mjs';
|
|
7
|
+
|
|
8
|
+
async function writeBuildInfo(nitro) {
|
|
9
|
+
const buildInfoPath = resolve(nitro.options.output.dir, "nitro.json");
|
|
10
|
+
const buildInfo = {
|
|
11
|
+
date: (/* @__PURE__ */ new Date()).toJSON(),
|
|
12
|
+
preset: nitro.options.preset,
|
|
13
|
+
framework: nitro.options.framework,
|
|
14
|
+
versions: {
|
|
15
|
+
nitro: version
|
|
16
|
+
},
|
|
17
|
+
commands: {
|
|
18
|
+
preview: nitro.options.commands.preview,
|
|
19
|
+
deploy: nitro.options.commands.deploy
|
|
20
|
+
},
|
|
21
|
+
config: {
|
|
22
|
+
...Object.fromEntries(
|
|
23
|
+
presetsWithConfig.map((key) => [key, nitro.options[key]])
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
await writeFile(buildInfoPath, JSON.stringify(buildInfo, null, 2), true);
|
|
28
|
+
const lastBuild = resolve(
|
|
29
|
+
nitro.options.rootDir,
|
|
30
|
+
"node_modules/.nitro/last-build"
|
|
31
|
+
);
|
|
32
|
+
await mkdir(dirname(lastBuild), { recursive: true });
|
|
33
|
+
await unlink(lastBuild).catch(() => {
|
|
34
|
+
});
|
|
35
|
+
await symlink(nitro.options.output.dir, lastBuild).catch(console.warn);
|
|
36
|
+
return buildInfo;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { writeBuildInfo as w };
|