astro 1.2.2 → 1.2.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.
@@ -1,8 +1,8 @@
1
1
  import type { GetModuleInfo, ModuleInfo } from 'rollup';
2
2
  export declare function walkParentInfos(id: string, ctx: {
3
3
  getModuleInfo: GetModuleInfo;
4
- }, depth?: number, seen?: Set<string>): Generator<[ModuleInfo, number], void, unknown>;
4
+ }, depth?: number, seen?: Set<string>, childId?: string): Generator<[ModuleInfo, number, number], void, unknown>;
5
5
  export declare function moduleIsTopLevelPage(info: ModuleInfo): boolean;
6
6
  export declare function getTopLevelPages(id: string, ctx: {
7
7
  getModuleInfo: GetModuleInfo;
8
- }): Generator<[ModuleInfo, number], void, unknown>;
8
+ }): Generator<[ModuleInfo, number, number], void, unknown>;
@@ -1,16 +1,17 @@
1
1
  import { resolvedPagesVirtualModuleId } from "../app/index.js";
2
- function* walkParentInfos(id, ctx, depth = 0, seen = /* @__PURE__ */ new Set()) {
2
+ function* walkParentInfos(id, ctx, depth = 0, seen = /* @__PURE__ */ new Set(), childId = "") {
3
3
  seen.add(id);
4
4
  const info = ctx.getModuleInfo(id);
5
5
  if (info) {
6
- yield [info, depth];
6
+ let order = childId ? info.importedIds.indexOf(childId) : 0;
7
+ yield [info, depth, order];
7
8
  }
8
9
  const importers = ((info == null ? void 0 : info.importers) || []).concat((info == null ? void 0 : info.dynamicImporters) || []);
9
10
  for (const imp of importers) {
10
11
  if (seen.has(imp)) {
11
12
  continue;
12
13
  }
13
- yield* walkParentInfos(imp, ctx, ++depth, seen);
14
+ yield* walkParentInfos(imp, ctx, ++depth, seen, id);
14
15
  }
15
16
  }
16
17
  function moduleIsTopLevelPage(info) {
@@ -78,13 +78,23 @@ function* eachPageData(internals) {
78
78
  }
79
79
  function sortedCSS(pageData) {
80
80
  return Array.from(pageData.css).sort((a, b) => {
81
- let depthA = a[1].depth, depthB = b[1].depth;
82
- if (depthA === -1) {
81
+ let depthA = a[1].depth, depthB = b[1].depth, orderA = a[1].order, orderB = b[1].order;
82
+ if (orderA === -1 && orderB >= 0) {
83
+ return 1;
84
+ } else if (orderB === -1 && orderA >= 0) {
83
85
  return -1;
84
- } else if (depthB === -1) {
86
+ } else if (orderA > orderB) {
85
87
  return 1;
88
+ } else if (orderA < orderB) {
89
+ return -1;
86
90
  } else {
87
- return depthA > depthB ? -1 : 1;
91
+ if (depthA === -1) {
92
+ return -1;
93
+ } else if (depthB === -1) {
94
+ return 1;
95
+ } else {
96
+ return depthA > depthB ? -1 : 1;
97
+ }
88
98
  }
89
99
  }).map(([id]) => id);
90
100
  }
@@ -10,6 +10,7 @@ export interface PageBuildData {
10
10
  moduleSpecifier: string;
11
11
  css: Map<string, {
12
12
  depth: number;
13
+ order: number;
13
14
  }>;
14
15
  hoistedScript: {
15
16
  type: 'inline' | 'external';
@@ -65,15 +65,20 @@ function rollupPluginAstroBuildCSS(options) {
65
65
  };
66
66
  },
67
67
  async generateBundle(_outputOptions, bundle) {
68
- const appendCSSToPage = (pageData, meta, depth) => {
68
+ const appendCSSToPage = (pageData, meta, depth, order) => {
69
69
  for (const importedCssImport of meta.importedCss) {
70
70
  if (pageData == null ? void 0 : pageData.css.has(importedCssImport)) {
71
71
  const cssInfo = pageData == null ? void 0 : pageData.css.get(importedCssImport);
72
72
  if (depth < cssInfo.depth) {
73
73
  cssInfo.depth = depth;
74
74
  }
75
+ if (cssInfo.order === -1) {
76
+ cssInfo.order = order;
77
+ } else if (order < cssInfo.order && order > -1) {
78
+ cssInfo.order = order;
79
+ }
75
80
  } else {
76
- pageData == null ? void 0 : pageData.css.set(importedCssImport, { depth });
81
+ pageData == null ? void 0 : pageData.css.set(importedCssImport, { depth, order });
77
82
  }
78
83
  }
79
84
  };
@@ -101,25 +106,25 @@ function rollupPluginAstroBuildCSS(options) {
101
106
  for (const id of Object.keys(c.modules)) {
102
107
  for (const pageData of getParentClientOnlys(id, this)) {
103
108
  for (const importedCssImport of meta.importedCss) {
104
- pageData.css.set(importedCssImport, { depth: -1 });
109
+ pageData.css.set(importedCssImport, { depth: -1, order: -1 });
105
110
  }
106
111
  }
107
112
  }
108
113
  }
109
114
  for (const id of Object.keys(c.modules)) {
110
- for (const [pageInfo, depth] of walkParentInfos(id, this)) {
115
+ for (const [pageInfo, depth, order] of walkParentInfos(id, this)) {
111
116
  if (moduleIsTopLevelPage(pageInfo)) {
112
117
  const pageViteID = pageInfo.id;
113
118
  const pageData = getPageDataByViteID(internals, pageViteID);
114
119
  if (pageData) {
115
- appendCSSToPage(pageData, meta, depth);
120
+ appendCSSToPage(pageData, meta, depth, order);
116
121
  }
117
122
  } else if (options.target === "client" && isHoistedScript(internals, pageInfo.id)) {
118
123
  for (const pageData of getPageDatasByHoistedScriptId(
119
124
  internals,
120
125
  pageInfo.id
121
126
  )) {
122
- appendCSSToPage(pageData, meta, -1);
127
+ appendCSSToPage(pageData, meta, -1, order);
123
128
  }
124
129
  }
125
130
  }
@@ -143,7 +148,7 @@ function rollupPluginAstroBuildCSS(options) {
143
148
  );
144
149
  if (cssChunk) {
145
150
  for (const pageData of eachPageData(internals)) {
146
- pageData.css.set(cssChunk.fileName, { depth: -1 });
151
+ pageData.css.set(cssChunk.fileName, { depth: -1, order: -1 });
147
152
  }
148
153
  }
149
154
  }
@@ -48,7 +48,7 @@ async function dev(config, options) {
48
48
  isRestart
49
49
  })
50
50
  );
51
- const currentVersion = "1.2.2";
51
+ const currentVersion = "1.2.3";
52
52
  if (currentVersion.includes("-")) {
53
53
  warn(options.logging, null, msg.prerelease({ currentVersion }));
54
54
  }
@@ -47,7 +47,7 @@ function devStart({
47
47
  site,
48
48
  isRestart = false
49
49
  }) {
50
- const version = "1.2.2";
50
+ const version = "1.2.3";
51
51
  const rootPath = site ? site.pathname : "/";
52
52
  const localPrefix = `${dim("\u2503")} Local `;
53
53
  const networkPrefix = `${dim("\u2503")} Network `;
@@ -226,7 +226,7 @@ function printHelp({
226
226
  message.push(
227
227
  linebreak(),
228
228
  ` ${bgGreen(black(` ${commandName} `))} ${green(
229
- `v${"1.2.2"}`
229
+ `v${"1.2.3"}`
230
230
  )} ${headline}`
231
231
  );
232
232
  }
package/dist/core/util.js CHANGED
@@ -5,7 +5,7 @@ import resolve from "resolve";
5
5
  import slash from "slash";
6
6
  import { fileURLToPath, pathToFileURL } from "url";
7
7
  import { prependForwardSlash, removeTrailingForwardSlash } from "./path.js";
8
- const ASTRO_VERSION = "1.2.2";
8
+ const ASTRO_VERSION = "1.2.3";
9
9
  function isObject(value) {
10
10
  return typeof value === "object" && value != null;
11
11
  }
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "1.2.2";
1
+ const ASTRO_VERSION = "1.2.3";
2
2
  function createDeprecatedFetchContentFn() {
3
3
  return () => {
4
4
  throw new Error("Deprecated: Astro.fetchContent() has been replaced with Astro.glob().");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "1.2.2",
3
+ "version": "1.2.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",