astro 1.0.0-beta.28 → 1.0.0-beta.30

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
@@ -40,7 +40,7 @@ function printAstroHelp() {
40
40
  });
41
41
  }
42
42
  async function printVersion() {
43
- const version = "1.0.0-beta.28";
43
+ const version = "1.0.0-beta.30";
44
44
  console.log();
45
45
  console.log(` ${colors.bgGreen(colors.black(` astro `))} ${colors.green(`v${version}`)}`);
46
46
  }
@@ -83,7 +83,7 @@ async function cli(args) {
83
83
  } else if (flags.silent) {
84
84
  logging.level = "silent";
85
85
  }
86
- const telemetry = new AstroTelemetry({ version: "1.0.0-beta.28" });
86
+ const telemetry = new AstroTelemetry({ version: "1.0.0-beta.30" });
87
87
  if (cmd === "telemetry") {
88
88
  try {
89
89
  const subcommand = (_a = flags._[3]) == null ? void 0 : _a.toString();
@@ -97,7 +97,7 @@ async function cli(args) {
97
97
  try {
98
98
  const packages = flags._.slice(3);
99
99
  telemetry.record(event.eventCliSession({
100
- astroVersion: "1.0.0-beta.28",
100
+ astroVersion: "1.0.0-beta.30",
101
101
  cliCommand: "add"
102
102
  }));
103
103
  return await add(packages, { cwd: root, flags, logging, telemetry });
@@ -108,7 +108,7 @@ async function cli(args) {
108
108
  case "dev": {
109
109
  try {
110
110
  const { astroConfig, userConfig } = await openConfig({ cwd: root, flags, cmd });
111
- telemetry.record(event.eventCliSession({ astroVersion: "1.0.0-beta.28", cliCommand: "dev" }, userConfig, flags));
111
+ telemetry.record(event.eventCliSession({ astroVersion: "1.0.0-beta.30", cliCommand: "dev" }, userConfig, flags));
112
112
  await devServer(astroConfig, { logging, telemetry });
113
113
  return await new Promise(() => {
114
114
  });
@@ -119,7 +119,7 @@ async function cli(args) {
119
119
  case "build": {
120
120
  try {
121
121
  const { astroConfig, userConfig } = await openConfig({ cwd: root, flags, cmd });
122
- telemetry.record(event.eventCliSession({ astroVersion: "1.0.0-beta.28", cliCommand: "build" }, userConfig, flags));
122
+ telemetry.record(event.eventCliSession({ astroVersion: "1.0.0-beta.30", cliCommand: "build" }, userConfig, flags));
123
123
  return await build(astroConfig, { logging, telemetry });
124
124
  } catch (err) {
125
125
  return throwAndExit(err);
@@ -127,14 +127,14 @@ async function cli(args) {
127
127
  }
128
128
  case "check": {
129
129
  const { astroConfig, userConfig } = await openConfig({ cwd: root, flags, cmd });
130
- telemetry.record(event.eventCliSession({ astroVersion: "1.0.0-beta.28", cliCommand: "check" }, userConfig, flags));
130
+ telemetry.record(event.eventCliSession({ astroVersion: "1.0.0-beta.30", cliCommand: "check" }, userConfig, flags));
131
131
  const ret = await check(astroConfig);
132
132
  return process.exit(ret);
133
133
  }
134
134
  case "preview": {
135
135
  try {
136
136
  const { astroConfig, userConfig } = await openConfig({ cwd: root, flags, cmd });
137
- telemetry.record(event.eventCliSession({ astroVersion: "1.0.0-beta.28", cliCommand: "preview" }, userConfig, flags));
137
+ telemetry.record(event.eventCliSession({ astroVersion: "1.0.0-beta.30", cliCommand: "preview" }, userConfig, flags));
138
138
  const server = await preview(astroConfig, { logging, telemetry });
139
139
  return await server.closed();
140
140
  } catch (err) {
@@ -144,7 +144,7 @@ async function cli(args) {
144
144
  case "docs": {
145
145
  try {
146
146
  await telemetry.record(event.eventCliSession({
147
- astroVersion: "1.0.0-beta.28",
147
+ astroVersion: "1.0.0-beta.30",
148
148
  cliCommand: "docs"
149
149
  }));
150
150
  return await openInBrowser("https://docs.astro.build/");
@@ -140,7 +140,6 @@ class AstroBuilder {
140
140
  try {
141
141
  await this.build(setupData);
142
142
  } catch (_err) {
143
- debugger;
144
143
  throw fixViteErrorMessage(createSafeError(_err), setupData.viteServer);
145
144
  }
146
145
  }
@@ -78,7 +78,7 @@ async function staticBuild(opts) {
78
78
  timer.clientBuild = performance.now();
79
79
  await clientBuild(opts, internals, jsInput);
80
80
  timer.ssr = performance.now();
81
- info(opts.logging, "build", "Building for SSR...");
81
+ info(opts.logging, "build", isBuildingToSSR(astroConfig) ? "Building SSR entrypoints..." : "Building entrypoints for prerendering...");
82
82
  const ssrResult = await ssrBuild(opts, internals, pageInput);
83
83
  info(opts.logging, "build", dim(`Completed in ${getTimeStat(timer.ssr, performance.now())}.`));
84
84
  timer.generate = performance.now();
@@ -93,6 +93,7 @@ ${bgMagenta(black(" finalizing server assets "))}
93
93
  }
94
94
  }
95
95
  async function ssrBuild(opts, internals, input) {
96
+ var _a, _b;
96
97
  const { astroConfig, viteConfig } = opts;
97
98
  const ssr = isBuildingToSSR(astroConfig);
98
99
  const out = ssr ? opts.buildConfig.server : astroConfig.outDir;
@@ -106,12 +107,12 @@ async function ssrBuild(opts, internals, input) {
106
107
  outDir: fileURLToPath(out),
107
108
  rollupOptions: {
108
109
  input: [],
109
- output: {
110
+ output: __spreadValues({
110
111
  format: "esm",
111
112
  entryFileNames: opts.buildConfig.serverEntry,
112
113
  chunkFileNames: "chunks/chunk.[hash].mjs",
113
114
  assetFileNames: "assets/asset.[hash][extname]"
114
- }
115
+ }, (_b = (_a = viteConfig.build) == null ? void 0 : _a.rollupOptions) == null ? void 0 : _b.output)
115
116
  },
116
117
  ssr: true,
117
118
  target: "esnext",
@@ -146,6 +147,7 @@ async function ssrBuild(opts, internals, input) {
146
147
  return await vite.build(viteBuildConfig);
147
148
  }
148
149
  async function clientBuild(opts, internals, input) {
150
+ var _a, _b;
149
151
  const { astroConfig, viteConfig } = opts;
150
152
  const timer = performance.now();
151
153
  const ssr = isBuildingToSSR(astroConfig);
@@ -168,12 +170,12 @@ ${bgGreen(black(" building client "))}`);
168
170
  outDir: fileURLToPath(out),
169
171
  rollupOptions: {
170
172
  input: Array.from(input),
171
- output: {
173
+ output: __spreadValues({
172
174
  format: "esm",
173
175
  entryFileNames: "entry.[hash].js",
174
176
  chunkFileNames: "chunks/chunk.[hash].js",
175
177
  assetFileNames: "assets/asset.[hash][extname]"
176
- },
178
+ }, (_b = (_a = viteConfig.build) == null ? void 0 : _a.rollupOptions) == null ? void 0 : _b.output),
177
179
  preserveEntrySignatures: "exports-only"
178
180
  },
179
181
  target: "esnext"
@@ -36,13 +36,16 @@ async function dev(config, options) {
36
36
  site,
37
37
  https: !!((_a = viteConfig.server) == null ? void 0 : _a.https)
38
38
  }));
39
- const currentVersion = "1.0.0-beta.28";
39
+ const currentVersion = "1.0.0-beta.30";
40
40
  if (currentVersion.includes("-")) {
41
41
  warn(options.logging, null, msg.prerelease({ currentVersion }));
42
42
  }
43
43
  await runHookServerStart({ config, address: devServerAddressInfo });
44
44
  return {
45
45
  address: devServerAddressInfo,
46
+ get watcher() {
47
+ return viteServer.watcher;
48
+ },
46
49
  stop: async () => {
47
50
  await viteServer.close();
48
51
  await runHookServerDone({ config });
@@ -1,17 +1,6 @@
1
1
  import { bold, dim } from "kleur/colors";
2
2
  import stringWidth from "string-width";
3
- function getLoggerLocale() {
4
- const defaultLocale = "en-US";
5
- if (process.env.LANG) {
6
- const extractedLocale = process.env.LANG.split(".")[0].replace(/_/g, "-");
7
- if (extractedLocale.length < 2)
8
- return defaultLocale;
9
- else
10
- return extractedLocale.substring(0, 5);
11
- } else
12
- return defaultLocale;
13
- }
14
- const dateTimeFormat = new Intl.DateTimeFormat(getLoggerLocale(), {
3
+ const dateTimeFormat = new Intl.DateTimeFormat([], {
15
4
  hour: "2-digit",
16
5
  minute: "2-digit",
17
6
  second: "2-digit"
@@ -47,7 +47,7 @@ function devStart({
47
47
  https,
48
48
  site
49
49
  }) {
50
- const version = "1.0.0-beta.28";
50
+ const version = "1.0.0-beta.30";
51
51
  const rootPath = site ? site.pathname : "/";
52
52
  const localPrefix = `${dim("\u2503")} Local `;
53
53
  const networkPrefix = `${dim("\u2503")} Network `;
@@ -203,7 +203,7 @@ function printHelp({
203
203
  };
204
204
  let message = [];
205
205
  if (headline) {
206
- message.push(linebreak(), ` ${bgGreen(black(` ${commandName} `))} ${green(`v${"1.0.0-beta.28"}`)} ${headline}`);
206
+ message.push(linebreak(), ` ${bgGreen(black(` ${commandName} `))} ${green(`v${"1.0.0-beta.30"}`)} ${headline}`);
207
207
  }
208
208
  if (usage) {
209
209
  message.push(linebreak(), ` ${green(commandName)} ${bold(usage)}`);
@@ -105,14 +105,10 @@ async function render(renderers, mod, ssrOpts) {
105
105
  pathname,
106
106
  scripts,
107
107
  async resolve(s) {
108
- const [resolvedUrl, resolvedPath] = await viteServer.moduleGraph.resolveUrl(s);
109
- if (resolvedPath.includes("node_modules/.vite")) {
110
- return resolvedPath.replace(/.*?node_modules\/\.vite/, "/node_modules/.vite");
108
+ if (s.startsWith("/@fs")) {
109
+ return s;
111
110
  }
112
- if (!resolvedUrl.startsWith(".") && !resolvedUrl.startsWith("/")) {
113
- return "/@id" + prependForwardSlash(resolvedUrl);
114
- }
115
- return "/@fs" + prependForwardSlash(resolvedPath);
111
+ return "/@id" + prependForwardSlash(s);
116
112
  },
117
113
  renderers,
118
114
  request,
@@ -116,7 +116,14 @@ async function runHookBuildSetup({
116
116
  }) {
117
117
  for (const integration of config.integrations) {
118
118
  if (integration.hooks["astro:build:setup"]) {
119
- await integration.hooks["astro:build:setup"]({ vite, pages, target });
119
+ await integration.hooks["astro:build:setup"]({
120
+ vite,
121
+ pages,
122
+ target,
123
+ updateConfig: (newConfig) => {
124
+ mergeConfig(vite, newConfig);
125
+ }
126
+ });
120
127
  }
121
128
  }
122
129
  }
@@ -1,22 +1,6 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
1
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
2
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
3
  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));
20
4
  var __objRest = (source, exclude) => {
21
5
  var target = {};
22
6
  for (var prop in source)
@@ -427,9 +411,7 @@ async function renderHead(result) {
427
411
  if ("data-astro-component-hydration" in script.props) {
428
412
  needsHydrationStyles = true;
429
413
  }
430
- return renderElement("script", __spreadProps(__spreadValues({}, script), {
431
- props: __spreadProps(__spreadValues({}, script.props), { "astro-script": result._metadata.pathname + "/script-" + i })
432
- }));
414
+ return renderElement("script", script);
433
415
  });
434
416
  if (needsHydrationStyles) {
435
417
  styles.push(renderElement("style", {
@@ -858,6 +858,7 @@ export interface AstroIntegration {
858
858
  vite: ViteConfigWithSSR;
859
859
  pages: Map<string, PageBuildData>;
860
860
  target: 'client' | 'server';
861
+ updateConfig: (newConfig: ViteConfigWithSSR) => void;
861
862
  }) => void | Promise<void>;
862
863
  'astro:build:done'?: (options: {
863
864
  pages: {
@@ -1,6 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import type { AddressInfo } from 'net';
3
3
  import type { AstroTelemetry } from '@astrojs/telemetry';
4
+ import * as vite from 'vite';
4
5
  import type { AstroConfig } from '../../@types/astro';
5
6
  import { LogOptions } from '../logger/core.js';
6
7
  export interface DevOptions {
@@ -9,6 +10,7 @@ export interface DevOptions {
9
10
  }
10
11
  export interface DevServer {
11
12
  address: AddressInfo;
13
+ watcher: vite.FSWatcher;
12
14
  stop(): Promise<void>;
13
15
  }
14
16
  /** `astro dev` */
@@ -154,15 +154,10 @@ File: ${filename}`);
154
154
  SUFFIX += `import "${id}?astro&type=script&index=${i}";`;
155
155
  i++;
156
156
  }
157
- if (deps.size > 1) {
158
- SUFFIX += `
159
- if(import.meta.hot) import.meta.hot.accept(["${id}", "${Array.from(deps).join('","')}"], (...mods) => mods);`;
160
- } else {
161
- SUFFIX += `
157
+ SUFFIX += `
162
158
  if (import.meta.hot) {
163
- import.meta.hot.accept(mod => mod);
164
- }`;
165
- }
159
+ import.meta.hot.accept(mod => mod);
160
+ }`;
166
161
  }
167
162
  if (isPage) {
168
163
  SUFFIX += `
@@ -117,18 +117,20 @@ async function handle500Response(viteServer, origin, req, res, err) {
117
117
  }
118
118
  function getCustom404Route(config, manifest) {
119
119
  const relPages = resolvePages(config).href.replace(config.root.href, "");
120
- return manifest.routes.find((r) => r.component === appendForwardSlash(relPages) + "404.astro");
120
+ const pattern = new RegExp(`${appendForwardSlash(relPages)}404.(astro|md)`);
121
+ return manifest.routes.find((r) => r.component.match(pattern));
121
122
  }
122
123
  function log404(logging, pathname) {
123
124
  info(logging, "serve", msg.req({ url: pathname, statusCode: 404 }));
124
125
  }
125
126
  async function handleRequest(routeCache, viteServer, logging, manifest, config, req, res) {
127
+ var _a;
126
128
  const reqStart = performance.now();
127
129
  const site = config.site ? new URL(config.base, config.site) : void 0;
128
130
  const devRoot = site ? site.pathname : "/";
129
131
  const origin = `${viteServer.config.server.https ? "https" : "http"}://${req.headers.host}`;
130
132
  const buildingToSSR = isBuildingToSSR(config);
131
- const url = new URL(origin + req.url);
133
+ const url = config.build.format === "file" ? new URL(origin + ((_a = req.url) == null ? void 0 : _a.replace(/(index)?\.html$/, ""))) : new URL(origin + req.url);
132
134
  const pathname = decodeURI(url.pathname);
133
135
  const rootRelativeUrl = pathname.substring(devRoot.length - 1);
134
136
  if (!buildingToSSR) {
@@ -235,7 +237,6 @@ async function handleRequest(routeCache, viteServer, logging, manifest, config,
235
237
  return await writeSSRResult(result, res, statusCode);
236
238
  }
237
239
  } catch (_err) {
238
- debugger;
239
240
  const err = fixViteErrorMessage(createSafeError(_err), viteServer);
240
241
  error(logging, null, msg.formatErrorMessage(err));
241
242
  handle500Response(viteServer, origin, req, res, err);
@@ -35,8 +35,8 @@ import matter from "gray-matter";
35
35
  import { fileURLToPath } from "url";
36
36
  import { PAGE_SSR_SCRIPT_ID } from "../vite-plugin-scripts/index.js";
37
37
  import { pagesVirtualModuleId } from "../core/app/index.js";
38
- import { appendForwardSlash } from "../core/path.js";
39
- import { resolvePages } from "../core/util.js";
38
+ import { appendForwardSlash, prependForwardSlash } from "../core/path.js";
39
+ import { resolvePages, viteID } from "../core/util.js";
40
40
  const MARKDOWN_IMPORT_FLAG = "?mdImport";
41
41
  const MARKDOWN_CONTENT_FLAG = "?content";
42
42
  function markdown({ config }) {
@@ -147,7 +147,7 @@ ${astroResult}`;
147
147
  site: config.site ? new URL(config.base, config.site).toString() : void 0,
148
148
  sourcefile: id,
149
149
  sourcemap: "inline",
150
- internalURL: `/@fs${new URL("../runtime/server/index.js", import.meta.url).pathname}`
150
+ internalURL: `/@fs${prependForwardSlash(viteID(new URL("../runtime/server/index.js", import.meta.url)))}`
151
151
  });
152
152
  tsResult = `
153
153
  export const metadata = ${JSON.stringify(metadata)};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "1.0.0-beta.28",
3
+ "version": "1.0.0-beta.30",
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",
@@ -72,10 +72,10 @@
72
72
  "@astrojs/prism": "0.4.1",
73
73
  "@astrojs/telemetry": "^0.1.2",
74
74
  "@astrojs/webapi": "^0.11.1",
75
- "@babel/core": "^7.17.10",
76
- "@babel/generator": "^7.17.10",
77
- "@babel/parser": "^7.17.10",
78
- "@babel/traverse": "^7.17.10",
75
+ "@babel/core": "^7.17.12",
76
+ "@babel/generator": "^7.17.12",
77
+ "@babel/parser": "^7.17.12",
78
+ "@babel/traverse": "^7.17.12",
79
79
  "@proload/core": "^0.3.2",
80
80
  "@proload/plugin-tsm": "^0.2.1",
81
81
  "ast-types": "^0.14.2",
@@ -109,7 +109,7 @@
109
109
  "prompts": "^2.4.2",
110
110
  "recast": "^0.20.5",
111
111
  "resolve": "^1.22.0",
112
- "rollup": "^2.72.1",
112
+ "rollup": "^2.73.0",
113
113
  "semver": "^7.3.7",
114
114
  "serialize-javascript": "^6.0.0",
115
115
  "shiki": "^0.10.1",
@@ -125,7 +125,8 @@
125
125
  "zod": "^3.16.0"
126
126
  },
127
127
  "devDependencies": {
128
- "@babel/types": "^7.17.10",
128
+ "@babel/types": "^7.17.12",
129
+ "@playwright/test": "^1.22.1",
129
130
  "@types/babel__core": "^7.1.19",
130
131
  "@types/babel__generator": "^7.6.4",
131
132
  "@types/babel__traverse": "^7.17.1",
@@ -140,7 +141,7 @@
140
141
  "@types/mocha": "^9.1.1",
141
142
  "@types/parse5": "^6.0.3",
142
143
  "@types/path-browserify": "^1.0.0",
143
- "@types/prettier": "^2.6.0",
144
+ "@types/prettier": "^2.6.1",
144
145
  "@types/resolve": "^1.20.2",
145
146
  "@types/rimraf": "^3.0.2",
146
147
  "@types/send": "^0.17.1",
@@ -163,7 +164,8 @@
163
164
  "dev": "astro-scripts dev \"src/**/*.ts\"",
164
165
  "postbuild": "astro-scripts copy \"src/**/*.astro\"",
165
166
  "benchmark": "node test/benchmark/dev.bench.js && node test/benchmark/build.bench.js",
166
- "test": "mocha --exit --timeout 20000 --ignore **/lit-element.test.js && mocha --timeout 20000 **/lit-element.test.js",
167
- "test:match": "mocha --timeout 20000 -g"
167
+ "test": "mocha --exit --timeout 20000 --ignore **/lit-element.test.js --ignore **/errors.test.js && mocha --timeout 20000 **/lit-element.test.js && mocha --timeout 20000 **/errors.test.js",
168
+ "test:match": "mocha --timeout 20000 -g",
169
+ "test:e2e": "playwright test e2e"
168
170
  }
169
171
  }