astro 1.0.0-beta.5 → 1.0.0-beta.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +61 -0
- package/README.md +28 -88
- package/astro-jsx.d.ts +4 -1
- package/components/Code.astro +1 -1
- package/components/Markdown.astro +7 -0
- package/components/Shiki.js +24 -0
- package/dist/cli/check.js +2 -2
- package/dist/cli/index.js +42 -18
- package/dist/cli/telemetry.js +36 -0
- package/dist/core/add/babel.js +2 -2
- package/dist/core/add/consts.js +3 -2
- package/dist/core/add/index.js +17 -16
- package/dist/core/app/common.js +2 -0
- package/dist/core/app/index.js +30 -17
- package/dist/core/app/node.js +1 -1
- package/dist/core/build/generate.js +21 -19
- package/dist/core/build/graph.js +27 -0
- package/dist/core/build/index.js +12 -29
- package/dist/core/build/internal.js +35 -4
- package/dist/core/build/page-data.js +23 -54
- package/dist/core/build/static-build.js +62 -51
- package/dist/{@types/serialize-javascript.d.js → core/build/types.js} +0 -0
- package/dist/core/build/vite-plugin-analyzer.js +93 -0
- package/dist/core/build/vite-plugin-hoisted-scripts.js +31 -7
- package/dist/core/build/vite-plugin-pages.js +7 -10
- package/dist/core/build/vite-plugin-ssr.js +52 -20
- package/dist/core/config.js +133 -42
- package/dist/core/create-vite.js +28 -14
- package/dist/core/dev/index.js +22 -5
- package/dist/core/errors.js +30 -0
- package/dist/core/logger/console.js +2 -2
- package/dist/core/logger/core.js +2 -13
- package/dist/core/logger/node.js +4 -4
- package/dist/core/messages.js +71 -29
- package/dist/core/path.js +14 -10
- package/dist/core/preview/index.js +3 -3
- package/dist/core/render/core.js +23 -10
- package/dist/core/render/dev/css.js +22 -6
- package/dist/core/render/dev/index.js +39 -64
- package/dist/core/render/dev/resolve.js +11 -0
- package/dist/core/render/result.js +39 -35
- package/dist/core/render/route-cache.js +5 -11
- package/dist/core/render/ssr-element.js +18 -1
- package/dist/core/render/util.js +39 -2
- package/dist/core/routing/index.js +1 -1
- package/dist/core/routing/manifest/create.js +71 -27
- package/dist/core/routing/manifest/generator.js +15 -0
- package/dist/core/routing/manifest/serialization.js +36 -18
- package/dist/core/routing/params.js +12 -1
- package/dist/core/routing/validation.js +7 -0
- package/dist/core/util.js +2 -2
- package/dist/integrations/index.js +52 -12
- package/dist/runtime/client/events.js +21 -0
- package/dist/runtime/client/hmr.js +85 -6
- package/dist/{@types/shorthash.d.js → runtime/client/hydration-directives.d.js} +0 -0
- package/dist/runtime/client/idle.js +3 -23
- package/dist/runtime/client/idle.prebuilt.js +4 -0
- package/dist/runtime/client/load.js +5 -23
- package/dist/runtime/client/load.prebuilt.js +4 -0
- package/dist/runtime/client/media.js +3 -23
- package/dist/runtime/client/media.prebuilt.js +4 -0
- package/dist/runtime/client/only.js +5 -23
- package/dist/runtime/client/only.prebuilt.js +4 -0
- package/dist/runtime/client/visible.js +7 -29
- package/dist/runtime/client/visible.prebuilt.js +4 -0
- package/dist/runtime/server/astro-island.js +70 -0
- package/dist/runtime/server/astro-island.prebuilt.js +4 -0
- package/dist/runtime/server/hydration.js +29 -22
- package/dist/runtime/server/index.js +115 -49
- package/dist/runtime/server/metadata.js +9 -38
- package/dist/runtime/server/scripts.js +55 -0
- package/dist/runtime/server/serialize.js +57 -0
- package/dist/runtime/server/shorthash.js +62 -0
- package/dist/runtime/server/util.js +0 -4
- package/dist/template/5xx.js +2 -2
- package/dist/types/@types/astro.d.ts +224 -115
- package/dist/types/cli/telemetry.d.ts +7 -0
- package/dist/types/core/add/babel.d.ts +1 -1
- package/dist/types/core/add/consts.d.ts +1 -1
- package/dist/types/core/add/index.d.ts +3 -1
- package/dist/types/core/app/common.d.ts +1 -1
- package/dist/types/core/app/index.d.ts +2 -0
- package/dist/types/core/app/node.d.ts +1 -1
- package/dist/types/core/app/types.d.ts +14 -6
- package/dist/types/core/build/graph.d.ts +7 -0
- package/dist/types/core/build/index.d.ts +3 -1
- package/dist/types/core/build/internal.d.ts +22 -10
- package/dist/types/core/build/page-data.d.ts +2 -2
- package/dist/types/core/build/types.d.ts +34 -0
- package/dist/types/core/build/vite-plugin-analyzer.d.ts +4 -0
- package/dist/types/core/build/vite-plugin-hoisted-scripts.d.ts +1 -1
- package/dist/types/core/build/vite-plugin-pages.d.ts +0 -2
- package/dist/types/core/build/vite-plugin-ssr.d.ts +2 -1
- package/dist/types/core/config.d.ts +85 -44
- package/dist/types/core/dev/index.d.ts +5 -1
- package/dist/types/core/errors.d.ts +1 -0
- package/dist/types/core/messages.d.ts +6 -4
- package/dist/types/core/path.d.ts +4 -3
- package/dist/types/core/preview/index.d.ts +2 -0
- package/dist/types/core/render/core.d.ts +5 -3
- package/dist/types/core/render/dev/css.d.ts +5 -1
- package/dist/types/core/render/dev/index.d.ts +5 -4
- package/dist/types/core/render/dev/resolve.d.ts +1 -0
- package/dist/types/core/render/result.d.ts +5 -3
- package/dist/types/core/render/route-cache.d.ts +1 -2
- package/dist/types/core/render/ssr-element.d.ts +8 -0
- package/dist/types/core/render/util.d.ts +4 -1
- package/dist/types/core/routing/index.d.ts +1 -1
- package/dist/types/core/routing/manifest/generator.d.ts +2 -0
- package/dist/types/core/routing/manifest/serialization.d.ts +2 -2
- package/dist/types/core/routing/params.d.ts +6 -0
- package/dist/types/core/routing/validation.d.ts +2 -0
- package/dist/types/integrations/index.d.ts +8 -1
- package/dist/types/runtime/client/events.d.ts +1 -0
- package/dist/types/runtime/client/idle.d.ts +0 -6
- package/dist/types/runtime/client/idle.prebuilt.d.ts +7 -0
- package/dist/types/runtime/client/load.d.ts +0 -5
- package/dist/types/runtime/client/load.prebuilt.d.ts +7 -0
- package/dist/types/runtime/client/media.d.ts +0 -5
- package/dist/types/runtime/client/media.prebuilt.d.ts +7 -0
- package/dist/types/runtime/client/only.d.ts +0 -5
- package/dist/types/runtime/client/only.prebuilt.d.ts +7 -0
- package/dist/types/runtime/client/visible.d.ts +0 -7
- package/dist/types/runtime/client/visible.prebuilt.d.ts +7 -0
- package/dist/types/runtime/server/astro-island.d.ts +4 -0
- package/dist/types/runtime/server/astro-island.prebuilt.d.ts +7 -0
- package/dist/types/runtime/server/hydration.d.ts +2 -3
- package/dist/types/runtime/server/index.d.ts +5 -2
- package/dist/types/runtime/server/metadata.d.ts +0 -10
- package/dist/types/runtime/server/scripts.d.ts +6 -0
- package/dist/types/runtime/server/serialize.d.ts +1 -0
- package/dist/types/runtime/server/shorthash.d.ts +31 -0
- package/dist/types/runtime/server/util.d.ts +0 -6
- package/dist/types/vite-plugin-astro/compile.d.ts +12 -4
- package/dist/types/vite-plugin-astro/hmr.d.ts +2 -2
- package/dist/types/vite-plugin-astro/styles.d.ts +3 -1
- package/dist/types/vite-plugin-astro/types.d.ts +8 -0
- package/dist/types/vite-plugin-build-css/index.d.ts +2 -5
- package/dist/types/vite-plugin-build-css/resolve.d.ts +2 -2
- package/dist/types/vite-plugin-utils/index.d.ts +5 -0
- package/dist/vite-plugin-astro/compile.js +19 -10
- package/dist/vite-plugin-astro/hmr.js +20 -15
- package/dist/vite-plugin-astro/index.js +75 -33
- package/dist/vite-plugin-astro/styles.js +4 -3
- package/dist/{core/build/types.d.js → vite-plugin-astro/types.js} +0 -0
- package/dist/vite-plugin-astro-server/index.js +62 -19
- package/dist/vite-plugin-build-css/index.js +100 -177
- package/dist/vite-plugin-config-alias/index.js +1 -1
- package/dist/vite-plugin-env/index.js +7 -3
- package/dist/vite-plugin-jsx/index.js +4 -3
- package/dist/vite-plugin-markdown/index.js +76 -34
- package/dist/vite-plugin-utils/index.js +13 -0
- package/env.d.ts +18 -2
- package/package.json +49 -48
- package/dist/core/render/pretty-feed.js +0 -103
- package/dist/core/render/rss.js +0 -119
- package/dist/types/core/render/pretty-feed.d.ts +0 -2
- package/dist/types/core/render/rss.d.ts +0 -14
- package/dist/types/vite-plugin-build-html/add-rollup-input.d.ts +0 -2
- package/dist/types/vite-plugin-build-html/extract-assets.d.ts +0 -20
- package/dist/types/vite-plugin-build-html/index.d.ts +0 -18
- package/dist/types/vite-plugin-build-html/util.d.ts +0 -7
- package/dist/vite-plugin-build-html/add-rollup-input.js +0 -50
- package/dist/vite-plugin-build-html/extract-assets.js +0 -202
- package/dist/vite-plugin-build-html/index.js +0 -427
- package/dist/vite-plugin-build-html/util.js +0 -44
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import astroRemark from "@astrojs/markdown-remark";
|
|
2
1
|
import fs from "fs";
|
|
3
2
|
import { bgGreen, black, cyan, dim, green, magenta } from "kleur/colors";
|
|
4
3
|
import npath from "path";
|
|
5
4
|
import { fileURLToPath } from "url";
|
|
6
|
-
import {
|
|
7
|
-
import { prependForwardSlash } from "../../core/path.js";
|
|
5
|
+
import { joinPaths, prependForwardSlash, removeLeadingForwardSlash } from "../../core/path.js";
|
|
8
6
|
import { BEFORE_HYDRATION_SCRIPT_ID } from "../../vite-plugin-scripts/index.js";
|
|
9
7
|
import { call as callEndpoint } from "../endpoint/index.js";
|
|
8
|
+
import { debug, info } from "../logger/core.js";
|
|
10
9
|
import { render } from "../render/core.js";
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
createModuleScriptElementWithSrcSet
|
|
14
|
-
} from "../render/ssr-element.js";
|
|
10
|
+
import { createLinkStylesheetElementSet, createModuleScriptsSet } from "../render/ssr-element.js";
|
|
11
|
+
import { createRequest } from "../request.js";
|
|
15
12
|
import { getOutputFilename, isBuildingToSSR } from "../util.js";
|
|
16
13
|
import { getOutFile, getOutFolder } from "./common.js";
|
|
17
14
|
import { eachPageData, getPageDataByComponent } from "./internal.js";
|
|
18
15
|
import { getTimeStat } from "./util.js";
|
|
19
|
-
import { createRequest } from "../request.js";
|
|
20
16
|
const MAX_CONCURRENT_RENDERS = 1;
|
|
21
17
|
function* throttle(max, inPaths) {
|
|
22
18
|
let tmp = [];
|
|
@@ -35,6 +31,9 @@ function* throttle(max, inPaths) {
|
|
|
35
31
|
yield tmp;
|
|
36
32
|
}
|
|
37
33
|
}
|
|
34
|
+
function shouldSkipDraft(pageModule, astroConfig) {
|
|
35
|
+
return !astroConfig.markdown.drafts && "frontmatter" in pageModule && pageModule.frontmatter.draft === true;
|
|
36
|
+
}
|
|
38
37
|
function rootRelativeFacadeId(facadeId, astroConfig) {
|
|
39
38
|
return facadeId.slice(fileURLToPath(astroConfig.root).length);
|
|
40
39
|
}
|
|
@@ -69,16 +68,20 @@ async function generatePage(opts, internals, pageData, ssrEntry) {
|
|
|
69
68
|
const renderers = ssrEntry.renderers;
|
|
70
69
|
const pageInfo = getPageDataByComponent(internals, pageData.route.component);
|
|
71
70
|
const linkIds = Array.from((pageInfo == null ? void 0 : pageInfo.css) ?? []);
|
|
72
|
-
const
|
|
71
|
+
const scripts = (pageInfo == null ? void 0 : pageInfo.hoistedScript) ?? null;
|
|
73
72
|
const pageModule = ssrEntry.pageMap.get(pageData.component);
|
|
74
73
|
if (!pageModule) {
|
|
75
74
|
throw new Error(`Unable to find the module for ${pageData.component}. This is unexpected and likely a bug in Astro, please report.`);
|
|
76
75
|
}
|
|
76
|
+
if (shouldSkipDraft(pageModule, opts.astroConfig)) {
|
|
77
|
+
info(opts.logging, null, `${magenta("\u26A0\uFE0F")} Skipping draft ${pageData.route.component}`);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
77
80
|
const generationOptions = {
|
|
78
81
|
pageData,
|
|
79
82
|
internals,
|
|
80
83
|
linkIds,
|
|
81
|
-
|
|
84
|
+
scripts,
|
|
82
85
|
mod: pageModule,
|
|
83
86
|
renderers
|
|
84
87
|
};
|
|
@@ -99,15 +102,16 @@ function addPageName(pathname, opts) {
|
|
|
99
102
|
opts.pageNames.push(pathname.replace(/\/?$/, "/").replace(/^\//, ""));
|
|
100
103
|
}
|
|
101
104
|
async function generatePath(pathname, opts, gopts) {
|
|
105
|
+
var _a;
|
|
102
106
|
const { astroConfig, logging, origin, routeCache } = opts;
|
|
103
|
-
const { mod, internals, linkIds,
|
|
107
|
+
const { mod, internals, linkIds, scripts: hoistedScripts, pageData, renderers } = gopts;
|
|
104
108
|
if (pageData.route.type === "page") {
|
|
105
109
|
addPageName(pathname, opts);
|
|
106
110
|
}
|
|
107
111
|
debug("build", `Generating: ${pathname}`);
|
|
108
|
-
const site = astroConfig.site;
|
|
112
|
+
const site = astroConfig.base !== "/" ? joinPaths(((_a = astroConfig.site) == null ? void 0 : _a.toString()) || "http://localhost/", astroConfig.base) : astroConfig.site;
|
|
109
113
|
const links = createLinkStylesheetElementSet(linkIds.reverse(), site);
|
|
110
|
-
const scripts =
|
|
114
|
+
const scripts = createModuleScriptsSet(hoistedScripts ? [hoistedScripts] : [], site);
|
|
111
115
|
for (const script of astroConfig._ctx.scripts) {
|
|
112
116
|
if (script.stage === "head-inline") {
|
|
113
117
|
scripts.add({
|
|
@@ -117,12 +121,11 @@ async function generatePath(pathname, opts, gopts) {
|
|
|
117
121
|
}
|
|
118
122
|
}
|
|
119
123
|
const ssr = isBuildingToSSR(opts.astroConfig);
|
|
120
|
-
const url = new URL(
|
|
124
|
+
const url = new URL(opts.astroConfig.base + removeLeadingForwardSlash(pathname), origin);
|
|
121
125
|
const options = {
|
|
122
|
-
legacyBuild: false,
|
|
123
126
|
links,
|
|
124
127
|
logging,
|
|
125
|
-
|
|
128
|
+
markdown: astroConfig.markdown,
|
|
126
129
|
mod,
|
|
127
130
|
origin,
|
|
128
131
|
pathname,
|
|
@@ -136,9 +139,7 @@ async function generatePath(pathname, opts, gopts) {
|
|
|
136
139
|
}
|
|
137
140
|
throw new Error(`Cannot find the built path for ${specifier}`);
|
|
138
141
|
}
|
|
139
|
-
|
|
140
|
-
const fullyRelativePath = relPath[0] === "." ? relPath : "./" + relPath;
|
|
141
|
-
return fullyRelativePath;
|
|
142
|
+
return prependForwardSlash(npath.posix.join(astroConfig.base, hashedFilePath));
|
|
142
143
|
},
|
|
143
144
|
request: createRequest({ url, headers: new Headers(), logging, ssr }),
|
|
144
145
|
route: pageData.route,
|
|
@@ -162,6 +163,7 @@ async function generatePath(pathname, opts, gopts) {
|
|
|
162
163
|
}
|
|
163
164
|
const outFolder = getOutFolder(astroConfig, pathname, pageData.route.type);
|
|
164
165
|
const outFile = getOutFile(astroConfig, outFolder, pathname, pageData.route.type);
|
|
166
|
+
pageData.route.distURL = outFile;
|
|
165
167
|
await fs.promises.mkdir(outFolder, { recursive: true });
|
|
166
168
|
await fs.promises.writeFile(outFile, body, "utf-8");
|
|
167
169
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { resolvedPagesVirtualModuleId } from "../app/index.js";
|
|
2
|
+
function* walkParentInfos(id, ctx, seen = /* @__PURE__ */ new Set()) {
|
|
3
|
+
seen.add(id);
|
|
4
|
+
const info = ctx.getModuleInfo(id);
|
|
5
|
+
if (info) {
|
|
6
|
+
yield info;
|
|
7
|
+
}
|
|
8
|
+
const importers = ((info == null ? void 0 : info.importers) || []).concat((info == null ? void 0 : info.dynamicImporters) || []);
|
|
9
|
+
for (const imp of importers) {
|
|
10
|
+
if (seen.has(imp)) {
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
yield* walkParentInfos(imp, ctx, seen);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function* getTopLevelPages(id, ctx) {
|
|
17
|
+
for (const info of walkParentInfos(id, ctx)) {
|
|
18
|
+
const importers = ((info == null ? void 0 : info.importers) || []).concat((info == null ? void 0 : info.dynamicImporters) || []);
|
|
19
|
+
if (importers.length <= 2 && importers[0] === resolvedPagesVirtualModuleId) {
|
|
20
|
+
yield info.id;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
getTopLevelPages,
|
|
26
|
+
walkParentInfos
|
|
27
|
+
};
|
package/dist/core/build/index.js
CHANGED
|
@@ -1,31 +1,24 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import * as colors from "kleur/colors";
|
|
3
|
-
import { apply as applyPolyfill } from "../polyfill.js";
|
|
4
3
|
import { performance } from "perf_hooks";
|
|
5
4
|
import * as vite from "vite";
|
|
6
|
-
import { createVite } from "../create-vite.js";
|
|
7
|
-
import {
|
|
8
|
-
debug,
|
|
9
|
-
info,
|
|
10
|
-
levels,
|
|
11
|
-
timerMessage,
|
|
12
|
-
warnIfUsingExperimentalSSR
|
|
13
|
-
} from "../logger/core.js";
|
|
14
|
-
import { nodeLogOptions } from "../logger/node.js";
|
|
15
|
-
import { createRouteManifest } from "../routing/index.js";
|
|
16
|
-
import { collectPagesData } from "./page-data.js";
|
|
17
|
-
import { staticBuild } from "./static-build.js";
|
|
18
|
-
import { RouteCache } from "../render/route-cache.js";
|
|
19
5
|
import {
|
|
20
6
|
runHookBuildDone,
|
|
21
7
|
runHookBuildStart,
|
|
22
8
|
runHookConfigDone,
|
|
23
9
|
runHookConfigSetup
|
|
24
10
|
} from "../../integrations/index.js";
|
|
25
|
-
import {
|
|
26
|
-
import { createSafeError, isBuildingToSSR } from "../util.js";
|
|
11
|
+
import { createVite } from "../create-vite.js";
|
|
27
12
|
import { fixViteErrorMessage } from "../errors.js";
|
|
28
|
-
|
|
13
|
+
import { debug, info, levels, timerMessage, warnIfUsingExperimentalSSR } from "../logger/core.js";
|
|
14
|
+
import { apply as applyPolyfill } from "../polyfill.js";
|
|
15
|
+
import { RouteCache } from "../render/route-cache.js";
|
|
16
|
+
import { createRouteManifest } from "../routing/index.js";
|
|
17
|
+
import { createSafeError, isBuildingToSSR } from "../util.js";
|
|
18
|
+
import { collectPagesData } from "./page-data.js";
|
|
19
|
+
import { staticBuild } from "./static-build.js";
|
|
20
|
+
import { getTimeStat } from "./util.js";
|
|
21
|
+
async function build(config, options) {
|
|
29
22
|
applyPolyfill();
|
|
30
23
|
const builder = new AstroBuilder(config, options);
|
|
31
24
|
await builder.run();
|
|
@@ -40,7 +33,7 @@ class AstroBuilder {
|
|
|
40
33
|
this.logging = options.logging;
|
|
41
34
|
this.routeCache = new RouteCache(this.logging);
|
|
42
35
|
this.origin = config.site ? new URL(config.site).origin : `http://localhost:${config.server.port}`;
|
|
43
|
-
this.manifest =
|
|
36
|
+
this.manifest = { routes: [] };
|
|
44
37
|
this.timer = {};
|
|
45
38
|
}
|
|
46
39
|
async setup() {
|
|
@@ -49,6 +42,7 @@ class AstroBuilder {
|
|
|
49
42
|
this.timer.init = performance.now();
|
|
50
43
|
this.timer.viteStart = performance.now();
|
|
51
44
|
this.config = await runHookConfigSetup({ config: this.config, command: "build" });
|
|
45
|
+
this.manifest = createRouteManifest({ config: this.config }, this.logging);
|
|
52
46
|
const viteConfig = await createVite({
|
|
53
47
|
mode: this.mode,
|
|
54
48
|
server: {
|
|
@@ -85,15 +79,6 @@ class AstroBuilder {
|
|
|
85
79
|
viteServer,
|
|
86
80
|
ssr: isBuildingToSSR(this.config)
|
|
87
81
|
});
|
|
88
|
-
Object.entries(allPages).forEach(([page, data]) => {
|
|
89
|
-
if ("frontmatter" in data.preload[1]) {
|
|
90
|
-
const frontmatter = data.preload[1].frontmatter;
|
|
91
|
-
if (Boolean(frontmatter.draft) && !this.config.markdown.drafts) {
|
|
92
|
-
debug("build", timerMessage(`Skipping draft page ${page}`, this.timer.loadStart));
|
|
93
|
-
delete allPages[page];
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
82
|
debug("build", timerMessage("All pages loaded", this.timer.loadStart));
|
|
98
83
|
const pageNames = [];
|
|
99
84
|
this.timer.buildStart = performance.now();
|
|
@@ -141,7 +126,6 @@ class AstroBuilder {
|
|
|
141
126
|
try {
|
|
142
127
|
await this.build(setupData);
|
|
143
128
|
} catch (_err) {
|
|
144
|
-
debugger;
|
|
145
129
|
throw fixViteErrorMessage(createSafeError(_err), setupData.viteServer);
|
|
146
130
|
}
|
|
147
131
|
}
|
|
@@ -151,7 +135,6 @@ class AstroBuilder {
|
|
|
151
135
|
pageCount,
|
|
152
136
|
buildMode
|
|
153
137
|
}) {
|
|
154
|
-
const buildTime = performance.now() - timeStart;
|
|
155
138
|
const total = getTimeStat(timeStart, performance.now());
|
|
156
139
|
let messages = [];
|
|
157
140
|
if (buildMode === "static") {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { prependForwardSlash } from "../path.js";
|
|
1
2
|
import { viteID } from "../util.js";
|
|
2
3
|
function createBuildInternals() {
|
|
3
4
|
const pureCSSChunks = /* @__PURE__ */ new Set();
|
|
@@ -5,15 +6,19 @@ function createBuildInternals() {
|
|
|
5
6
|
const astroStyleMap = /* @__PURE__ */ new Map();
|
|
6
7
|
const astroPageStyleMap = /* @__PURE__ */ new Map();
|
|
7
8
|
const hoistedScriptIdToHoistedMap = /* @__PURE__ */ new Map();
|
|
9
|
+
const hoistedScriptIdToPagesMap = /* @__PURE__ */ new Map();
|
|
8
10
|
return {
|
|
9
11
|
pureCSSChunks,
|
|
10
|
-
chunkToReferenceIdMap,
|
|
11
|
-
astroStyleMap,
|
|
12
|
-
astroPageStyleMap,
|
|
13
12
|
hoistedScriptIdToHoistedMap,
|
|
13
|
+
hoistedScriptIdToPagesMap,
|
|
14
14
|
entrySpecifierToBundleMap: /* @__PURE__ */ new Map(),
|
|
15
15
|
pagesByComponent: /* @__PURE__ */ new Map(),
|
|
16
|
-
pagesByViteID: /* @__PURE__ */ new Map()
|
|
16
|
+
pagesByViteID: /* @__PURE__ */ new Map(),
|
|
17
|
+
pagesByClientOnly: /* @__PURE__ */ new Map(),
|
|
18
|
+
discoveredHydratedComponents: /* @__PURE__ */ new Set(),
|
|
19
|
+
discoveredClientOnlyComponents: /* @__PURE__ */ new Set(),
|
|
20
|
+
discoveredScripts: /* @__PURE__ */ new Set(),
|
|
21
|
+
staticFiles: /* @__PURE__ */ new Set()
|
|
17
22
|
};
|
|
18
23
|
}
|
|
19
24
|
function trackPageData(internals, component, pageData, componentModuleId, componentURL) {
|
|
@@ -21,6 +26,18 @@ function trackPageData(internals, component, pageData, componentModuleId, compon
|
|
|
21
26
|
internals.pagesByComponent.set(component, pageData);
|
|
22
27
|
internals.pagesByViteID.set(viteID(componentURL), pageData);
|
|
23
28
|
}
|
|
29
|
+
function trackClientOnlyPageDatas(internals, pageData, clientOnlys) {
|
|
30
|
+
for (const clientOnlyComponent of clientOnlys) {
|
|
31
|
+
let pageDataSet;
|
|
32
|
+
if (internals.pagesByClientOnly.has(clientOnlyComponent)) {
|
|
33
|
+
pageDataSet = internals.pagesByClientOnly.get(clientOnlyComponent);
|
|
34
|
+
} else {
|
|
35
|
+
pageDataSet = /* @__PURE__ */ new Set();
|
|
36
|
+
internals.pagesByClientOnly.set(clientOnlyComponent, pageDataSet);
|
|
37
|
+
}
|
|
38
|
+
pageDataSet.add(pageData);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
24
41
|
function* getPageDatasByChunk(internals, chunk) {
|
|
25
42
|
const pagesByViteID = internals.pagesByViteID;
|
|
26
43
|
for (const [modulePath] of Object.entries(chunk.modules)) {
|
|
@@ -29,6 +46,18 @@ function* getPageDatasByChunk(internals, chunk) {
|
|
|
29
46
|
}
|
|
30
47
|
}
|
|
31
48
|
}
|
|
49
|
+
function* getPageDatasByClientOnlyID(internals, viteid) {
|
|
50
|
+
const pagesByClientOnly = internals.pagesByClientOnly;
|
|
51
|
+
if (pagesByClientOnly.size) {
|
|
52
|
+
const pathname = `/@fs${prependForwardSlash(viteid)}`;
|
|
53
|
+
const pageBuildDatas = pagesByClientOnly.get(pathname);
|
|
54
|
+
if (pageBuildDatas) {
|
|
55
|
+
for (const pageData of pageBuildDatas) {
|
|
56
|
+
yield pageData;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
32
61
|
function getPageDataByComponent(internals, component) {
|
|
33
62
|
if (internals.pagesByComponent.has(component)) {
|
|
34
63
|
return internals.pagesByComponent.get(component);
|
|
@@ -53,6 +82,8 @@ export {
|
|
|
53
82
|
getPageDataByComponent,
|
|
54
83
|
getPageDataByViteID,
|
|
55
84
|
getPageDatasByChunk,
|
|
85
|
+
getPageDatasByClientOnlyID,
|
|
56
86
|
hasPageDataByViteID,
|
|
87
|
+
trackClientOnlyPageDatas,
|
|
57
88
|
trackPageData
|
|
58
89
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { info } from "../logger/core.js";
|
|
2
|
-
import { fileURLToPath } from "url";
|
|
3
2
|
import * as colors from "kleur/colors";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
4
|
import { debug } from "../logger/core.js";
|
|
5
|
-
import {
|
|
6
|
-
import { generateRssFunction } from "../render/rss.js";
|
|
5
|
+
import { removeTrailingForwardSlash } from "../path.js";
|
|
7
6
|
import { callGetStaticPaths } from "../render/route-cache.js";
|
|
7
|
+
import { matchRoute } from "../routing/match.js";
|
|
8
8
|
import { isBuildingToSSR } from "../util.js";
|
|
9
9
|
async function collectPagesData(opts) {
|
|
10
|
-
var _a;
|
|
11
10
|
const { astroConfig, logging, manifest, origin, routeCache, viteServer } = opts;
|
|
12
11
|
const assets = {};
|
|
13
12
|
const allPages = {};
|
|
13
|
+
const builtPaths = /* @__PURE__ */ new Set();
|
|
14
14
|
const buildMode = isBuildingToSSR(astroConfig) ? "ssr" : "static";
|
|
15
15
|
const dataCollectionLogTimeout = setInterval(() => {
|
|
16
16
|
info(opts.logging, "build", "The data collection step may take longer for larger projects...");
|
|
@@ -22,33 +22,22 @@ async function collectPagesData(opts) {
|
|
|
22
22
|
info(opts.logging, "build", `${colors.bold(route.component)} is taking a bit longer to import. This is common for larger "Astro.glob(...)" or "import.meta.globEager(...)" calls, for instance. Hang tight!`);
|
|
23
23
|
clearInterval(routeCollectionLogTimeout);
|
|
24
24
|
}, 1e4);
|
|
25
|
+
builtPaths.add(route.pathname);
|
|
25
26
|
allPages[route.component] = {
|
|
26
27
|
component: route.component,
|
|
27
28
|
route,
|
|
28
29
|
paths: [route.pathname],
|
|
29
30
|
moduleSpecifier: "",
|
|
30
31
|
css: /* @__PURE__ */ new Set(),
|
|
31
|
-
hoistedScript: void 0
|
|
32
|
-
scripts: /* @__PURE__ */ new Set(),
|
|
33
|
-
preload: await ssrPreload({
|
|
34
|
-
astroConfig,
|
|
35
|
-
filePath: new URL(`./${route.component}`, astroConfig.root),
|
|
36
|
-
viteServer
|
|
37
|
-
}).then((routes) => {
|
|
38
|
-
clearInterval(routeCollectionLogTimeout);
|
|
39
|
-
if (buildMode === "static") {
|
|
40
|
-
const html = `${route.pathname}`.replace(/\/?$/, "/index.html");
|
|
41
|
-
debug("build", `\u251C\u2500\u2500 ${colors.bold(colors.green("\u2714"))} ${route.component} \u2192 ${colors.yellow(html)}`);
|
|
42
|
-
} else {
|
|
43
|
-
debug("build", `\u251C\u2500\u2500 ${colors.bold(colors.green("\u2714"))} ${route.component}`);
|
|
44
|
-
}
|
|
45
|
-
return routes;
|
|
46
|
-
}).catch((err) => {
|
|
47
|
-
clearInterval(routeCollectionLogTimeout);
|
|
48
|
-
debug("build", `\u251C\u2500\u2500 ${colors.bold(colors.red("\u2718"))} ${route.component}`);
|
|
49
|
-
throw err;
|
|
50
|
-
})
|
|
32
|
+
hoistedScript: void 0
|
|
51
33
|
};
|
|
34
|
+
clearInterval(routeCollectionLogTimeout);
|
|
35
|
+
if (buildMode === "static") {
|
|
36
|
+
const html = `${route.pathname}`.replace(/\/?$/, "/index.html");
|
|
37
|
+
debug("build", `\u251C\u2500\u2500 ${colors.bold(colors.green("\u2714"))} ${route.component} \u2192 ${colors.yellow(html)}`);
|
|
38
|
+
} else {
|
|
39
|
+
debug("build", `\u251C\u2500\u2500 ${colors.bold(colors.green("\u2714"))} ${route.component}`);
|
|
40
|
+
}
|
|
52
41
|
continue;
|
|
53
42
|
}
|
|
54
43
|
const result = await getStaticPathsForRoute(opts, route).then((_result) => {
|
|
@@ -59,44 +48,24 @@ async function collectPagesData(opts) {
|
|
|
59
48
|
debug("build", `\u251C\u2500\u2500 ${colors.bold(colors.red("\u2717"))} ${route.component}`);
|
|
60
49
|
throw err;
|
|
61
50
|
});
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (rssResult.xml) {
|
|
66
|
-
const { url, content } = rssResult.xml;
|
|
67
|
-
if (content) {
|
|
68
|
-
const rssFile = new URL(url.replace(/^\/?/, "./"), astroConfig.outDir);
|
|
69
|
-
if (assets[fileURLToPath(rssFile)]) {
|
|
70
|
-
throw new Error(`[getStaticPaths] RSS feed ${url} already exists.
|
|
71
|
-
Use \`rss(data, {url: '...'})\` to choose a unique, custom URL. (${route.component})`);
|
|
72
|
-
}
|
|
73
|
-
assets[fileURLToPath(rssFile)] = content;
|
|
74
|
-
}
|
|
51
|
+
const finalPaths = result.staticPaths.map((staticPath) => staticPath.params && route.generate(staticPath.params)).filter((staticPath) => {
|
|
52
|
+
if (!staticPath) {
|
|
53
|
+
return false;
|
|
75
54
|
}
|
|
76
|
-
if ((
|
|
77
|
-
|
|
78
|
-
const stylesheetFile = new URL(url.replace(/^\/?/, "./"), astroConfig.outDir);
|
|
79
|
-
if (assets[fileURLToPath(stylesheetFile)]) {
|
|
80
|
-
throw new Error(`[getStaticPaths] RSS feed stylesheet ${url} already exists.
|
|
81
|
-
Use \`rss(data, {stylesheet: '...'})\` to choose a unique, custom URL. (${route.component})`);
|
|
82
|
-
}
|
|
83
|
-
assets[fileURLToPath(stylesheetFile)] = content;
|
|
55
|
+
if (!builtPaths.has(removeTrailingForwardSlash(staticPath))) {
|
|
56
|
+
return true;
|
|
84
57
|
}
|
|
85
|
-
|
|
86
|
-
|
|
58
|
+
const matchedRoute = matchRoute(staticPath, manifest);
|
|
59
|
+
return matchedRoute === route;
|
|
60
|
+
});
|
|
61
|
+
finalPaths.map((staticPath) => builtPaths.add(removeTrailingForwardSlash(staticPath)));
|
|
87
62
|
allPages[route.component] = {
|
|
88
63
|
component: route.component,
|
|
89
64
|
route,
|
|
90
65
|
paths: finalPaths,
|
|
91
66
|
moduleSpecifier: "",
|
|
92
67
|
css: /* @__PURE__ */ new Set(),
|
|
93
|
-
hoistedScript: void 0
|
|
94
|
-
scripts: /* @__PURE__ */ new Set(),
|
|
95
|
-
preload: await ssrPreload({
|
|
96
|
-
astroConfig,
|
|
97
|
-
filePath: new URL(`./${route.component}`, astroConfig.root),
|
|
98
|
-
viteServer
|
|
99
|
-
})
|
|
68
|
+
hoistedScript: void 0
|
|
100
69
|
};
|
|
101
70
|
}
|
|
102
71
|
clearInterval(dataCollectionLogTimeout);
|
|
@@ -20,27 +20,26 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
20
20
|
import glob from "fast-glob";
|
|
21
21
|
import fs from "fs";
|
|
22
22
|
import { bgGreen, bgMagenta, black, dim } from "kleur/colors";
|
|
23
|
-
import npath from "path";
|
|
24
23
|
import { fileURLToPath } from "url";
|
|
25
24
|
import * as vite from "vite";
|
|
26
25
|
import { createBuildInternals } from "../../core/build/internal.js";
|
|
27
|
-
import { info } from "../logger/core.js";
|
|
28
26
|
import { prependForwardSlash } from "../../core/path.js";
|
|
29
27
|
import { emptyDir, removeDir } from "../../core/util.js";
|
|
28
|
+
import { runHookBuildSetup } from "../../integrations/index.js";
|
|
30
29
|
import { rollupPluginAstroBuildCSS } from "../../vite-plugin-build-css/index.js";
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import { vitePluginSSR } from "./vite-plugin-ssr.js";
|
|
34
|
-
import { vitePluginPages } from "./vite-plugin-pages.js";
|
|
30
|
+
import { info } from "../logger/core.js";
|
|
31
|
+
import { isBuildingToSSR } from "../util.js";
|
|
35
32
|
import { generatePages } from "./generate.js";
|
|
36
33
|
import { trackPageData } from "./internal.js";
|
|
37
|
-
import { isBuildingToSSR } from "../util.js";
|
|
38
|
-
import { runHookBuildSetup } from "../../integrations/index.js";
|
|
39
34
|
import { getTimeStat } from "./util.js";
|
|
35
|
+
import { vitePluginAnalyzer } from "./vite-plugin-analyzer.js";
|
|
36
|
+
import { vitePluginHoistedScripts } from "./vite-plugin-hoisted-scripts.js";
|
|
37
|
+
import { vitePluginInternals } from "./vite-plugin-internals.js";
|
|
38
|
+
import { vitePluginPages } from "./vite-plugin-pages.js";
|
|
39
|
+
import { injectManifest, vitePluginSSR } from "./vite-plugin-ssr.js";
|
|
40
40
|
async function staticBuild(opts) {
|
|
41
41
|
const { allPages, astroConfig } = opts;
|
|
42
42
|
const pageInput = /* @__PURE__ */ new Set();
|
|
43
|
-
const jsInput = /* @__PURE__ */ new Set();
|
|
44
43
|
const facadeIdToPageDataMap = /* @__PURE__ */ new Map();
|
|
45
44
|
const internals = createBuildInternals();
|
|
46
45
|
const timer = {};
|
|
@@ -49,40 +48,31 @@ async function staticBuild(opts) {
|
|
|
49
48
|
const astroModuleURL = new URL("./" + component, astroConfig.root);
|
|
50
49
|
const astroModuleId = prependForwardSlash(component);
|
|
51
50
|
trackPageData(internals, component, pageData, astroModuleId, astroModuleURL);
|
|
52
|
-
if (pageData.route.type === "page") {
|
|
53
|
-
const [renderers, mod] = pageData.preload;
|
|
54
|
-
const metadata = mod.$$metadata;
|
|
55
|
-
const topLevelImports = /* @__PURE__ */ new Set([
|
|
56
|
-
...metadata.hydratedComponentPaths(),
|
|
57
|
-
...metadata.clientOnlyComponentPaths(),
|
|
58
|
-
...metadata.hydrationDirectiveSpecifiers(),
|
|
59
|
-
...renderers.filter((renderer) => !!renderer.clientEntrypoint).map((renderer) => renderer.clientEntrypoint)
|
|
60
|
-
]);
|
|
61
|
-
const hoistedScripts = new Set(metadata.hoistedScriptPaths());
|
|
62
|
-
if (hoistedScripts.size) {
|
|
63
|
-
const moduleId = npath.posix.join(astroModuleId, "hoisted.js");
|
|
64
|
-
internals.hoistedScriptIdToHoistedMap.set(moduleId, hoistedScripts);
|
|
65
|
-
topLevelImports.add(moduleId);
|
|
66
|
-
}
|
|
67
|
-
for (const specifier of topLevelImports) {
|
|
68
|
-
jsInput.add(specifier);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
51
|
pageInput.add(astroModuleId);
|
|
72
52
|
facadeIdToPageDataMap.set(fileURLToPath(astroModuleURL), pageData);
|
|
73
53
|
}
|
|
74
54
|
emptyDir(astroConfig.outDir, new Set(".git"));
|
|
75
|
-
timer.clientBuild = performance.now();
|
|
76
|
-
await clientBuild(opts, internals, jsInput);
|
|
77
55
|
timer.ssr = performance.now();
|
|
78
|
-
info(opts.logging, "build", "Building for
|
|
56
|
+
info(opts.logging, "build", isBuildingToSSR(astroConfig) ? "Building SSR entrypoints..." : "Building entrypoints for prerendering...");
|
|
79
57
|
const ssrResult = await ssrBuild(opts, internals, pageInput);
|
|
80
58
|
info(opts.logging, "build", dim(`Completed in ${getTimeStat(timer.ssr, performance.now())}.`));
|
|
59
|
+
const clientInput = /* @__PURE__ */ new Set([
|
|
60
|
+
...internals.discoveredHydratedComponents,
|
|
61
|
+
...internals.discoveredClientOnlyComponents,
|
|
62
|
+
...astroConfig._ctx.renderers.map((r) => r.clientEntrypoint).filter((a) => a),
|
|
63
|
+
...internals.discoveredScripts
|
|
64
|
+
]);
|
|
65
|
+
timer.clientBuild = performance.now();
|
|
66
|
+
await clientBuild(opts, internals, clientInput);
|
|
81
67
|
timer.generate = performance.now();
|
|
82
68
|
if (opts.buildConfig.staticMode) {
|
|
83
|
-
|
|
84
|
-
|
|
69
|
+
try {
|
|
70
|
+
await generatePages(ssrResult, opts, internals, facadeIdToPageDataMap);
|
|
71
|
+
} finally {
|
|
72
|
+
await cleanSsrOutput(opts);
|
|
73
|
+
}
|
|
85
74
|
} else {
|
|
75
|
+
await injectManifest(opts, internals);
|
|
86
76
|
info(opts.logging, null, `
|
|
87
77
|
${bgMagenta(black(" finalizing server assets "))}
|
|
88
78
|
`);
|
|
@@ -90,25 +80,30 @@ ${bgMagenta(black(" finalizing server assets "))}
|
|
|
90
80
|
}
|
|
91
81
|
}
|
|
92
82
|
async function ssrBuild(opts, internals, input) {
|
|
83
|
+
var _a, _b, _c, _d;
|
|
93
84
|
const { astroConfig, viteConfig } = opts;
|
|
94
85
|
const ssr = isBuildingToSSR(astroConfig);
|
|
95
86
|
const out = ssr ? opts.buildConfig.server : astroConfig.outDir;
|
|
96
87
|
const viteBuildConfig = {
|
|
97
|
-
logLevel: "error",
|
|
88
|
+
logLevel: opts.viteConfig.logLevel ?? "error",
|
|
98
89
|
mode: "production",
|
|
99
90
|
css: viteConfig.css,
|
|
91
|
+
optimizeDeps: {
|
|
92
|
+
include: [...((_a = viteConfig.optimizeDeps) == null ? void 0 : _a.include) ?? []],
|
|
93
|
+
exclude: [...((_b = viteConfig.optimizeDeps) == null ? void 0 : _b.exclude) ?? []]
|
|
94
|
+
},
|
|
100
95
|
build: __spreadProps(__spreadValues({}, viteConfig.build), {
|
|
101
96
|
emptyOutDir: false,
|
|
102
97
|
manifest: false,
|
|
103
98
|
outDir: fileURLToPath(out),
|
|
104
99
|
rollupOptions: {
|
|
105
100
|
input: [],
|
|
106
|
-
output: {
|
|
101
|
+
output: __spreadValues({
|
|
107
102
|
format: "esm",
|
|
108
103
|
entryFileNames: opts.buildConfig.serverEntry,
|
|
109
|
-
chunkFileNames: "chunks/
|
|
110
|
-
assetFileNames: "assets/
|
|
111
|
-
}
|
|
104
|
+
chunkFileNames: "chunks/[name].[hash].mjs",
|
|
105
|
+
assetFileNames: "assets/[name].[hash][extname]"
|
|
106
|
+
}, (_d = (_c = viteConfig.build) == null ? void 0 : _c.rollupOptions) == null ? void 0 : _d.output)
|
|
112
107
|
},
|
|
113
108
|
ssr: true,
|
|
114
109
|
target: "esnext",
|
|
@@ -121,23 +116,30 @@ async function ssrBuild(opts, internals, input) {
|
|
|
121
116
|
vitePluginPages(opts, internals),
|
|
122
117
|
rollupPluginAstroBuildCSS({
|
|
123
118
|
internals,
|
|
124
|
-
|
|
119
|
+
target: "server"
|
|
125
120
|
}),
|
|
126
121
|
...viteConfig.plugins || [],
|
|
127
|
-
isBuildingToSSR(opts.astroConfig) && vitePluginSSR(opts, internals, opts.astroConfig._ctx.adapter)
|
|
122
|
+
isBuildingToSSR(opts.astroConfig) && vitePluginSSR(opts, internals, opts.astroConfig._ctx.adapter),
|
|
123
|
+
vitePluginAnalyzer(opts.astroConfig, internals)
|
|
128
124
|
],
|
|
129
125
|
publicDir: ssr ? false : viteConfig.publicDir,
|
|
130
126
|
root: viteConfig.root,
|
|
131
127
|
envPrefix: "PUBLIC_",
|
|
132
128
|
server: viteConfig.server,
|
|
133
|
-
base: astroConfig.
|
|
129
|
+
base: astroConfig.base,
|
|
134
130
|
ssr: viteConfig.ssr,
|
|
135
131
|
resolve: viteConfig.resolve
|
|
136
132
|
};
|
|
137
|
-
await runHookBuildSetup({
|
|
133
|
+
await runHookBuildSetup({
|
|
134
|
+
config: astroConfig,
|
|
135
|
+
pages: internals.pagesByComponent,
|
|
136
|
+
vite: viteBuildConfig,
|
|
137
|
+
target: "server"
|
|
138
|
+
});
|
|
138
139
|
return await vite.build(viteBuildConfig);
|
|
139
140
|
}
|
|
140
141
|
async function clientBuild(opts, internals, input) {
|
|
142
|
+
var _a, _b, _c, _d;
|
|
141
143
|
const { astroConfig, viteConfig } = opts;
|
|
142
144
|
const timer = performance.now();
|
|
143
145
|
const ssr = isBuildingToSSR(astroConfig);
|
|
@@ -154,18 +156,22 @@ ${bgGreen(black(" building client "))}`);
|
|
|
154
156
|
logLevel: "info",
|
|
155
157
|
mode: "production",
|
|
156
158
|
css: viteConfig.css,
|
|
159
|
+
optimizeDeps: {
|
|
160
|
+
include: [...((_a = viteConfig.optimizeDeps) == null ? void 0 : _a.include) ?? []],
|
|
161
|
+
exclude: [...((_b = viteConfig.optimizeDeps) == null ? void 0 : _b.exclude) ?? []]
|
|
162
|
+
},
|
|
157
163
|
build: {
|
|
158
164
|
emptyOutDir: false,
|
|
159
165
|
minify: "esbuild",
|
|
160
166
|
outDir: fileURLToPath(out),
|
|
161
167
|
rollupOptions: {
|
|
162
168
|
input: Array.from(input),
|
|
163
|
-
output: {
|
|
169
|
+
output: __spreadValues({
|
|
164
170
|
format: "esm",
|
|
165
|
-
entryFileNames: "
|
|
166
|
-
chunkFileNames: "chunks/
|
|
167
|
-
assetFileNames: "assets/
|
|
168
|
-
},
|
|
171
|
+
entryFileNames: "[name].[hash].js",
|
|
172
|
+
chunkFileNames: "chunks/[name].[hash].js",
|
|
173
|
+
assetFileNames: "assets/[name].[hash][extname]"
|
|
174
|
+
}, (_d = (_c = viteConfig.build) == null ? void 0 : _c.rollupOptions) == null ? void 0 : _d.output),
|
|
169
175
|
preserveEntrySignatures: "exports-only"
|
|
170
176
|
},
|
|
171
177
|
target: "esnext"
|
|
@@ -175,7 +181,7 @@ ${bgGreen(black(" building client "))}`);
|
|
|
175
181
|
vitePluginHoistedScripts(astroConfig, internals),
|
|
176
182
|
rollupPluginAstroBuildCSS({
|
|
177
183
|
internals,
|
|
178
|
-
|
|
184
|
+
target: "client"
|
|
179
185
|
}),
|
|
180
186
|
...viteConfig.plugins || []
|
|
181
187
|
],
|
|
@@ -185,7 +191,12 @@ ${bgGreen(black(" building client "))}`);
|
|
|
185
191
|
server: viteConfig.server,
|
|
186
192
|
base: astroConfig.base
|
|
187
193
|
};
|
|
188
|
-
await runHookBuildSetup({
|
|
194
|
+
await runHookBuildSetup({
|
|
195
|
+
config: astroConfig,
|
|
196
|
+
pages: internals.pagesByComponent,
|
|
197
|
+
vite: viteBuildConfig,
|
|
198
|
+
target: "client"
|
|
199
|
+
});
|
|
189
200
|
const buildResult = await vite.build(viteBuildConfig);
|
|
190
201
|
info(opts.logging, null, dim(`Completed in ${getTimeStat(timer, performance.now())}.
|
|
191
202
|
`));
|
|
@@ -204,11 +215,11 @@ async function copyFiles(fromFolder, toFolder) {
|
|
|
204
215
|
const files = await glob("**/*", {
|
|
205
216
|
cwd: fileURLToPath(fromFolder)
|
|
206
217
|
});
|
|
207
|
-
await fs.promises.mkdir(toFolder, { recursive: true });
|
|
208
218
|
await Promise.all(files.map(async (filename) => {
|
|
209
219
|
const from = new URL(filename, fromFolder);
|
|
210
220
|
const to = new URL(filename, toFolder);
|
|
211
|
-
|
|
221
|
+
const lastFolder = new URL("./", to);
|
|
222
|
+
return fs.promises.mkdir(lastFolder, { recursive: true }).then(() => fs.promises.copyFile(from, to));
|
|
212
223
|
}));
|
|
213
224
|
}
|
|
214
225
|
async function ssrMoveAssets(opts) {
|
|
File without changes
|