astro 5.0.6 → 5.0.8

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.
@@ -114,7 +114,7 @@ class ContentLayer {
114
114
  logger.info("Content config changed");
115
115
  shouldClear = true;
116
116
  }
117
- if (previousAstroVersion !== "5.0.6") {
117
+ if (previousAstroVersion !== "5.0.8") {
118
118
  logger.info("Astro version changed");
119
119
  shouldClear = true;
120
120
  }
@@ -122,8 +122,8 @@ class ContentLayer {
122
122
  logger.info("Clearing content store");
123
123
  this.#store.clearAll();
124
124
  }
125
- if ("5.0.6") {
126
- await this.#store.metaStore().set("astro-version", "5.0.6");
125
+ if ("5.0.8") {
126
+ await this.#store.metaStore().set("astro-version", "5.0.8");
127
127
  }
128
128
  if (currentConfigDigest) {
129
129
  await this.#store.metaStore().set("config-digest", currentConfigDigest);
@@ -139,12 +139,12 @@ class AstroBuilder {
139
139
  viteConfig,
140
140
  key: keyPromise
141
141
  };
142
- const { internals, ssrOutputChunkNames, ssrOutputAssetNames, contentFileNames } = await viteBuild(opts);
142
+ const { internals, ssrOutputChunkNames } = await viteBuild(opts);
143
143
  const hasServerIslands = this.settings.serverIslandNameMap.size > 0;
144
144
  if (hasServerIslands && this.settings.buildOutput !== "server") {
145
145
  throw new AstroError(AstroErrorData.NoAdapterInstalledServerIslands);
146
146
  }
147
- await staticBuild(opts, internals, ssrOutputChunkNames, ssrOutputAssetNames, contentFileNames);
147
+ await staticBuild(opts, internals, ssrOutputChunkNames);
148
148
  this.timer.assetsStart = performance.now();
149
149
  Object.keys(assets).map((k) => {
150
150
  if (!assets[k]) return;
@@ -4,10 +4,8 @@ import type { StaticBuildOptions } from './types.js';
4
4
  export declare function viteBuild(opts: StaticBuildOptions): Promise<{
5
5
  internals: BuildInternals;
6
6
  ssrOutputChunkNames: string[];
7
- ssrOutputAssetNames: string[];
8
- contentFileNames: undefined;
9
7
  }>;
10
- export declare function staticBuild(opts: StaticBuildOptions, internals: BuildInternals, ssrOutputChunkNames: string[], ssrOutputAssetNames: string[], contentFileNames?: string[]): Promise<void>;
8
+ export declare function staticBuild(opts: StaticBuildOptions, internals: BuildInternals, ssrOutputChunkNames: string[]): Promise<void>;
11
9
  export declare function copyFiles(fromFolder: URL, toFolder: URL, includeDotfiles?: boolean): Promise<void[] | undefined>;
12
10
  /**
13
11
  * This function takes the virtual module name of any page entrypoint and
@@ -62,38 +62,33 @@ async function viteBuild(opts) {
62
62
  const ssrOutputs = viteBuildReturnToRollupOutputs(ssrOutput);
63
63
  const clientOutputs = viteBuildReturnToRollupOutputs(clientOutput ?? []);
64
64
  await runPostBuildHooks(container, ssrOutputs, clientOutputs);
65
- let contentFileNames = void 0;
66
65
  settings.timer.end("Client build");
67
66
  internals.ssrEntryChunk = void 0;
68
67
  if (opts.teardownCompiler) {
69
68
  teardown();
70
69
  }
71
70
  const ssrOutputChunkNames = [];
72
- const ssrOutputAssetNames = [];
73
71
  for (const output of ssrOutputs) {
74
72
  for (const chunk of output.output) {
75
73
  if (chunk.type === "chunk") {
76
74
  ssrOutputChunkNames.push(chunk.fileName);
77
75
  }
78
- if (chunk.type === "asset") {
79
- ssrOutputAssetNames.push(chunk.fileName);
80
- }
81
76
  }
82
77
  }
83
- return { internals, ssrOutputChunkNames, ssrOutputAssetNames, contentFileNames };
78
+ return { internals, ssrOutputChunkNames };
84
79
  }
85
- async function staticBuild(opts, internals, ssrOutputChunkNames, ssrOutputAssetNames, contentFileNames) {
80
+ async function staticBuild(opts, internals, ssrOutputChunkNames) {
86
81
  const { settings } = opts;
87
82
  if (settings.buildOutput === "static") {
88
83
  settings.timer.start("Static generate");
89
84
  await generatePages(opts, internals);
90
- await cleanServerOutput(opts, ssrOutputChunkNames, contentFileNames, internals);
85
+ await cleanServerOutput(opts, ssrOutputChunkNames, internals);
91
86
  settings.timer.end("Static generate");
92
87
  } else if (settings.buildOutput === "server") {
93
88
  settings.timer.start("Server generate");
94
89
  await generatePages(opts, internals);
95
90
  await cleanStaticOutput(opts, internals);
96
- await ssrMoveAssets(opts, ssrOutputAssetNames);
91
+ await ssrMoveAssets(opts);
97
92
  settings.timer.end("Server generate");
98
93
  }
99
94
  }
@@ -266,9 +261,9 @@ async function cleanStaticOutput(opts, internals) {
266
261
  })
267
262
  );
268
263
  }
269
- async function cleanServerOutput(opts, ssrOutputChunkNames, contentFileNames, internals) {
264
+ async function cleanServerOutput(opts, ssrOutputChunkNames, internals) {
270
265
  const out = getOutDirWithinCwd(opts.settings.config.outDir);
271
- const files = ssrOutputChunkNames.filter((f) => f.endsWith(".mjs")).concat(contentFileNames ?? []);
266
+ const files = ssrOutputChunkNames.filter((f) => f.endsWith(".mjs"));
272
267
  if (internals.manifestFileName) {
273
268
  files.push(internals.manifestFileName);
274
269
  }
@@ -276,7 +271,9 @@ async function cleanServerOutput(opts, ssrOutputChunkNames, contentFileNames, in
276
271
  await Promise.all(
277
272
  files.map(async (filename) => {
278
273
  const url = new URL(filename, out);
279
- await fs.promises.rm(url);
274
+ const map = new URL(url + ".map");
275
+ await Promise.all([fs.promises.rm(url), fs.promises.rm(new URL(map)).catch((e) => {
276
+ })]);
280
277
  })
281
278
  );
282
279
  removeEmptyDirs(fileURLToPath(out));
@@ -309,15 +306,22 @@ async function copyFiles(fromFolder, toFolder, includeDotfiles = false) {
309
306
  })
310
307
  );
311
308
  }
312
- async function ssrMoveAssets(opts, ssrOutputAssetNames) {
309
+ async function ssrMoveAssets(opts) {
313
310
  opts.logger.info("build", "Rearranging server assets...");
314
311
  const serverRoot = opts.settings.buildOutput === "static" ? opts.settings.config.build.client : opts.settings.config.build.server;
315
312
  const clientRoot = opts.settings.config.build.client;
316
- if (ssrOutputAssetNames.length > 0) {
313
+ const assets = opts.settings.config.build.assets;
314
+ const serverAssets = new URL(`./${assets}/`, appendForwardSlash(serverRoot.toString()));
315
+ const clientAssets = new URL(`./${assets}/`, appendForwardSlash(clientRoot.toString()));
316
+ const files = await glob(`**/*`, {
317
+ cwd: fileURLToPath(serverAssets)
318
+ });
319
+ console.log("FILES2", files);
320
+ if (files.length > 0) {
317
321
  await Promise.all(
318
- ssrOutputAssetNames.map(async function moveAsset(filename) {
319
- const currentUrl = new URL(filename, appendForwardSlash(serverRoot.toString()));
320
- const clientUrl = new URL(filename, appendForwardSlash(clientRoot.toString()));
322
+ files.map(async function moveAsset(filename) {
323
+ const currentUrl = new URL(filename, appendForwardSlash(serverAssets.toString()));
324
+ const clientUrl = new URL(filename, appendForwardSlash(clientAssets.toString()));
321
325
  const dir = new URL(path.parse(clientUrl.href).dir);
322
326
  if (!fs.existsSync(dir)) await fs.promises.mkdir(dir, { recursive: true });
323
327
  return fs.promises.rename(currentUrl, clientUrl);
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "5.0.6";
1
+ const ASTRO_VERSION = "5.0.8";
2
2
  const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
3
3
  const REWRITE_DIRECTIVE_HEADER_KEY = "X-Astro-Rewrite";
4
4
  const REWRITE_DIRECTIVE_HEADER_VALUE = "yes";
@@ -22,7 +22,7 @@ async function dev(inlineConfig) {
22
22
  await telemetry.record([]);
23
23
  const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
24
24
  const logger = restart.container.logger;
25
- const currentVersion = "5.0.6";
25
+ const currentVersion = "5.0.8";
26
26
  const isPrerelease = currentVersion.includes("-");
27
27
  if (!isPrerelease) {
28
28
  try {
@@ -38,7 +38,7 @@ function serverStart({
38
38
  host,
39
39
  base
40
40
  }) {
41
- const version = "5.0.6";
41
+ const version = "5.0.8";
42
42
  const localPrefix = `${dim("\u2503")} Local `;
43
43
  const networkPrefix = `${dim("\u2503")} Network `;
44
44
  const emptyPrefix = " ".repeat(11);
@@ -276,7 +276,7 @@ function printHelp({
276
276
  message.push(
277
277
  linebreak(),
278
278
  ` ${bgGreen(black(` ${commandName} `))} ${green(
279
- `v${"5.0.6"}`
279
+ `v${"5.0.8"}`
280
280
  )} ${headline}`
281
281
  );
282
282
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "5.0.6",
3
+ "version": "5.0.8",
4
4
  "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
5
5
  "type": "module",
6
6
  "author": "withastro",