astro 1.0.0-beta.4 → 1.0.0-beta.5

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/cli/index.js CHANGED
@@ -38,7 +38,7 @@ function printAstroHelp() {
38
38
  });
39
39
  }
40
40
  async function printVersion() {
41
- const version = "1.0.0-beta.4";
41
+ const version = "1.0.0-beta.5";
42
42
  console.log();
43
43
  console.log(` ${colors.bgGreen(colors.black(` astro `))} ${colors.green(`v${version}`)}`);
44
44
  }
@@ -116,6 +116,7 @@ async function generatePath(pathname, opts, gopts) {
116
116
  });
117
117
  }
118
118
  }
119
+ const ssr = isBuildingToSSR(opts.astroConfig);
119
120
  const url = new URL(origin + pathname);
120
121
  const options = {
121
122
  legacyBuild: false,
@@ -139,11 +140,11 @@ async function generatePath(pathname, opts, gopts) {
139
140
  const fullyRelativePath = relPath[0] === "." ? relPath : "./" + relPath;
140
141
  return fullyRelativePath;
141
142
  },
142
- request: createRequest({ url, headers: new Headers(), logging }),
143
+ request: createRequest({ url, headers: new Headers(), logging, ssr }),
143
144
  route: pageData.route,
144
145
  routeCache,
145
146
  site: astroConfig.site ? new URL(astroConfig.base, astroConfig.site).toString() : astroConfig.site,
146
- ssr: isBuildingToSSR(opts.astroConfig)
147
+ ssr
147
148
  };
148
149
  let body;
149
150
  if (pageData.route.type === "endpoint") {
@@ -31,8 +31,14 @@ const _manifest = Object.assign(_deserializeManifest('${manifestReplace}'), {
31
31
  const _args = ${adapter.args ? JSON.stringify(adapter.args) : "undefined"};
32
32
 
33
33
  ${adapter.exports ? `const _exports = adapter.createExports(_manifest, _args);
34
- ${adapter.exports.map((name) => `export const ${name} = _exports['${name}'];`).join("\n")}
35
- ${adapter.exports.includes("_default") ? `export default _default` : ""}
34
+ ${adapter.exports.map((name) => {
35
+ if (name === "default") {
36
+ return `const _default = _exports['default'];
37
+ export { _default as default };`;
38
+ } else {
39
+ return `export const ${name} = _exports['${name}'];`;
40
+ }
41
+ }).join("\n")}
36
42
  ` : ""}
37
43
  const _start = 'start';
38
44
  if(_start in adapter) {
@@ -36,7 +36,7 @@ async function dev(config, options = { logging: nodeLogOptions }) {
36
36
  site,
37
37
  https: !!((_a = viteConfig.server) == null ? void 0 : _a.https)
38
38
  }));
39
- const currentVersion = "1.0.0-beta.4";
39
+ const currentVersion = "1.0.0-beta.5";
40
40
  if (currentVersion.includes("-")) {
41
41
  warn(options.logging, null, msg.prerelease({ currentVersion }));
42
42
  }
@@ -45,7 +45,7 @@ function devStart({
45
45
  https,
46
46
  site
47
47
  }) {
48
- const version = "1.0.0-beta.4";
48
+ const version = "1.0.0-beta.5";
49
49
  const rootPath = site ? site.pathname : "/";
50
50
  const localPrefix = `${dim("\u2503")} Local `;
51
51
  const networkPrefix = `${dim("\u2503")} Network `;
@@ -170,7 +170,7 @@ function printHelp({
170
170
  };
171
171
  let message = [];
172
172
  if (headline) {
173
- message.push(linebreak(), ` ${bgGreen(black(` ${commandName} `))} ${green(`v${"1.0.0-beta.4"}`)} ${headline}`);
173
+ message.push(linebreak(), ` ${bgGreen(black(` ${commandName} `))} ${green(`v${"1.0.0-beta.5"}`)} ${headline}`);
174
174
  }
175
175
  if (usage) {
176
176
  message.push(linebreak(), ` ${green(commandName)} ${bold(usage)}`);
@@ -1,10 +1,30 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1
20
  import { warn } from "./logger/core.js";
2
21
  function createRequest({
3
22
  url,
4
23
  headers,
5
24
  method = "GET",
6
25
  body = void 0,
7
- logging
26
+ logging,
27
+ ssr
8
28
  }) {
9
29
  let headersObj = headers instanceof Headers ? headers : new Headers(Object.entries(headers));
10
30
  const request = new Request(url.toString(), {
@@ -26,6 +46,16 @@ function createRequest({
26
46
  }
27
47
  }
28
48
  });
49
+ if (!ssr) {
50
+ const _headers = request.headers;
51
+ const headersDesc = Object.getOwnPropertyDescriptor(request, "headers") || {};
52
+ Object.defineProperty(request, "headers", __spreadProps(__spreadValues({}, headersDesc), {
53
+ get() {
54
+ warn(logging, "ssg", `Headers are not exposed in static-site generation (SSG) mode. To enable reading headers you need to set an SSR adapter in your config.`);
55
+ return _headers;
56
+ }
57
+ }));
58
+ }
29
59
  return request;
30
60
  }
31
61
  export {
@@ -9,6 +9,7 @@ export interface CreateRequestOptions {
9
9
  method?: string;
10
10
  body?: RequestBody | undefined;
11
11
  logging: LogOptions;
12
+ ssr: boolean;
12
13
  }
13
- export declare function createRequest({ url, headers, method, body, logging, }: CreateRequestOptions): Request;
14
+ export declare function createRequest({ url, headers, method, body, logging, ssr, }: CreateRequestOptions): Request;
14
15
  export {};
@@ -34,7 +34,15 @@ function writeHtmlResponse(res, statusCode, html) {
34
34
  }
35
35
  async function writeWebResponse(res, webResponse) {
36
36
  const { status, headers, body } = webResponse;
37
- res.writeHead(status, Object.fromEntries(headers.entries()));
37
+ let _headers = {};
38
+ if ("raw" in headers) {
39
+ for (const [key, value] of Object.entries(headers.raw())) {
40
+ res.setHeader(key, value);
41
+ }
42
+ } else {
43
+ _headers = Object.fromEntries(headers.entries());
44
+ }
45
+ res.writeHead(status, _headers);
38
46
  if (body) {
39
47
  if (body instanceof Readable) {
40
48
  body.pipe(res);
@@ -128,7 +136,8 @@ async function handleRequest(routeCache, viteServer, logging, manifest, config,
128
136
  headers: buildingToSSR ? req.headers : new Headers(),
129
137
  method: req.method,
130
138
  body,
131
- logging
139
+ logging,
140
+ ssr: buildingToSSR
132
141
  });
133
142
  try {
134
143
  if (!pathname.startsWith(devRoot)) {
@@ -33,6 +33,9 @@ function isStyleVirtualModule(id) {
33
33
  function isPageStyleVirtualModule(id) {
34
34
  return id.startsWith(ASTRO_PAGE_STYLE_PREFIX);
35
35
  }
36
+ function isRawOrUrlModule(id) {
37
+ return id.match(/(\?|\&)([^=]+)(raw|url)/gm);
38
+ }
36
39
  function rollupPluginAstroBuildCSS(options) {
37
40
  const { internals, legacy } = options;
38
41
  const styleSourceMap = /* @__PURE__ */ new Map();
@@ -44,7 +47,7 @@ function rollupPluginAstroBuildCSS(options) {
44
47
  const info = ctx.getModuleInfo(id);
45
48
  if (info) {
46
49
  for (const importedId of info.importedIds) {
47
- if (!seen.has(importedId)) {
50
+ if (!seen.has(importedId) && !isRawOrUrlModule(importedId)) {
48
51
  yield* walkStyles(ctx, importedId, seen);
49
52
  }
50
53
  }
@@ -92,7 +92,8 @@ function rollupPluginAstroScanHTML(options) {
92
92
  request: createRequest({
93
93
  url: new URL(origin + pathname),
94
94
  headers: new Headers(),
95
- logging
95
+ logging,
96
+ ssr: false
96
97
  }),
97
98
  mode: "production",
98
99
  origin,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "1.0.0-beta.4",
3
+ "version": "1.0.0-beta.5",
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",