astro 2.3.3 → 2.3.4

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/client-base.d.ts CHANGED
@@ -3,7 +3,26 @@
3
3
  declare module 'astro:assets' {
4
4
  // Exporting things one by one is a bit cumbersome, not sure if there's a better way - erika, 2023-02-03
5
5
  type AstroAssets = {
6
- getImage: typeof import('./dist/assets/index.js').getImage;
6
+ // getImage's type here is different from the internal function since the Vite module implicitly pass the service config
7
+ /**
8
+ * Get an optimized image and the necessary attributes to render it.
9
+ *
10
+ * **Example**
11
+ * ```astro
12
+ * ---
13
+ * import { getImage } from 'astro:assets';
14
+ * import originalImage from '../assets/image.png';
15
+ *
16
+ * const optimizedImage = await getImage({src: originalImage, width: 1280 });
17
+ * ---
18
+ * <img src={optimizedImage.src} {...optimizedImage.attributes} />
19
+ * ```
20
+ *
21
+ * This is functionally equivalent to using the `<Image />` component, as the component calls this function internally.
22
+ */
23
+ getImage: (
24
+ options: import('./dist/assets/types.js').ImageTransform
25
+ ) => Promise<import('./dist/assets/types.js').GetImageResult>;
7
26
  getConfiguredImageService: typeof import('./dist/assets/index.js').getConfiguredImageService;
8
27
  Image: typeof import('./components/Image.astro').default;
9
28
  };
@@ -3,22 +3,6 @@ import { type ImageService } from './services/service.js';
3
3
  import type { GetImageResult, ImageMetadata, ImageTransform } from './types.js';
4
4
  export declare function isESMImportedImage(src: ImageMetadata | string): src is ImageMetadata;
5
5
  export declare function getConfiguredImageService(): Promise<ImageService>;
6
- /**
7
- * Get an optimized image and the necessary attributes to render it.
8
- *
9
- * **Example**
10
- * ```astro
11
- * ---
12
- * import { getImage } from 'astro:assets';
13
- * import originalImage from '../assets/image.png';
14
- *
15
- * const optimizedImage = await getImage({src: originalImage, width: 1280 });
16
- * ---
17
- * <img src={optimizedImage.src} {...optimizedImage.attributes} />
18
- * ```
19
- *
20
- * This is functionally equivalent to using the `<Image />` component, as the component calls this function internally.
21
- */
22
6
  export declare function getImage(options: ImageTransform, serviceConfig: Record<string, any>): Promise<GetImageResult>;
23
7
  export declare function getStaticImageList(): Iterable<[
24
8
  string,
@@ -90,7 +90,7 @@ function astroContentImportPlugin({
90
90
  if (settings.contentEntryTypes.some((t) => t.getRenderModule)) {
91
91
  plugins.push({
92
92
  name: "astro:content-render-imports",
93
- async load(viteId) {
93
+ async transform(_, viteId) {
94
94
  const contentRenderer = getContentRendererByViteId(viteId, settings);
95
95
  if (!contentRenderer)
96
96
  return;
@@ -28,12 +28,7 @@ import { createRequest } from "../request.js";
28
28
  import { matchRoute } from "../routing/match.js";
29
29
  import { getOutputFilename } from "../util.js";
30
30
  import { getOutDirWithinCwd, getOutFile, getOutFolder } from "./common.js";
31
- import {
32
- eachPageData,
33
- eachPrerenderedPageData,
34
- getPageDataByComponent,
35
- sortedCSS
36
- } from "./internal.js";
31
+ import { eachPageData, getPageDataByComponent, sortedCSS } from "./internal.js";
37
32
  import { getTimeStat } from "./util.js";
38
33
  function shouldSkipDraft(pageModule, settings) {
39
34
  var _a;
@@ -73,8 +68,9 @@ ${bgGreen(black(` ${verb} static routes `))}`);
73
68
  const ssrEntry = await import(ssrEntryURL.toString());
74
69
  const builtPaths = /* @__PURE__ */ new Set();
75
70
  if (ssr) {
76
- for (const pageData of eachPrerenderedPageData(internals)) {
77
- await generatePage(opts, internals, pageData, ssrEntry, builtPaths);
71
+ for (const pageData of eachPageData(internals)) {
72
+ if (pageData.route.prerender)
73
+ await generatePage(opts, internals, pageData, ssrEntry, builtPaths);
78
74
  }
79
75
  } else {
80
76
  for (const pageData of eachPageData(internals)) {
@@ -77,8 +77,6 @@ export declare function getPageDataByViteID(internals: BuildInternals, viteid: V
77
77
  export declare function hasPageDataByViteID(internals: BuildInternals, viteid: ViteID): boolean;
78
78
  export declare function eachPageData(internals: BuildInternals): Generator<PageBuildData, void, undefined>;
79
79
  export declare function hasPrerenderedPages(internals: BuildInternals): boolean;
80
- export declare function eachPrerenderedPageData(internals: BuildInternals): Generator<PageBuildData, void, unknown>;
81
- export declare function eachServerPageData(internals: BuildInternals): Generator<PageBuildData, void, unknown>;
82
80
  /**
83
81
  * Sort a page's CSS by depth. A higher depth means that the CSS comes from shared subcomponents.
84
82
  * A lower depth means it comes directly from the top-level page.
@@ -83,30 +83,13 @@ function* eachPageData(internals) {
83
83
  yield* internals.pagesByComponent.values();
84
84
  }
85
85
  function hasPrerenderedPages(internals) {
86
- var _a;
87
- for (const id of internals.pagesByViteID.keys()) {
88
- if ((_a = internals.pageOptionsByPage.get(id)) == null ? void 0 : _a.prerender) {
86
+ for (const pageData of eachPageData(internals)) {
87
+ if (pageData.route.prerender) {
89
88
  return true;
90
89
  }
91
90
  }
92
91
  return false;
93
92
  }
94
- function* eachPrerenderedPageData(internals) {
95
- var _a;
96
- for (const [id, pageData] of internals.pagesByViteID.entries()) {
97
- if ((_a = internals.pageOptionsByPage.get(id)) == null ? void 0 : _a.prerender) {
98
- yield pageData;
99
- }
100
- }
101
- }
102
- function* eachServerPageData(internals) {
103
- var _a;
104
- for (const [id, pageData] of internals.pagesByViteID.entries()) {
105
- if (!((_a = internals.pageOptionsByPage.get(id)) == null ? void 0 : _a.prerender)) {
106
- yield pageData;
107
- }
108
- }
109
- }
110
93
  function sortedCSS(pageData) {
111
94
  return Array.from(pageData.css).sort((a, b) => {
112
95
  let depthA = a[1].depth, depthB = b[1].depth, orderA = a[1].order, orderB = b[1].order;
@@ -146,8 +129,6 @@ function* getPageDatasByHoistedScriptId(internals, id) {
146
129
  export {
147
130
  createBuildInternals,
148
131
  eachPageData,
149
- eachPrerenderedPageData,
150
- eachServerPageData,
151
132
  getPageDataByComponent,
152
133
  getPageDataByViteID,
153
134
  getPageDatasByChunk,
@@ -1,6 +1,7 @@
1
1
  import type { Plugin as VitePlugin } from 'vite';
2
2
  import type { BuildInternals } from '../internal.js';
3
3
  import type { AstroBuildPlugin } from '../plugin.js';
4
+ export declare const astroEntryPrefix = "\0astro-entry:";
4
5
  /**
5
6
  * When adding hydrated or client:only components as Rollup inputs, sometimes we're not using all
6
7
  * of the export names, e.g. `import { Counter } from './ManyComponents.jsx'`. This plugin proxies
@@ -68,6 +68,7 @@ function pluginComponentEntry(internals) {
68
68
  };
69
69
  }
70
70
  export {
71
+ astroEntryPrefix,
71
72
  normalizeEntryId,
72
73
  pluginComponentEntry,
73
74
  vitePluginComponentEntry
@@ -7,7 +7,7 @@ import { joinPaths, prependForwardSlash } from "../../path.js";
7
7
  import { serializeRouteData } from "../../routing/index.js";
8
8
  import { addRollupInput } from "../add-rollup-input.js";
9
9
  import { getOutFile, getOutFolder } from "../common.js";
10
- import { eachPrerenderedPageData, eachServerPageData, sortedCSS } from "../internal.js";
10
+ import { eachPageData, sortedCSS } from "../internal.js";
11
11
  const virtualModuleId = "@astrojs-ssr-virtual-entry";
12
12
  const resolvedVirtualModuleId = "\0" + virtualModuleId;
13
13
  const manifestReplace = "@@ASTRO_MANIFEST_REPLACE@@";
@@ -111,7 +111,9 @@ function buildManifest(opts, internals, staticFiles) {
111
111
  return prependForwardSlash(joinPaths(settings.config.base, pth));
112
112
  }
113
113
  };
114
- for (const pageData of eachPrerenderedPageData(internals)) {
114
+ for (const pageData of eachPageData(internals)) {
115
+ if (!pageData.route.prerender)
116
+ continue;
115
117
  if (!pageData.route.pathname)
116
118
  continue;
117
119
  const outFolder = getOutFolder(
@@ -134,7 +136,9 @@ function buildManifest(opts, internals, staticFiles) {
134
136
  });
135
137
  staticFiles.push(file);
136
138
  }
137
- for (const pageData of eachServerPageData(internals)) {
139
+ for (const pageData of eachPageData(internals)) {
140
+ if (pageData.route.prerender)
141
+ continue;
138
142
  const scripts = [];
139
143
  if (pageData.hoistedScript) {
140
144
  const hoistedValue = pageData.hoistedScript.value;
@@ -8,7 +8,7 @@ import { fileURLToPath } from "url";
8
8
  import * as vite from "vite";
9
9
  import {
10
10
  createBuildInternals,
11
- eachPrerenderedPageData
11
+ eachPageData
12
12
  } from "../../core/build/internal.js";
13
13
  import { emptyDir, removeEmptyDirs } from "../../core/fs/index.js";
14
14
  import { appendForwardSlash, prependForwardSlash } from "../../core/path.js";
@@ -219,8 +219,9 @@ async function runPostBuildHooks(container, ssrReturn, clientReturn) {
219
219
  }
220
220
  async function cleanStaticOutput(opts, internals) {
221
221
  const allStaticFiles = /* @__PURE__ */ new Set();
222
- for (const pageData of eachPrerenderedPageData(internals)) {
223
- allStaticFiles.add(internals.pageToBundleMap.get(pageData.moduleSpecifier));
222
+ for (const pageData of eachPageData(internals)) {
223
+ if (pageData.route.prerender)
224
+ allStaticFiles.add(internals.pageToBundleMap.get(pageData.moduleSpecifier));
224
225
  }
225
226
  const ssr = opts.settings.config.output === "server";
226
227
  const out = ssr ? opts.buildConfig.server : getOutDirWithinCwd(opts.settings.config.outDir);
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "2.3.3";
1
+ const ASTRO_VERSION = "2.3.4";
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.3.3";
56
+ const currentVersion = "2.3.4";
57
57
  if (currentVersion.includes("-")) {
58
58
  warn(options.logging, null, msg.prerelease({ currentVersion }));
59
59
  }
@@ -47,7 +47,7 @@ function serverStart({
47
47
  base,
48
48
  isRestart = false
49
49
  }) {
50
- const version = "2.3.3";
50
+ const version = "2.3.4";
51
51
  const localPrefix = `${dim("\u2503")} Local `;
52
52
  const networkPrefix = `${dim("\u2503")} Network `;
53
53
  const emptyPrefix = " ".repeat(11);
@@ -233,7 +233,7 @@ function printHelp({
233
233
  message.push(
234
234
  linebreak(),
235
235
  ` ${bgGreen(black(` ${commandName} `))} ${green(
236
- `v${"2.3.3"}`
236
+ `v${"2.3.4"}`
237
237
  )} ${headline}`
238
238
  );
239
239
  }
package/dist/core/path.js CHANGED
@@ -40,7 +40,15 @@ function isString(path) {
40
40
  return typeof path === "string" || path instanceof String;
41
41
  }
42
42
  function joinPaths(...paths) {
43
- return paths.filter(isString).map(trimSlashes).join("/");
43
+ return paths.filter(isString).map((path, i) => {
44
+ if (i === 0) {
45
+ return removeTrailingForwardSlash(path);
46
+ } else if (i === paths.length - 1) {
47
+ return removeLeadingForwardSlash(path);
48
+ } else {
49
+ return trimSlashes(path);
50
+ }
51
+ }).join("/");
44
52
  }
45
53
  function removeFileExtension(path) {
46
54
  let idx = path.lastIndexOf(".");
@@ -15,7 +15,12 @@ function getPrivateEnv(viteConfig, astroConfig) {
15
15
  for (const key in fullEnv) {
16
16
  if (envPrefixes.every((prefix) => !key.startsWith(prefix))) {
17
17
  if (typeof process.env[key] !== "undefined") {
18
- privateEnv[key] = `process.env.${key}`;
18
+ const value = process.env[key];
19
+ if (value === "0" || value === "1" || value === "true" || value === "false") {
20
+ privateEnv[key] = value;
21
+ } else {
22
+ privateEnv[key] = `process.env.${key}`;
23
+ }
19
24
  } else {
20
25
  privateEnv[key] = JSON.stringify(fullEnv[key]);
21
26
  }
@@ -5,6 +5,7 @@ import babel from "@babel/core";
5
5
  import * as colors from "kleur/colors";
6
6
  import path from "path";
7
7
  import { CONTENT_FLAG, PROPAGATED_ASSET_FLAG } from "../content/index.js";
8
+ import { astroEntryPrefix } from "../core/build/plugins/plugin-component-entry.js";
8
9
  import { error } from "../core/logger/core.js";
9
10
  import { removeQueryString } from "../core/path.js";
10
11
  import { detectImportSource } from "./import-source.js";
@@ -104,7 +105,7 @@ function jsx({ settings, logging }) {
104
105
  },
105
106
  async transform(code, id, opts) {
106
107
  const ssr = Boolean(opts == null ? void 0 : opts.ssr);
107
- if (SPECIAL_QUERY_REGEX.test(id)) {
108
+ if (SPECIAL_QUERY_REGEX.test(id) || id.startsWith(astroEntryPrefix)) {
108
109
  return null;
109
110
  }
110
111
  id = removeQueryString(id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "2.3.3",
3
+ "version": "2.3.4",
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",
@@ -168,7 +168,6 @@
168
168
  "@types/rimraf": "^3.0.2",
169
169
  "@types/send": "^0.17.1",
170
170
  "@types/server-destroy": "^1.0.1",
171
- "@types/sharp": "^0.31.1",
172
171
  "@types/unist": "^2.0.6",
173
172
  "chai": "^4.3.6",
174
173
  "cheerio": "^1.0.0-rc.11",
@@ -182,14 +181,14 @@
182
181
  "remark-code-titles": "^0.1.2",
183
182
  "rollup": "^3.9.0",
184
183
  "sass": "^1.52.2",
185
- "sharp": "^0.31.3",
184
+ "sharp": "^0.32.1",
186
185
  "srcset-parse": "^1.1.0",
187
186
  "undici": "^5.22.0",
188
187
  "unified": "^10.1.2",
189
188
  "astro-scripts": "0.0.14"
190
189
  },
191
190
  "peerDependencies": {
192
- "sharp": "^0.31.3"
191
+ "sharp": ">=0.31.0"
193
192
  },
194
193
  "peerDependenciesMeta": {
195
194
  "sharp": {