astro 2.7.0 → 2.7.1

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.
Files changed (38) hide show
  1. package/README.md +3 -6
  2. package/dist/@types/astro.d.ts +0 -14
  3. package/dist/assets/utils/emitAsset.js +1 -2
  4. package/dist/content/vite-plugin-content-imports.js +0 -1
  5. package/dist/content/vite-plugin-content-virtual-mod.js +7 -1
  6. package/dist/core/build/generate.js +1 -3
  7. package/dist/core/build/index.js +1 -8
  8. package/dist/core/build/plugins/plugin-ssr.js +1 -1
  9. package/dist/core/build/static-build.js +7 -7
  10. package/dist/core/build/types.d.ts +1 -2
  11. package/dist/core/compile/compile.js +0 -5
  12. package/dist/core/compile/style.js +0 -1
  13. package/dist/core/constants.js +1 -1
  14. package/dist/core/dev/dev.js +1 -1
  15. package/dist/core/errors/dev/vite.js +1 -9
  16. package/dist/core/errors/errors-data.d.ts +0 -71
  17. package/dist/core/errors/errors-data.js +10 -75
  18. package/dist/core/errors/errors.d.ts +1 -10
  19. package/dist/core/errors/errors.js +8 -9
  20. package/dist/core/errors/index.d.ts +1 -1
  21. package/dist/core/errors/utils.d.ts +2 -5
  22. package/dist/core/errors/utils.js +3 -3
  23. package/dist/core/messages.js +2 -2
  24. package/dist/core/module-loader/loader.d.ts +4 -0
  25. package/dist/core/render/dev/vite.js +25 -19
  26. package/dist/core/render/ssr-element.js +3 -4
  27. package/dist/core/routing/manifest/create.js +1 -2
  28. package/dist/core/util.d.ts +1 -0
  29. package/dist/core/util.js +5 -4
  30. package/dist/events/error.d.ts +0 -1
  31. package/dist/events/error.js +1 -5
  32. package/dist/integrations/index.d.ts +3 -5
  33. package/dist/integrations/index.js +2 -4
  34. package/dist/vite-plugin-astro/compile.js +2 -0
  35. package/dist/vite-plugin-jsx/index.js +2 -0
  36. package/dist/vite-plugin-load-fallback/index.js +2 -2
  37. package/dist/vite-plugin-markdown/index.js +0 -2
  38. package/package.json +3 -5
package/README.md CHANGED
@@ -8,10 +8,8 @@
8
8
  <br/><br/>
9
9
  </p>
10
10
 
11
-
12
11
  ## Install
13
12
 
14
-
15
13
  ```bash
16
14
  # Recommended!
17
15
  npm create astro@latest
@@ -20,7 +18,7 @@ npm create astro@latest
20
18
  npm install --save-dev astro
21
19
  ```
22
20
 
23
- Looking for help? Start with our [Getting Started](https://docs.astro.build/en/getting-started/) guide.
21
+ Looking for help? Start with our [Getting Started](https://docs.astro.build/en/getting-started/) guide.
24
22
 
25
23
  Looking for quick examples? [Open a starter project](https://astro.new/) right in your browser.
26
24
 
@@ -31,9 +29,10 @@ Visit our [official documentation](https://docs.astro.build/).
31
29
  ## Support
32
30
 
33
31
  Having trouble? Get help in the official [Astro Discord](https://astro.build/chat).
32
+
34
33
  ## Contributing
35
34
 
36
- **New contributors welcome!** Check out our [Contributors Guide](/CONTRIBUTING.md) for help getting started.
35
+ **New contributors welcome!** Check out our [Contributors Guide](/CONTRIBUTING.md) for help getting started.
37
36
 
38
37
  Join us on [Discord](https://astro.build/chat) to meet other maintainers. We'll help you get your first contribution in no time!
39
38
 
@@ -42,5 +41,3 @@ Join us on [Discord](https://astro.build/chat) to meet other maintainers. We'll
42
41
  Astro is generously supported by [Netlify](https://www.netlify.com/), [Vercel](https://vercel.com/), and several other amazing organizations [listed here.](https://astro.build/)
43
42
 
44
43
  [❤️ Sponsor Astro! ❤️](https://github.com/withastro/.github/blob/main/FUNDING.md)
45
-
46
-
@@ -75,20 +75,6 @@ export interface CLIFlags {
75
75
  experimentalAssets?: boolean;
76
76
  experimentalRedirects?: boolean;
77
77
  }
78
- export interface BuildConfig {
79
- /**
80
- * @deprecated Use config.build.client instead.
81
- */
82
- client: URL;
83
- /**
84
- * @deprecated Use config.build.server instead.
85
- */
86
- server: URL;
87
- /**
88
- * @deprecated Use config.build.serverEntry instead.
89
- */
90
- serverEntry: string;
91
- }
92
78
  /**
93
79
  * Astro global available in all contexts in .astro files
94
80
  *
@@ -1,8 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { fileURLToPath, pathToFileURL } from "node:url";
4
- import slash from "slash";
5
- import { prependForwardSlash } from "../../core/path.js";
4
+ import { prependForwardSlash, slash } from "../../core/path.js";
6
5
  import { imageMetadata } from "./metadata.js";
7
6
  async function emitESMImage(id, watchMode, fileEmitter) {
8
7
  if (!id) {
@@ -277,7 +277,6 @@ function stringifyEntryData(data) {
277
277
  });
278
278
  } else {
279
279
  throw new AstroError({
280
- code: 99999,
281
280
  message: "Unexpected error processing content collection data."
282
281
  });
283
282
  }
@@ -4,6 +4,7 @@ import { extname } from "node:path";
4
4
  import { fileURLToPath, pathToFileURL } from "node:url";
5
5
  import pLimit from "p-limit";
6
6
  import { AstroError, AstroErrorData } from "../core/errors/index.js";
7
+ import { appendForwardSlash } from "../core/path.js";
7
8
  import { rootRelativePath } from "../core/util.js";
8
9
  import { VIRTUAL_MODULE_ID } from "./consts.js";
9
10
  import {
@@ -164,7 +165,12 @@ const UnexpectedLookupMapError = new AstroError({
164
165
  });
165
166
  function globWithUnderscoresIgnored(relContentDir, exts) {
166
167
  const extGlob = getExtGlob(exts);
167
- return [`${relContentDir}/**/*${extGlob}`, `!**/_*/**${extGlob}`, `!**/_*${extGlob}`];
168
+ const contentDir = appendForwardSlash(relContentDir);
169
+ return [
170
+ `${contentDir}**/*${extGlob}`,
171
+ `!${contentDir}_*/**${extGlob}`,
172
+ `!${contentDir}_*${extGlob}`
173
+ ];
168
174
  }
169
175
  export {
170
176
  astroContentVirtualModPlugin,
@@ -91,8 +91,7 @@ function chunkIsPage(settings, output, internals) {
91
91
  async function generatePages(opts, internals) {
92
92
  const timer = performance.now();
93
93
  const ssr = isServerLikeOutput(opts.settings.config);
94
- const serverEntry = opts.buildConfig.serverEntry;
95
- const outFolder = ssr ? opts.buildConfig.server : getOutDirWithinCwd(opts.settings.config.outDir);
94
+ const outFolder = ssr ? opts.settings.config.build.server : getOutDirWithinCwd(opts.settings.config.outDir);
96
95
  if (ssr && !hasPrerenderedPages(internals))
97
96
  return;
98
97
  const verb = ssr ? "prerendering" : "generating";
@@ -132,7 +131,6 @@ ${bgGreen(black(` generating optimized images `))}`);
132
131
  }
133
132
  await runHookBuildGenerated({
134
133
  config: opts.settings.config,
135
- buildConfig: opts.buildConfig,
136
134
  logging: opts.logging
137
135
  });
138
136
  info(opts.logging, null, dim(`Completed in ${getTimeStat(timer, performance.now())}.
@@ -81,11 +81,6 @@ class AstroBuilder {
81
81
  }
82
82
  /** Run the build logic. build() is marked private because usage should go through ".run()" */
83
83
  async build({ viteConfig }) {
84
- const buildConfig = {
85
- client: this.settings.config.build.client,
86
- server: this.settings.config.build.server,
87
- serverEntry: this.settings.config.build.serverEntry
88
- };
89
84
  await runHookBuildStart({ config: this.settings.config, logging: this.logging });
90
85
  this.validateConfig();
91
86
  info(this.logging, "build", `output target: ${colors.green(this.settings.config.output)}`);
@@ -117,8 +112,7 @@ class AstroBuilder {
117
112
  pageNames,
118
113
  routeCache: this.routeCache,
119
114
  teardownCompiler: this.teardownCompiler,
120
- viteConfig,
121
- buildConfig
115
+ viteConfig
122
116
  };
123
117
  const { internals } = await viteBuild(opts);
124
118
  await staticBuild(opts, internals);
@@ -134,7 +128,6 @@ class AstroBuilder {
134
128
  debug("build", timerMessage("Additional assets copied", this.timer.assetsStart));
135
129
  await runHookBuildDone({
136
130
  config: this.settings.config,
137
- buildConfig,
138
131
  pages: pageNames,
139
132
  routes: Object.values(allPages).map((pd) => pd.route),
140
133
  logging: this.logging
@@ -293,7 +293,7 @@ function storeEntryPoint(moduleKey, options, internals, fileName) {
293
293
  const componentPath = getPathFromVirtualModulePageName(RESOLVED_SPLIT_MODULE_ID, moduleKey);
294
294
  for (const [page, pageData] of Object.entries(options.allPages)) {
295
295
  if (componentPath == page) {
296
- const publicPath = fileURLToPath(options.settings.config.outDir);
296
+ const publicPath = fileURLToPath(options.settings.config.build.server);
297
297
  internals.entryPoints.set(pageData.route, pathToFileURL(join(publicPath, fileName)));
298
298
  }
299
299
  }
@@ -104,7 +104,7 @@ async function ssrBuild(opts, internals, input, container) {
104
104
  var _a, _b, _c, _d, _e;
105
105
  const { allPages, settings, viteConfig } = opts;
106
106
  const ssr = isServerLikeOutput(settings.config);
107
- const out = ssr ? opts.buildConfig.server : getOutDirWithinCwd(settings.config.outDir);
107
+ const out = ssr ? settings.config.build.server : getOutDirWithinCwd(settings.config.outDir);
108
108
  const routes = Object.values(allPages).map((pd) => pd.route);
109
109
  const { lastVitePlugins, vitePlugins } = container.runBeforeHook("ssr", input);
110
110
  const viteBuildConfig = {
@@ -178,7 +178,7 @@ async function clientBuild(opts, internals, input, container) {
178
178
  const { settings, viteConfig } = opts;
179
179
  const timer = performance.now();
180
180
  const ssr = isServerLikeOutput(settings.config);
181
- const out = ssr ? opts.buildConfig.client : getOutDirWithinCwd(settings.config.outDir);
181
+ const out = ssr ? settings.config.build.client : getOutDirWithinCwd(settings.config.outDir);
182
182
  if (!input.size) {
183
183
  if (ssr) {
184
184
  await copyFiles(settings.config.publicDir, out, true);
@@ -229,9 +229,9 @@ ${bgGreen(black(" building client "))}`);
229
229
  async function runPostBuildHooks(container, ssrReturn, clientReturn) {
230
230
  const mutations = await container.runPostHook(ssrReturn, clientReturn);
231
231
  const config = container.options.settings.config;
232
- const buildConfig = container.options.settings.config.build;
232
+ const build = container.options.settings.config.build;
233
233
  for (const [fileName, mutation] of mutations) {
234
- const root = isServerLikeOutput(config) ? mutation.build === "server" ? buildConfig.server : buildConfig.client : config.outDir;
234
+ const root = isServerLikeOutput(config) ? mutation.build === "server" ? build.server : build.client : config.outDir;
235
235
  const fileURL = new URL(fileName, root);
236
236
  await fs.promises.mkdir(new URL("./", fileURL), { recursive: true });
237
237
  await fs.promises.writeFile(fileURL, mutation.code, "utf-8");
@@ -244,7 +244,7 @@ async function cleanStaticOutput(opts, internals) {
244
244
  allStaticFiles.add(internals.pageToBundleMap.get(pageData.moduleSpecifier));
245
245
  }
246
246
  const ssr = isServerLikeOutput(opts.settings.config);
247
- const out = ssr ? opts.buildConfig.server : getOutDirWithinCwd(opts.settings.config.outDir);
247
+ const out = ssr ? opts.settings.config.build.server : getOutDirWithinCwd(opts.settings.config.outDir);
248
248
  const files = await glob("**/*.mjs", {
249
249
  cwd: fileURLToPath(out)
250
250
  });
@@ -305,8 +305,8 @@ async function copyFiles(fromFolder, toFolder, includeDotfiles = false) {
305
305
  }
306
306
  async function ssrMoveAssets(opts) {
307
307
  info(opts.logging, "build", "Rearranging server assets...");
308
- const serverRoot = opts.settings.config.output === "static" ? opts.buildConfig.client : opts.buildConfig.server;
309
- const clientRoot = opts.buildConfig.client;
308
+ const serverRoot = opts.settings.config.output === "static" ? opts.settings.config.build.client : opts.settings.config.build.server;
309
+ const clientRoot = opts.settings.config.build.client;
310
310
  const assets = opts.settings.config.build.assets;
311
311
  const serverAssets = new URL(`./${assets}/`, appendForwardSlash(serverRoot.toString()));
312
312
  const clientAssets = new URL(`./${assets}/`, appendForwardSlash(clientRoot.toString()));
@@ -1,5 +1,5 @@
1
1
  import type { default as vite, InlineConfig } from 'vite';
2
- import type { AstroConfig, AstroSettings, BuildConfig, ComponentInstance, ManifestData, MiddlewareHandler, RouteData, RuntimeMode, SSRLoadedRenderer } from '../../@types/astro';
2
+ import type { AstroConfig, AstroSettings, ComponentInstance, ManifestData, MiddlewareHandler, RouteData, RuntimeMode, SSRLoadedRenderer } from '../../@types/astro';
3
3
  import type { LogOptions } from '../logger/core';
4
4
  import type { RouteCache } from '../render/route-cache';
5
5
  export type ComponentPath = string;
@@ -33,7 +33,6 @@ export type AllPagesData = Record<ComponentPath, PageBuildData>;
33
33
  export interface StaticBuildOptions {
34
34
  allPages: AllPagesData;
35
35
  settings: AstroSettings;
36
- buildConfig: BuildConfig;
37
36
  logging: LogOptions;
38
37
  manifest: ManifestData;
39
38
  mode: RuntimeMode;
@@ -55,7 +55,6 @@ function handleCompileResultErrors(result, cssTransformErrors) {
55
55
  const compilerError = result.diagnostics.find((diag) => diag.severity === 1);
56
56
  if (compilerError) {
57
57
  throw new CompilerError({
58
- code: compilerError.code,
59
58
  message: compilerError.text,
60
59
  location: {
61
60
  line: compilerError.location.line,
@@ -70,15 +69,11 @@ function handleCompileResultErrors(result, cssTransformErrors) {
70
69
  break;
71
70
  case 1: {
72
71
  const error = cssTransformErrors[0];
73
- if (!error.errorCode) {
74
- error.errorCode = AstroErrorData.UnknownCSSError.code;
75
- }
76
72
  throw cssTransformErrors[0];
77
73
  }
78
74
  default: {
79
75
  throw new AggregateError({
80
76
  ...cssTransformErrors[0],
81
- code: cssTransformErrors[0].errorCode,
82
77
  errors: cssTransformErrors
83
78
  });
84
79
  }
@@ -69,7 +69,6 @@ function enhanceCSSError(err, filename) {
69
69
  const errorPosition = positionAt(styleTagBeginning, fileContent);
70
70
  errorPosition.line += 1;
71
71
  return new CSSError({
72
- code: AstroErrorData.UnknownCSSError.code,
73
72
  message: err.message,
74
73
  location: {
75
74
  file: filename,
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "2.7.0";
1
+ const ASTRO_VERSION = "2.7.1";
2
2
  const SUPPORTED_MARKDOWN_FILE_EXTENSIONS = [
3
3
  ".markdown",
4
4
  ".mdown",
@@ -53,7 +53,7 @@ async function dev(settings, options) {
53
53
  isRestart: options.isRestart
54
54
  })
55
55
  );
56
- const currentVersion = "2.7.0";
56
+ const currentVersion = "2.7.1";
57
57
  if (currentVersion.includes("-")) {
58
58
  warn(options.logging, null, msg.prerelease({ currentVersion }));
59
59
  }
@@ -29,7 +29,6 @@ function enhanceViteSSRError({
29
29
  safeError.name = "FailedToLoadModuleSSR";
30
30
  safeError.message = AstroErrorData.FailedToLoadModuleSSR.message(importName);
31
31
  safeError.hint = AstroErrorData.FailedToLoadModuleSSR.hint;
32
- safeError.code = AstroErrorData.FailedToLoadModuleSSR.code;
33
32
  const line = lns.findIndex((ln) => ln.includes(importName));
34
33
  if (line !== -1) {
35
34
  const column = (_b = lns[line]) == null ? void 0 : _b.indexOf(importName);
@@ -55,7 +54,6 @@ function enhanceViteSSRError({
55
54
  safeError.message = AstroErrorData.InvalidGlob.message(globPattern);
56
55
  safeError.name = "InvalidGlob";
57
56
  safeError.hint = AstroErrorData.InvalidGlob.hint;
58
- safeError.code = AstroErrorData.InvalidGlob.code;
59
57
  safeError.title = AstroErrorData.InvalidGlob.title;
60
58
  const line = lns.findIndex((ln) => ln.includes(globPattern));
61
59
  if (line !== -1) {
@@ -81,13 +79,7 @@ async function getViteErrorPayload(err) {
81
79
  }
82
80
  const message = renderErrorMarkdown(err.message.trim(), "html");
83
81
  const hint = err.hint ? renderErrorMarkdown(err.hint.trim(), "html") : void 0;
84
- const hasDocs = err.type && err.name && [
85
- "AstroError",
86
- "AggregateError",
87
- /* 'CompilerError' ,*/
88
- "CSSError",
89
- "MarkdownError"
90
- ] || ["FailedToLoadModuleSSR", "InvalidGlob"].includes(err.name);
82
+ const hasDocs = err.name in AstroErrorData;
91
83
  const docslink = hasDocs ? `https://docs.astro.build/en/reference/errors/${getKebabErrorName(err.name)}/` : void 0;
92
84
  const highlighter = await getHighlighter({ theme: "css-variables" });
93
85
  let highlighterLang = (_b = (_a = err.loc) == null ? void 0 : _a.file) == null ? void 0 : _b.split(".").pop();