astro 0.25.2 → 0.26.0
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/@types/astro.js +0 -0
- package/dist/@types/serialize-javascript.d.js +0 -0
- package/dist/@types/shorthash.d.js +0 -0
- package/dist/adapter-ssg/index.js +0 -0
- package/dist/cli/check.js +4 -4
- package/dist/cli/index.js +21 -32
- package/dist/core/add/babel.js +0 -0
- package/dist/core/add/consts.js +0 -0
- package/dist/core/add/imports.js +0 -0
- package/dist/core/add/index.js +7 -14
- package/dist/core/add/wrapper.js +0 -0
- package/dist/core/app/common.js +0 -0
- package/dist/core/app/index.js +13 -10
- package/dist/core/app/node.js +0 -0
- package/dist/core/app/types.js +0 -0
- package/dist/core/build/add-rollup-input.js +0 -0
- package/dist/core/build/common.js +4 -5
- package/dist/core/build/generate.js +65 -72
- package/dist/core/build/index.js +59 -74
- package/dist/core/build/internal.js +4 -0
- package/dist/core/build/page-data.js +10 -9
- package/dist/core/build/static-build.js +46 -28
- package/dist/core/build/types.d.js +0 -0
- package/dist/core/build/util.js +0 -0
- package/dist/core/build/vite-plugin-hoisted-scripts.js +1 -1
- package/dist/core/build/vite-plugin-internals.js +0 -0
- package/dist/core/build/vite-plugin-pages.js +1 -0
- package/dist/core/build/vite-plugin-ssr.js +4 -2
- package/dist/core/config.js +87 -79
- package/dist/core/create-vite.js +12 -7
- package/dist/core/dev/index.js +8 -7
- package/dist/core/endpoint/dev/index.js +5 -10
- package/dist/core/endpoint/index.js +1 -3
- package/dist/core/errors.js +45 -0
- package/dist/core/logger/console.js +43 -0
- package/dist/core/logger/core.js +103 -0
- package/dist/core/logger/node.js +94 -0
- package/dist/core/messages.js +50 -24
- package/dist/core/path.js +0 -0
- package/dist/core/polyfill.js +0 -0
- package/dist/core/preview/index.js +8 -8
- package/dist/core/preview/util.js +3 -6
- package/dist/core/render/core.js +5 -6
- package/dist/core/render/dev/css.js +5 -6
- package/dist/core/render/dev/hmr.js +0 -0
- package/dist/core/render/dev/html.js +0 -0
- package/dist/core/render/dev/index.js +23 -36
- package/dist/core/render/paginate.js +0 -0
- package/dist/core/render/pretty-feed.js +103 -0
- package/dist/core/render/result.js +33 -15
- package/dist/core/render/route-cache.js +2 -2
- package/dist/core/render/rss.js +5 -4
- package/dist/core/render/script.js +0 -0
- package/dist/core/render/ssr-element.js +1 -1
- package/dist/core/render/util.js +26 -0
- package/dist/core/request.js +27 -0
- package/dist/core/routing/index.js +0 -0
- package/dist/core/routing/manifest/create.js +8 -6
- package/dist/core/routing/manifest/serialization.js +0 -0
- package/dist/core/routing/match.js +0 -0
- package/dist/core/routing/params.js +0 -0
- package/dist/core/routing/validation.js +1 -1
- package/dist/core/util.js +57 -125
- package/dist/integrations/index.js +9 -1
- package/dist/runtime/client/hmr.js +0 -0
- package/dist/runtime/client/idle.js +0 -0
- package/dist/runtime/client/load.js +0 -0
- package/dist/runtime/client/media.js +0 -0
- package/dist/runtime/client/only.js +0 -0
- package/dist/runtime/client/visible.js +0 -0
- package/dist/runtime/server/escape.js +0 -0
- package/dist/runtime/server/hydration.js +0 -0
- package/dist/runtime/server/index.js +42 -36
- package/dist/runtime/server/metadata.js +0 -0
- package/dist/runtime/server/util.js +0 -0
- package/dist/template/4xx.js +1 -1
- package/dist/template/5xx.js +0 -0
- package/dist/template/css.js +0 -0
- package/dist/types/@types/astro.d.ts +291 -233
- package/dist/types/cli/index.d.ts +1 -1
- package/dist/types/core/add/index.d.ts +1 -1
- package/dist/types/core/build/common.d.ts +0 -1
- package/dist/types/core/build/generate.d.ts +1 -1
- package/dist/types/core/build/index.d.ts +1 -1
- package/dist/types/core/build/internal.d.ts +1 -0
- package/dist/types/core/build/page-data.d.ts +1 -1
- package/dist/types/core/build/vite-plugin-pages.d.ts +1 -0
- package/dist/types/core/config.d.ts +125 -116
- package/dist/types/core/create-vite.d.ts +1 -1
- package/dist/types/core/dev/index.d.ts +1 -1
- package/dist/types/core/endpoint/index.d.ts +1 -1
- package/dist/types/core/errors.d.ts +23 -0
- package/dist/types/core/logger/console.d.ts +4 -0
- package/dist/types/core/{logger.d.ts → logger/core.d.ts} +7 -22
- package/dist/types/core/logger/node.d.ts +34 -0
- package/dist/types/core/messages.d.ts +4 -2
- package/dist/types/core/preview/index.d.ts +1 -1
- package/dist/types/core/preview/util.d.ts +1 -2
- package/dist/types/core/render/core.d.ts +2 -3
- package/dist/types/core/render/dev/css.d.ts +0 -2
- package/dist/types/core/render/dev/index.d.ts +4 -6
- package/dist/types/core/render/pretty-feed.d.ts +2 -0
- package/dist/types/core/render/result.d.ts +2 -3
- package/dist/types/core/render/route-cache.d.ts +1 -1
- package/dist/types/core/render/util.d.ts +6 -0
- package/dist/types/core/request.d.ts +14 -0
- package/dist/types/core/routing/manifest/create.d.ts +1 -1
- package/dist/types/core/routing/validation.d.ts +1 -1
- package/dist/types/core/util.d.ts +11 -7
- package/dist/types/integrations/index.d.ts +6 -0
- package/dist/types/runtime/server/index.d.ts +1 -2
- package/dist/types/vite-plugin-astro/hmr.d.ts +1 -1
- package/dist/types/vite-plugin-astro/index.d.ts +1 -1
- package/dist/types/vite-plugin-astro-server/index.d.ts +1 -1
- package/dist/types/vite-plugin-build-css/index.d.ts +2 -1
- package/dist/types/vite-plugin-build-html/extract-assets.d.ts +1 -1
- package/dist/types/vite-plugin-build-html/index.d.ts +3 -3
- package/dist/types/vite-plugin-config-alias/index.d.ts +1 -1
- package/dist/types/vite-plugin-jsx/index.d.ts +1 -1
- package/dist/vite-plugin-astro/compile.js +12 -14
- package/dist/vite-plugin-astro/hmr.js +2 -2
- package/dist/vite-plugin-astro/index.js +21 -8
- package/dist/vite-plugin-astro/query.js +0 -0
- package/dist/vite-plugin-astro/styles.js +1 -1
- package/dist/vite-plugin-astro-postprocess/index.js +31 -34
- package/dist/vite-plugin-astro-server/index.js +50 -22
- package/dist/vite-plugin-build-css/index.js +47 -4
- package/dist/vite-plugin-build-css/resolve.js +0 -0
- package/dist/vite-plugin-build-html/add-rollup-input.js +0 -0
- package/dist/vite-plugin-build-html/extract-assets.js +0 -0
- package/dist/vite-plugin-build-html/index.js +22 -23
- package/dist/vite-plugin-build-html/util.js +0 -0
- package/dist/vite-plugin-config-alias/index.js +1 -1
- package/dist/vite-plugin-env/index.js +1 -1
- package/dist/vite-plugin-integrations-container/index.js +0 -0
- package/dist/vite-plugin-jsx/index.js +1 -1
- package/dist/vite-plugin-markdown/index.js +89 -18
- package/dist/vite-plugin-scripts/index.js +0 -0
- package/env.d.ts +1 -1
- package/package.json +13 -9
- package/dist/core/build/scan-based-build.js +0 -61
- package/dist/core/dev/util.js +0 -44
- package/dist/core/logger.js +0 -174
- package/dist/core/render/dev/error.js +0 -34
- package/dist/core/render/request.js +0 -23
- package/dist/core/render/sitemap.js +0 -18
- package/dist/types/core/build/scan-based-build.d.ts +0 -18
- package/dist/types/core/dev/util.d.ts +0 -9
- package/dist/types/core/render/dev/error.d.ts +0 -7
- package/dist/types/core/render/request.d.ts +0 -15
- package/dist/types/core/render/sitemap.d.ts +0 -2
package/dist/core/messages.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import stripAnsi from "strip-ansi";
|
|
2
1
|
import { bold, dim, red, green, underline, yellow, bgYellow, cyan, bgGreen, black, bgRed, bgWhite } from "kleur/colors";
|
|
3
|
-
import { pad, emoji, getLocalAddress, getNetworkLogging } from "./dev/util.js";
|
|
4
2
|
import os from "os";
|
|
3
|
+
import { collectErrorMetadata, cleanErrorStack } from "./errors.js";
|
|
4
|
+
import { emoji, getLocalAddress, padMultilineString } from "./util.js";
|
|
5
5
|
const PREFIX_PADDING = 6;
|
|
6
6
|
function req({ url, statusCode, reqTime }) {
|
|
7
7
|
let color = dim;
|
|
@@ -13,13 +13,13 @@ function req({ url, statusCode, reqTime }) {
|
|
|
13
13
|
color = dim;
|
|
14
14
|
else if (statusCode >= 200)
|
|
15
15
|
color = green;
|
|
16
|
-
return `${bold(color(
|
|
16
|
+
return `${bold(color(`${statusCode}`.padStart(PREFIX_PADDING)))} ${url.padStart(40)} ${reqTime ? dim(Math.round(reqTime) + "ms") : ""}`.trim();
|
|
17
17
|
}
|
|
18
18
|
function reload({ file }) {
|
|
19
|
-
return `${green(
|
|
19
|
+
return `${green("reload".padStart(PREFIX_PADDING))} ${file}`;
|
|
20
20
|
}
|
|
21
21
|
function hmr({ file }) {
|
|
22
|
-
return `${green(
|
|
22
|
+
return `${green("update".padStart(PREFIX_PADDING))} ${file}`;
|
|
23
23
|
}
|
|
24
24
|
function devStart({
|
|
25
25
|
startupTime,
|
|
@@ -28,13 +28,13 @@ function devStart({
|
|
|
28
28
|
https,
|
|
29
29
|
site
|
|
30
30
|
}) {
|
|
31
|
-
const version = "0.
|
|
31
|
+
const version = "0.26.0";
|
|
32
32
|
const rootPath = site ? site.pathname : "/";
|
|
33
33
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
34
34
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
35
35
|
const { address: networkAddress, port } = devServerAddressInfo;
|
|
36
|
-
const localAddress = getLocalAddress(networkAddress, config);
|
|
37
|
-
const networkLogging = getNetworkLogging(config);
|
|
36
|
+
const localAddress = getLocalAddress(networkAddress, config.server.host);
|
|
37
|
+
const networkLogging = getNetworkLogging(config.server.host);
|
|
38
38
|
const toDisplayUrl = (hostname) => `${https ? "https" : "http"}://${hostname}:${port}${rootPath}`;
|
|
39
39
|
let addresses = [];
|
|
40
40
|
if (networkLogging === "none") {
|
|
@@ -66,35 +66,59 @@ function success(message, tip) {
|
|
|
66
66
|
const headline = green(message);
|
|
67
67
|
const footer = tip ? `
|
|
68
68
|
\u25B6 ${tip}` : void 0;
|
|
69
|
-
return ["", badge
|
|
69
|
+
return ["", `${badge} ${headline}`, footer].filter((v) => v !== void 0).map((msg) => ` ${msg}`).join("\n");
|
|
70
70
|
}
|
|
71
71
|
function failure(message, tip) {
|
|
72
72
|
const badge = bgRed(black(` error `));
|
|
73
73
|
const headline = red(message);
|
|
74
74
|
const footer = tip ? `
|
|
75
75
|
\u25B6 ${tip}` : void 0;
|
|
76
|
-
return ["", badge
|
|
76
|
+
return ["", `${badge} ${headline}`, footer].filter((v) => v !== void 0).map((msg) => ` ${msg}`).join("\n");
|
|
77
77
|
}
|
|
78
78
|
function cancelled(message, tip) {
|
|
79
79
|
const badge = bgYellow(black(` cancelled `));
|
|
80
80
|
const headline = yellow(message);
|
|
81
81
|
const footer = tip ? `
|
|
82
82
|
\u25B6 ${tip}` : void 0;
|
|
83
|
-
return ["", badge
|
|
83
|
+
return ["", `${badge} ${headline}`, footer].filter((v) => v !== void 0).map((msg) => ` ${msg}`).join("\n");
|
|
84
84
|
}
|
|
85
85
|
function portInUse({ port }) {
|
|
86
86
|
return `Port ${port} in use. Trying a new one\u2026`;
|
|
87
87
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
88
|
+
const LOCAL_IP_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1"]);
|
|
89
|
+
function getNetworkLogging(host) {
|
|
90
|
+
if (host === false) {
|
|
91
|
+
return "host-to-expose";
|
|
92
|
+
} else if (typeof host === "string" && LOCAL_IP_HOSTS.has(host)) {
|
|
93
|
+
return "none";
|
|
94
|
+
} else {
|
|
95
|
+
return "visible";
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function formatConfigErrorMessage(err) {
|
|
99
|
+
const errorList = err.issues.map((issue) => ` ! ${bold(issue.path.join("."))} ${red(issue.message + ".")}`);
|
|
100
|
+
return `${red("[config]")} Astro found issue(s) with your configuration:
|
|
101
|
+
${errorList.join("\n")}`;
|
|
102
|
+
}
|
|
103
|
+
function formatErrorMessage(_err, args = []) {
|
|
104
|
+
const err = collectErrorMetadata(_err);
|
|
105
|
+
args.push(`${bgRed(black(` error `))}${red(bold(padMultilineString(err.message)))}`);
|
|
106
|
+
if (err.id) {
|
|
107
|
+
args.push(` ${bold("File:")}`);
|
|
108
|
+
args.push(red(` ${err.id}`));
|
|
109
|
+
}
|
|
110
|
+
if (err.frame) {
|
|
111
|
+
args.push(` ${bold("Code:")}`);
|
|
112
|
+
args.push(red(padMultilineString(err.frame, 4)));
|
|
113
|
+
}
|
|
114
|
+
if (args.length === 1 && err.stack) {
|
|
115
|
+
args.push(dim(cleanErrorStack(err.stack)));
|
|
116
|
+
} else if (err.stack) {
|
|
117
|
+
args.push(` ${bold("Stacktrace:")}`);
|
|
118
|
+
args.push(dim(cleanErrorStack(err.stack)));
|
|
119
|
+
args.push(``);
|
|
120
|
+
}
|
|
121
|
+
return args.join("\n");
|
|
98
122
|
}
|
|
99
123
|
function printHelp({
|
|
100
124
|
commandName,
|
|
@@ -112,7 +136,7 @@ function printHelp({
|
|
|
112
136
|
});
|
|
113
137
|
let raw = "";
|
|
114
138
|
for (const row of rows) {
|
|
115
|
-
raw += `${opts.prefix}${bold(
|
|
139
|
+
raw += `${opts.prefix}${bold(`${row[0]}`.padStart(opts.padding - opts.prefix.length))}`;
|
|
116
140
|
if (split)
|
|
117
141
|
raw += "\n ";
|
|
118
142
|
raw += dim(row[1]) + "\n";
|
|
@@ -121,7 +145,7 @@ function printHelp({
|
|
|
121
145
|
};
|
|
122
146
|
let message = [];
|
|
123
147
|
if (headline) {
|
|
124
|
-
message.push(linebreak(), ` ${bgGreen(black(` ${commandName} `))} ${green(`v${"0.
|
|
148
|
+
message.push(linebreak(), ` ${bgGreen(black(` ${commandName} `))} ${green(`v${"0.26.0"}`)} ${headline}`);
|
|
125
149
|
}
|
|
126
150
|
if (usage) {
|
|
127
151
|
message.push(linebreak(), ` ${green(commandName)} ${bold(usage)}`);
|
|
@@ -137,8 +161,10 @@ function printHelp({
|
|
|
137
161
|
export {
|
|
138
162
|
cancelled,
|
|
139
163
|
devStart,
|
|
140
|
-
err,
|
|
141
164
|
failure,
|
|
165
|
+
formatConfigErrorMessage,
|
|
166
|
+
formatErrorMessage,
|
|
167
|
+
getNetworkLogging,
|
|
142
168
|
hmr,
|
|
143
169
|
portInUse,
|
|
144
170
|
prerelease,
|
package/dist/core/path.js
CHANGED
|
File without changes
|
package/dist/core/polyfill.js
CHANGED
|
File without changes
|
|
@@ -3,16 +3,16 @@ import sirv from "sirv";
|
|
|
3
3
|
import { performance } from "perf_hooks";
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
5
|
import * as msg from "../messages.js";
|
|
6
|
-
import { error, info } from "../logger.js";
|
|
6
|
+
import { error, info } from "../logger/core.js";
|
|
7
7
|
import { subpathNotUsedTemplate, notFoundTemplate } from "../../template/4xx.js";
|
|
8
8
|
import { getResolvedHostForHttpServer } from "./util.js";
|
|
9
9
|
const HAS_FILE_EXTENSION_REGEXP = /^.*\.[^\\]+$/;
|
|
10
10
|
async function preview(config, { logging }) {
|
|
11
11
|
const startServerTime = performance.now();
|
|
12
12
|
const defaultOrigin = "http://localhost";
|
|
13
|
-
const trailingSlash = config.
|
|
14
|
-
let baseURL = new URL(config.
|
|
15
|
-
const staticFileServer = sirv(fileURLToPath(config.
|
|
13
|
+
const trailingSlash = config.trailingSlash;
|
|
14
|
+
let baseURL = new URL(config.base, new URL(config.site || "/", defaultOrigin));
|
|
15
|
+
const staticFileServer = sirv(fileURLToPath(config.outDir), {
|
|
16
16
|
dev: true,
|
|
17
17
|
etag: true,
|
|
18
18
|
maxAge: 0
|
|
@@ -34,10 +34,10 @@ async function preview(config, { logging }) {
|
|
|
34
34
|
}
|
|
35
35
|
switch (true) {
|
|
36
36
|
case (hasTrailingSlash && trailingSlash == "never" && !isRoot):
|
|
37
|
-
sendError('Not Found (
|
|
37
|
+
sendError('Not Found (trailingSlash is set to "never")');
|
|
38
38
|
return;
|
|
39
39
|
case (!hasTrailingSlash && trailingSlash == "always" && !isRoot && !HAS_FILE_EXTENSION_REGEXP.test(pathname)):
|
|
40
|
-
sendError('Not Found (
|
|
40
|
+
sendError('Not Found (trailingSlash is set to "always")');
|
|
41
41
|
return;
|
|
42
42
|
default: {
|
|
43
43
|
req.url = "/" + ((_a = req.url) == null ? void 0 : _a.replace(baseURL.pathname, ""));
|
|
@@ -46,8 +46,8 @@ async function preview(config, { logging }) {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
|
-
let { port } = config.
|
|
50
|
-
const host = getResolvedHostForHttpServer(config);
|
|
49
|
+
let { port } = config.server;
|
|
50
|
+
const host = getResolvedHostForHttpServer(config.server.host);
|
|
51
51
|
let httpServer;
|
|
52
52
|
function startServer(timerStart) {
|
|
53
53
|
let showedPortTakenMsg = false;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
function getResolvedHostForHttpServer(
|
|
2
|
-
|
|
3
|
-
if (host === false && hostname === "localhost") {
|
|
1
|
+
function getResolvedHostForHttpServer(host) {
|
|
2
|
+
if (host === false) {
|
|
4
3
|
return "127.0.0.1";
|
|
5
4
|
} else if (host === true) {
|
|
6
5
|
return void 0;
|
|
7
|
-
} else if (typeof host === "string") {
|
|
8
|
-
return host;
|
|
9
6
|
} else {
|
|
10
|
-
return
|
|
7
|
+
return host;
|
|
11
8
|
}
|
|
12
9
|
}
|
|
13
10
|
export {
|
package/dist/core/render/core.js
CHANGED
|
@@ -15,7 +15,7 @@ var __spreadValues = (a, b) => {
|
|
|
15
15
|
return a;
|
|
16
16
|
};
|
|
17
17
|
import { renderHead, renderPage } from "../../runtime/server/index.js";
|
|
18
|
-
import { getParams } from "../routing/
|
|
18
|
+
import { getParams } from "../routing/params.js";
|
|
19
19
|
import { createResult } from "./result.js";
|
|
20
20
|
import { findPathItemByKey, callGetStaticPaths } from "./route-cache.js";
|
|
21
21
|
var GetParamsAndPropsError = /* @__PURE__ */ ((GetParamsAndPropsError2) => {
|
|
@@ -49,7 +49,7 @@ async function getParamsAndProps(opts) {
|
|
|
49
49
|
return [params, pageProps];
|
|
50
50
|
}
|
|
51
51
|
async function render(opts) {
|
|
52
|
-
const {
|
|
52
|
+
const { legacyBuild, links, logging, origin, markdownRender, mod, pathname, scripts, renderers, request, resolve, route, routeCache, site, ssr } = opts;
|
|
53
53
|
const paramsAndPropsRes = await getParamsAndProps({
|
|
54
54
|
logging,
|
|
55
55
|
mod,
|
|
@@ -77,11 +77,10 @@ async function render(opts) {
|
|
|
77
77
|
pathname,
|
|
78
78
|
resolve,
|
|
79
79
|
renderers,
|
|
80
|
+
request,
|
|
80
81
|
site,
|
|
81
82
|
scripts,
|
|
82
|
-
ssr
|
|
83
|
-
method,
|
|
84
|
-
headers
|
|
83
|
+
ssr
|
|
85
84
|
});
|
|
86
85
|
let page = await renderPage(result, Component, pageProps, null);
|
|
87
86
|
if (page.type === "response") {
|
|
@@ -92,7 +91,7 @@ async function render(opts) {
|
|
|
92
91
|
html = await renderHead(result) + html;
|
|
93
92
|
}
|
|
94
93
|
html = html.replace("<!--astro:head:injected-->", "");
|
|
95
|
-
if (
|
|
94
|
+
if (!/<!doctype html/i.test(html)) {
|
|
96
95
|
html = "<!DOCTYPE html>\n" + html;
|
|
97
96
|
}
|
|
98
97
|
return {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { unwrapId, viteID } from "../../util.js";
|
|
3
|
-
|
|
4
|
-
const cssRe = new RegExp(`\\.(${Array.from(STYLE_EXTENSIONS).map((s) => s.slice(1)).join("|")})($|\\?)`);
|
|
5
|
-
const isCSSRequest = (request) => cssRe.test(request);
|
|
3
|
+
import { STYLE_EXTENSIONS } from "../util.js";
|
|
6
4
|
function getStylesForURL(filePath, viteServer) {
|
|
7
5
|
const importedCssUrls = /* @__PURE__ */ new Set();
|
|
8
6
|
function crawlCSS(_id, isFile, scanned = /* @__PURE__ */ new Set()) {
|
|
@@ -10,6 +8,9 @@ function getStylesForURL(filePath, viteServer) {
|
|
|
10
8
|
const importedModules = /* @__PURE__ */ new Set();
|
|
11
9
|
const moduleEntriesForId = isFile ? viteServer.moduleGraph.getModulesByFile(id) ?? /* @__PURE__ */ new Set() : /* @__PURE__ */ new Set([viteServer.moduleGraph.getModuleById(id)]);
|
|
12
10
|
for (const entry of moduleEntriesForId) {
|
|
11
|
+
if (!entry) {
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
13
14
|
if (id === entry.id) {
|
|
14
15
|
scanned.add(id);
|
|
15
16
|
for (const importedModule of entry.importedModules) {
|
|
@@ -32,7 +33,5 @@ function getStylesForURL(filePath, viteServer) {
|
|
|
32
33
|
return importedCssUrls;
|
|
33
34
|
}
|
|
34
35
|
export {
|
|
35
|
-
|
|
36
|
-
getStylesForURL,
|
|
37
|
-
isCSSRequest
|
|
36
|
+
getStylesForURL
|
|
38
37
|
};
|
|
File without changes
|
|
File without changes
|
|
@@ -17,14 +17,15 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import astroRemark from "@astrojs/markdown-remark";
|
|
20
21
|
import { fileURLToPath } from "url";
|
|
21
22
|
import { render as coreRender } from "../core.js";
|
|
22
23
|
import { prependForwardSlash } from "../../../core/path.js";
|
|
23
24
|
import { createModuleScriptElementWithSrcSet } from "../ssr-element.js";
|
|
24
25
|
import { getStylesForURL } from "./css.js";
|
|
25
|
-
import { errorHandler } from "./error.js";
|
|
26
26
|
import { getHmrScript } from "./hmr.js";
|
|
27
27
|
import { injectTags } from "./html.js";
|
|
28
|
+
import { isBuildingToSSR } from "../../util.js";
|
|
28
29
|
const svelteStylesRE = /svelte\?svelte&type=style/;
|
|
29
30
|
async function loadRenderer(viteServer, renderer) {
|
|
30
31
|
var _a;
|
|
@@ -41,10 +42,10 @@ async function preload({ astroConfig, filePath, viteServer }) {
|
|
|
41
42
|
return [renderers, mod];
|
|
42
43
|
}
|
|
43
44
|
async function render(renderers, mod, ssrOpts) {
|
|
44
|
-
const { astroConfig, filePath, logging, mode, origin, pathname,
|
|
45
|
-
const
|
|
46
|
-
const scripts = createModuleScriptElementWithSrcSet(!
|
|
47
|
-
if (mod.hasOwnProperty("$$metadata") && mode === "development" && !
|
|
45
|
+
const { astroConfig, filePath, logging, mode, origin, pathname, request, route, routeCache, viteServer } = ssrOpts;
|
|
46
|
+
const isLegacyBuild = false;
|
|
47
|
+
const scripts = createModuleScriptElementWithSrcSet(!isLegacyBuild && mod.hasOwnProperty("$$metadata") ? Array.from(mod.$$metadata.hoistedScriptPaths()) : []);
|
|
48
|
+
if (mod.hasOwnProperty("$$metadata") && mode === "development" && !isLegacyBuild) {
|
|
48
49
|
scripts.add({
|
|
49
50
|
props: { type: "module", src: "/@vite/client" },
|
|
50
51
|
children: ""
|
|
@@ -63,7 +64,7 @@ async function render(renderers, mod, ssrOpts) {
|
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
let links = /* @__PURE__ */ new Set();
|
|
66
|
-
if (!
|
|
67
|
+
if (!isLegacyBuild) {
|
|
67
68
|
[...getStylesForURL(filePath, viteServer)].forEach((href) => {
|
|
68
69
|
if (mode === "development" && svelteStylesRE.test(href)) {
|
|
69
70
|
scripts.add({
|
|
@@ -83,41 +84,36 @@ async function render(renderers, mod, ssrOpts) {
|
|
|
83
84
|
});
|
|
84
85
|
}
|
|
85
86
|
let content = await coreRender({
|
|
86
|
-
legacyBuild:
|
|
87
|
+
legacyBuild: isLegacyBuild,
|
|
87
88
|
links,
|
|
88
89
|
logging,
|
|
89
|
-
markdownRender: astroConfig.
|
|
90
|
+
markdownRender: [astroRemark, astroConfig.markdown],
|
|
90
91
|
mod,
|
|
91
92
|
origin,
|
|
92
93
|
pathname,
|
|
93
94
|
scripts,
|
|
94
95
|
async resolve(s) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return "/@id" + prependForwardSlash(resolvedUrl);
|
|
102
|
-
}
|
|
103
|
-
return "/@fs" + prependForwardSlash(resolvedPath);
|
|
104
|
-
} else {
|
|
105
|
-
return s;
|
|
96
|
+
const [resolvedUrl, resolvedPath] = await viteServer.moduleGraph.resolveUrl(s);
|
|
97
|
+
if (resolvedPath.includes("node_modules/.vite")) {
|
|
98
|
+
return resolvedPath.replace(/.*?node_modules\/\.vite/, "/node_modules/.vite");
|
|
99
|
+
}
|
|
100
|
+
if (!resolvedUrl.startsWith(".") && !resolvedUrl.startsWith("/")) {
|
|
101
|
+
return "/@id" + prependForwardSlash(resolvedUrl);
|
|
106
102
|
}
|
|
103
|
+
return "/@fs" + prependForwardSlash(resolvedPath);
|
|
107
104
|
},
|
|
108
105
|
renderers,
|
|
106
|
+
request,
|
|
109
107
|
route,
|
|
110
108
|
routeCache,
|
|
111
|
-
site: astroConfig.
|
|
112
|
-
ssr: astroConfig
|
|
113
|
-
method,
|
|
114
|
-
headers
|
|
109
|
+
site: astroConfig.site ? new URL(astroConfig.base, astroConfig.site).toString() : void 0,
|
|
110
|
+
ssr: isBuildingToSSR(astroConfig)
|
|
115
111
|
});
|
|
116
112
|
if ((route == null ? void 0 : route.type) === "endpoint" || content.type === "response") {
|
|
117
113
|
return content;
|
|
118
114
|
}
|
|
119
115
|
const tags = [];
|
|
120
|
-
if (mode === "development" &&
|
|
116
|
+
if (mode === "development" && isLegacyBuild) {
|
|
121
117
|
tags.push({
|
|
122
118
|
tag: "script",
|
|
123
119
|
attrs: { type: "module" },
|
|
@@ -125,7 +121,7 @@ async function render(renderers, mod, ssrOpts) {
|
|
|
125
121
|
injectTo: "head"
|
|
126
122
|
});
|
|
127
123
|
}
|
|
128
|
-
if (
|
|
124
|
+
if (isLegacyBuild) {
|
|
129
125
|
[...getStylesForURL(filePath, viteServer)].forEach((href) => {
|
|
130
126
|
if (mode === "development" && svelteStylesRE.test(href)) {
|
|
131
127
|
tags.push({
|
|
@@ -147,10 +143,6 @@ async function render(renderers, mod, ssrOpts) {
|
|
|
147
143
|
});
|
|
148
144
|
}
|
|
149
145
|
let html = injectTags(content.html, tags);
|
|
150
|
-
if (mode === "development" && astroConfig.buildOptions.legacyBuild) {
|
|
151
|
-
const relativeURL = filePath.href.replace(astroConfig.projectRoot.href, "/");
|
|
152
|
-
html = await viteServer.transformIndexHtml(relativeURL, html, pathname);
|
|
153
|
-
}
|
|
154
146
|
if (!/<!doctype html/i.test(html)) {
|
|
155
147
|
html = "<!DOCTYPE html>\n" + content;
|
|
156
148
|
}
|
|
@@ -160,13 +152,8 @@ async function render(renderers, mod, ssrOpts) {
|
|
|
160
152
|
};
|
|
161
153
|
}
|
|
162
154
|
async function ssr(preloadedComponent, ssrOpts) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
return await render(renderers, mod, ssrOpts);
|
|
166
|
-
} catch (e) {
|
|
167
|
-
await errorHandler(e, { viteServer: ssrOpts.viteServer, filePath: ssrOpts.filePath });
|
|
168
|
-
throw e;
|
|
169
|
-
}
|
|
155
|
+
const [renderers, mod] = preloadedComponent;
|
|
156
|
+
return await render(renderers, mod, ssrOpts);
|
|
170
157
|
}
|
|
171
158
|
export {
|
|
172
159
|
loadRenderers,
|
|
File without changes
|