astro 0.25.0 → 0.25.3

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
@@ -37,7 +37,7 @@ function printAstroHelp() {
37
37
  });
38
38
  }
39
39
  async function printVersion() {
40
- const version = "0.25.0";
40
+ const version = "0.25.3";
41
41
  console.log();
42
42
  console.log(` ${colors.bgGreen(colors.black(` astro `))} ${colors.green(`v${version}`)}`);
43
43
  }
@@ -20,7 +20,7 @@ const CONFIG_STUB = `import { defineConfig } from 'astro/config';
20
20
 
21
21
  export default defineConfig({});`;
22
22
  const TAILWIND_CONFIG_STUB = `module.exports = {
23
- content: [],
23
+ content: ['./src/**/*.{astro,html,js,jsx,svelte,ts,tsx,vue}'],
24
24
  theme: {
25
25
  extend: {},
26
26
  },
@@ -41,6 +41,9 @@ function getPageDataByViteID(internals, viteid) {
41
41
  }
42
42
  return void 0;
43
43
  }
44
+ function hasPageDataByViteID(internals, viteid) {
45
+ return internals.pagesByViteID.has(viteid);
46
+ }
44
47
  function* eachPageData(internals) {
45
48
  yield* internals.pagesByComponent.values();
46
49
  }
@@ -50,5 +53,6 @@ export {
50
53
  getPageDataByComponent,
51
54
  getPageDataByViteID,
52
55
  getPageDatasByChunk,
56
+ hasPageDataByViteID,
53
57
  trackPageData
54
58
  };
@@ -45,7 +45,8 @@ async function build(opts) {
45
45
  viteServer
46
46
  }),
47
47
  rollupPluginAstroBuildCSS({
48
- internals
48
+ internals,
49
+ legacy: true
49
50
  }),
50
51
  ...viteConfig.plugins || []
51
52
  ],
@@ -110,8 +110,7 @@ async function ssrBuild(opts, internals, input) {
110
110
  format: "esm",
111
111
  entryFileNames: opts.buildConfig.serverEntry,
112
112
  chunkFileNames: "chunks/chunk.[hash].mjs",
113
- assetFileNames: "assets/asset.[hash][extname]",
114
- inlineDynamicImports: true
113
+ assetFileNames: "assets/asset.[hash][extname]"
115
114
  }
116
115
  },
117
116
  target: "esnext",
@@ -123,7 +122,8 @@ async function ssrBuild(opts, internals, input) {
123
122
  vitePluginInternals(input, internals),
124
123
  vitePluginPages(opts, internals),
125
124
  rollupPluginAstroBuildCSS({
126
- internals
125
+ internals,
126
+ legacy: false
127
127
  }),
128
128
  ...viteConfig.plugins || [],
129
129
  isBuildingToSSR(opts.astroConfig) && vitePluginSSR(opts, internals, opts.astroConfig._ctx.adapter)
@@ -170,7 +170,8 @@ ${bgGreen(black(" building resources "))}
170
170
  vitePluginInternals(input, internals),
171
171
  vitePluginHoistedScripts(astroConfig, internals),
172
172
  rollupPluginAstroBuildCSS({
173
- internals
173
+ internals,
174
+ legacy: false
174
175
  }),
175
176
  ...viteConfig.plugins || []
176
177
  ],
@@ -45,6 +45,7 @@ export const renderers = [${rendererItems}];`;
45
45
  };
46
46
  }
47
47
  export {
48
+ resolvedVirtualModuleId,
48
49
  virtualModuleId,
49
50
  vitePluginPages
50
51
  };
@@ -55,9 +55,7 @@ const AstroConfigSchema = z.object({
55
55
  pages: z.string().optional().default("./src/pages").transform((val) => new URL(val)),
56
56
  public: z.string().optional().default("./public").transform((val) => new URL(val)),
57
57
  dist: z.string().optional().default("./dist").transform((val) => new URL(val)),
58
- integrations: z.preprocess((val) => Array.isArray(val) ? val.flat(Infinity).filter(Boolean) : val, z.array(z.object({ name: z.string(), hooks: z.object({}).passthrough().default({}) })).default([]).refine((arr) => arr.every((integration) => integration.name.startsWith("@astrojs/")), {
59
- message: `Astro integrations are still experimental, and only official integrations are currently supported`
60
- })),
58
+ integrations: z.preprocess((val) => Array.isArray(val) ? val.flat(Infinity).filter(Boolean) : val, z.array(z.object({ name: z.string(), hooks: z.object({}).passthrough().default({}) })).default([])),
61
59
  adapter: z.object({ name: z.string(), hooks: z.object({}).passthrough().default({}) }).optional(),
62
60
  styleOptions: z.object({
63
61
  postcss: z.object({
@@ -84,6 +82,7 @@ const AstroConfigSchema = z.object({
84
82
  port: z.number().optional().default(3e3),
85
83
  trailingSlash: z.union([z.literal("always"), z.literal("never"), z.literal("ignore")]).optional().default("ignore")
86
84
  }).optional().default({}),
85
+ experimentalIntegrations: z.boolean().optional().default(false),
87
86
  vite: z.any().optional().default({})
88
87
  });
89
88
  async function validateConfig(userConfig, root) {
@@ -127,9 +126,20 @@ async function validateConfig(userConfig, root) {
127
126
  }).optional().default({ options: {}, plugins: [] }))
128
127
  }).optional().default({})
129
128
  });
130
- return __spreadProps(__spreadValues({}, await AstroConfigRelativeSchema.parseAsync(userConfig)), {
129
+ const result = __spreadProps(__spreadValues({}, await AstroConfigRelativeSchema.parseAsync(userConfig)), {
131
130
  _ctx: { scripts: [], renderers: [], adapter: void 0 }
132
131
  });
132
+ if (!result.experimentalIntegrations && !result.integrations.every((int) => int.name.startsWith("@astrojs/"))) {
133
+ throw new Error([
134
+ `Astro integrations are still experimental.`,
135
+ ``,
136
+ `Only official "@astrojs/*" integrations are currently supported.`,
137
+ `To enable 3rd-party integrations, use the "--experimental-integrations" flag.`,
138
+ `Breaking changes may occur in this API before Astro v1.0 is released.`,
139
+ ``
140
+ ].join("\n"));
141
+ }
142
+ return result;
133
143
  }
134
144
  function addTrailingSlash(str) {
135
145
  return str.replace(/\/*$/, "/");
@@ -148,6 +158,7 @@ function resolveFlags(flags) {
148
158
  host: typeof flags.host === "string" || typeof flags.host === "boolean" ? flags.host : void 0,
149
159
  legacyBuild: typeof flags.legacyBuild === "boolean" ? flags.legacyBuild : false,
150
160
  experimentalSsr: typeof flags.experimentalSsr === "boolean" ? flags.experimentalSsr : false,
161
+ experimentalIntegrations: typeof flags.experimentalIntegrations === "boolean" ? flags.experimentalIntegrations : false,
151
162
  drafts: typeof flags.drafts === "boolean" ? flags.drafts : false
152
163
  };
153
164
  }
@@ -172,6 +183,8 @@ function mergeCLIFlags(astroConfig, flags) {
172
183
  astroConfig.buildOptions.legacyBuild = false;
173
184
  }
174
185
  }
186
+ if (typeof flags.experimentalIntegrations === "boolean")
187
+ astroConfig.experimentalIntegrations = flags.experimentalIntegrations;
175
188
  if (typeof flags.drafts === "boolean")
176
189
  astroConfig.buildOptions.drafts = flags.drafts;
177
190
  return astroConfig;
@@ -23,7 +23,7 @@ async function dev(config, options = { logging: defaultLogOptions }) {
23
23
  const devServerAddressInfo = viteServer.httpServer.address();
24
24
  const site = config.buildOptions.site ? new URL(config.buildOptions.site) : void 0;
25
25
  info(options.logging, null, msg.devStart({ startupTime: performance.now() - devStart, config, devServerAddressInfo, site, https: !!((_a = viteConfig.server) == null ? void 0 : _a.https) }));
26
- const currentVersion = "0.25.0";
26
+ const currentVersion = "0.25.3";
27
27
  if (currentVersion.includes("-")) {
28
28
  warn(options.logging, null, msg.prerelease({ currentVersion }));
29
29
  }
@@ -28,7 +28,7 @@ function devStart({
28
28
  https,
29
29
  site
30
30
  }) {
31
- const version = "0.25.0";
31
+ const version = "0.25.3";
32
32
  const rootPath = site ? site.pathname : "/";
33
33
  const localPrefix = `${dim("\u2503")} Local `;
34
34
  const networkPrefix = `${dim("\u2503")} Network `;
@@ -121,7 +121,7 @@ function printHelp({
121
121
  };
122
122
  let message = [];
123
123
  if (headline) {
124
- message.push(linebreak(), ` ${bgGreen(black(` ${commandName} `))} ${green(`v${"0.25.0"}`)} ${headline}`);
124
+ message.push(linebreak(), ` ${bgGreen(black(` ${commandName} `))} ${green(`v${"0.25.3"}`)} ${headline}`);
125
125
  }
126
126
  if (usage) {
127
127
  message.push(linebreak(), ` ${green(commandName)} ${bold(usage)}`);
@@ -35,6 +35,7 @@ export interface CLIFlags {
35
35
  /** @deprecated */
36
36
  experimentalStaticBuild?: boolean;
37
37
  experimentalSsr?: boolean;
38
+ experimentalIntegrations?: boolean;
38
39
  legacyBuild?: boolean;
39
40
  drafts?: boolean;
40
41
  }
@@ -400,6 +401,11 @@ export interface AstroUserConfig {
400
401
  */
401
402
  trailingSlash?: 'always' | 'never' | 'ignore';
402
403
  };
404
+ /**
405
+ * Enable experimental support for 3rd-party integrations.
406
+ * Default: false
407
+ */
408
+ experimentalIntegrations?: boolean;
403
409
  /**
404
410
  * @docs
405
411
  * @name vite
@@ -8,4 +8,4 @@ export declare const FIRST_PARTY_ADDONS: {
8
8
  }[];
9
9
  export declare const ALIASES: Map<string, string>;
10
10
  export declare const CONFIG_STUB = "import { defineConfig } from 'astro/config';\n\nexport default defineConfig({});";
11
- export declare const TAILWIND_CONFIG_STUB = "module.exports = {\n\tcontent: [],\n\ttheme: {\n\t\textend: {},\n\t},\n\tplugins: [],\n}\n";
11
+ export declare const TAILWIND_CONFIG_STUB = "module.exports = {\n\tcontent: ['./src/**/*.{astro,html,js,jsx,svelte,ts,tsx,vue}'],\n\ttheme: {\n\t\textend: {},\n\t},\n\tplugins: [],\n}\n";
@@ -37,4 +37,5 @@ export declare function trackPageData(internals: BuildInternals, component: stri
37
37
  export declare function getPageDatasByChunk(internals: BuildInternals, chunk: RenderedChunk): Generator<PageBuildData, void, unknown>;
38
38
  export declare function getPageDataByComponent(internals: BuildInternals, component: string): PageBuildData | undefined;
39
39
  export declare function getPageDataByViteID(internals: BuildInternals, viteid: ViteID): PageBuildData | undefined;
40
+ export declare function hasPageDataByViteID(internals: BuildInternals, viteid: ViteID): boolean;
40
41
  export declare function eachPageData(internals: BuildInternals): Generator<PageBuildData, void, undefined>;
@@ -2,4 +2,5 @@ import type { Plugin as VitePlugin } from 'vite';
2
2
  import type { BuildInternals } from './internal.js';
3
3
  import type { StaticBuildOptions } from './types';
4
4
  export declare const virtualModuleId = "@astrojs-pages-virtual-entry";
5
+ export declare const resolvedVirtualModuleId: string;
5
6
  export declare function vitePluginPages(opts: StaticBuildOptions, internals: BuildInternals): VitePlugin;
@@ -7,7 +7,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
7
7
  pages: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
8
8
  public: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
9
9
  dist: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
10
- integrations: z.ZodEffects<z.ZodEffects<z.ZodDefault<z.ZodArray<z.ZodObject<{
10
+ integrations: z.ZodEffects<z.ZodDefault<z.ZodArray<z.ZodObject<{
11
11
  name: z.ZodString;
12
12
  hooks: z.ZodDefault<z.ZodObject<{}, "passthrough", z.ZodTypeAny, {}, {}>>;
13
13
  }, "strip", z.ZodTypeAny, {
@@ -22,12 +22,6 @@ export declare const AstroConfigSchema: z.ZodObject<{
22
22
  }[], {
23
23
  hooks?: {} | undefined;
24
24
  name: string;
25
- }[] | undefined>, {
26
- name: string;
27
- hooks: {};
28
- }[], {
29
- hooks?: {} | undefined;
30
- name: string;
31
25
  }[] | undefined>;
32
26
  adapter: z.ZodOptional<z.ZodObject<{
33
27
  name: z.ZodString;
@@ -112,6 +106,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
112
106
  port?: number | undefined;
113
107
  trailingSlash?: "always" | "never" | "ignore" | undefined;
114
108
  }>>>;
109
+ experimentalIntegrations: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
115
110
  vite: z.ZodDefault<z.ZodOptional<z.ZodAny>>;
116
111
  }, "strip", z.ZodTypeAny, {
117
112
  adapter?: {
@@ -153,6 +148,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
153
148
  port: number;
154
149
  trailingSlash: "always" | "never" | "ignore";
155
150
  };
151
+ experimentalIntegrations: boolean;
156
152
  }, {
157
153
  projectRoot?: string | undefined;
158
154
  src?: string | undefined;
@@ -192,6 +188,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
192
188
  port?: number | undefined;
193
189
  trailingSlash?: "always" | "never" | "ignore" | undefined;
194
190
  } | undefined;
191
+ experimentalIntegrations?: boolean | undefined;
195
192
  vite?: any;
196
193
  }>;
197
194
  /** Turn raw config values into normalized values */
@@ -1,10 +1,11 @@
1
- import type { BuildInternals } from '../core/build/internal';
1
+ import { BuildInternals } from '../core/build/internal';
2
2
  import { Plugin as VitePlugin } from 'vite';
3
3
  export declare function getAstroPageStyleId(pathname: string): string;
4
4
  export declare function getAstroStyleId(pathname: string): string;
5
5
  export declare function getAstroStylePathFromId(id: string): string;
6
6
  interface PluginOptions {
7
7
  internals: BuildInternals;
8
+ legacy: boolean;
8
9
  }
9
10
  export declare function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin;
10
11
  export {};
@@ -1,7 +1,7 @@
1
1
  import * as path from "path";
2
2
  import esbuild from "esbuild";
3
3
  import { isCSSRequest } from "../core/render/dev/css.js";
4
- import { getPageDatasByChunk } from "../core/build/internal.js";
4
+ import { getPageDatasByChunk, getPageDataByViteID, hasPageDataByViteID } from "../core/build/internal.js";
5
5
  const PLUGIN_NAME = "@astrojs/rollup-plugin-build-css";
6
6
  const ASTRO_STYLE_PREFIX = "@astro-inline-style";
7
7
  const ASTRO_PAGE_STYLE_PREFIX = "@astro-page-all-styles";
@@ -30,8 +30,46 @@ function isPageStyleVirtualModule(id) {
30
30
  return id.startsWith(ASTRO_PAGE_STYLE_PREFIX);
31
31
  }
32
32
  function rollupPluginAstroBuildCSS(options) {
33
- const { internals } = options;
33
+ const { internals, legacy } = options;
34
34
  const styleSourceMap = /* @__PURE__ */ new Map();
35
+ function* walkStyles(ctx, id, seen = /* @__PURE__ */ new Set()) {
36
+ seen.add(id);
37
+ if (styleSourceMap.has(id)) {
38
+ yield [id, styleSourceMap.get(id)];
39
+ }
40
+ const info = ctx.getModuleInfo(id);
41
+ if (info) {
42
+ for (const importedId of info.importedIds) {
43
+ if (!seen.has(importedId)) {
44
+ yield* walkStyles(ctx, importedId, seen);
45
+ }
46
+ }
47
+ }
48
+ }
49
+ async function addStyles() {
50
+ var _a;
51
+ for (const id of this.getModuleIds()) {
52
+ if (hasPageDataByViteID(internals, id)) {
53
+ let pageStyles = "";
54
+ for (const [_styleId, styles] of walkStyles(this, id)) {
55
+ pageStyles += styles;
56
+ }
57
+ if (!pageStyles)
58
+ continue;
59
+ const { code: minifiedCSS } = await esbuild.transform(pageStyles, {
60
+ loader: "css",
61
+ minify: true
62
+ });
63
+ const referenceId = this.emitFile({
64
+ name: "entry.css",
65
+ type: "asset",
66
+ source: minifiedCSS
67
+ });
68
+ const fileName = this.getFileName(referenceId);
69
+ (_a = getPageDataByViteID(internals, id)) == null ? void 0 : _a.css.add(fileName);
70
+ }
71
+ }
72
+ }
35
73
  return {
36
74
  name: PLUGIN_NAME,
37
75
  configResolved(resolvedConfig) {
@@ -75,6 +113,8 @@ function rollupPluginAstroBuildCSS(options) {
75
113
  return null;
76
114
  },
77
115
  async renderChunk(_code, chunk) {
116
+ if (!legacy)
117
+ return null;
78
118
  let chunkCSS = "";
79
119
  let isPureCSS = true;
80
120
  for (const [id] of Object.entries(chunk.modules)) {
@@ -108,13 +148,16 @@ function rollupPluginAstroBuildCSS(options) {
108
148
  }
109
149
  return null;
110
150
  },
111
- generateBundle(opts, bundle) {
151
+ async generateBundle(opts, bundle) {
112
152
  const hasPureCSSChunks = internals.pureCSSChunks.size;
113
153
  const pureChunkFilenames = new Set([...internals.pureCSSChunks].map((chunk) => chunk.fileName));
114
154
  const emptyChunkFiles = [...pureChunkFilenames].map((file) => path.basename(file)).join("|").replace(/\./g, "\\.");
115
155
  const emptyChunkRE = new RegExp(opts.format === "es" ? `\\bimport\\s*"[^"]*(?:${emptyChunkFiles})";
116
156
  ?` : `\\brequire\\(\\s*"[^"]*(?:${emptyChunkFiles})"\\);
117
157
  ?`, "g");
158
+ if (!legacy) {
159
+ await addStyles.call(this);
160
+ }
118
161
  for (const [chunkId, chunk] of Object.entries(bundle)) {
119
162
  if (chunk.type === "chunk") {
120
163
  for (const { css: cssSet } of getPageDatasByChunk(internals, chunk)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "0.25.0",
3
+ "version": "0.25.3",
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",
@@ -65,7 +65,7 @@
65
65
  ],
66
66
  "dependencies": {
67
67
  "@astrojs/compiler": "^0.13.1",
68
- "@astrojs/language-server": "^0.8.10",
68
+ "@astrojs/language-server": "^0.13.2",
69
69
  "@astrojs/markdown-remark": "^0.7.0",
70
70
  "@astrojs/prism": "0.4.1",
71
71
  "@astrojs/webapi": "^0.11.0",
@@ -85,6 +85,7 @@
85
85
  "es-module-lexer": "^0.10.4",
86
86
  "esbuild": "0.14.25",
87
87
  "estree-walker": "^3.0.1",
88
+ "execa": "^6.1.0",
88
89
  "fast-glob": "^3.2.11",
89
90
  "fast-xml-parser": "^4.0.7",
90
91
  "html-entities": "^2.3.2",
@@ -144,7 +145,6 @@
144
145
  "astro-scripts": "0.0.2",
145
146
  "chai": "^4.3.6",
146
147
  "cheerio": "^1.0.0-rc.10",
147
- "execa": "^6.1.0",
148
148
  "mocha": "^9.2.2",
149
149
  "sass": "^1.49.9"
150
150
  },