astro 1.0.8 → 1.0.9
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/core/build/graph.js +5 -2
- package/dist/core/build/internal.js +16 -3
- package/dist/core/build/static-build.js +4 -2
- package/dist/core/build/vite-plugin-css.js +53 -15
- package/dist/core/dev/index.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/render/result.js +18 -7
- package/dist/core/util.js +1 -1
- package/dist/runtime/server/astro-global.js +1 -1
- package/dist/runtime/server/astro-island.js +5 -4
- package/dist/runtime/server/astro-island.prebuilt.js +1 -1
- package/dist/types/@types/astro.d.ts +16 -1
- package/dist/types/core/build/graph.d.ts +1 -0
- package/dist/types/core/build/internal.d.ts +2 -0
- package/dist/types/runtime/server/astro-island.prebuilt.d.ts +1 -1
- package/dist/types/vite-plugin-astro/compile.d.ts +5 -3
- package/dist/types/vite-plugin-astro/hmr.d.ts +1 -10
- package/dist/types/vite-plugin-astro/styles.d.ts +12 -10
- package/dist/vite-plugin-astro/compile.js +18 -30
- package/dist/vite-plugin-astro/hmr.js +4 -24
- package/dist/vite-plugin-astro/index.js +14 -14
- package/dist/vite-plugin-astro/styles.js +23 -18
- package/dist/vite-plugin-jsx/tag.js +16 -28
- package/dist/vite-plugin-markdown-legacy/index.js +8 -4
- package/package.json +3 -3
package/dist/core/build/graph.js
CHANGED
|
@@ -13,15 +13,18 @@ function* walkParentInfos(id, ctx, depth = 0, seen = /* @__PURE__ */ new Set())
|
|
|
13
13
|
yield* walkParentInfos(imp, ctx, ++depth, seen);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
+
function moduleIsTopLevelPage(info) {
|
|
17
|
+
return info.importers[0] === resolvedPagesVirtualModuleId;
|
|
18
|
+
}
|
|
16
19
|
function* getTopLevelPages(id, ctx) {
|
|
17
|
-
var _a;
|
|
18
20
|
for (const res of walkParentInfos(id, ctx)) {
|
|
19
|
-
if ((
|
|
21
|
+
if (moduleIsTopLevelPage(res[0])) {
|
|
20
22
|
yield res;
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
export {
|
|
25
27
|
getTopLevelPages,
|
|
28
|
+
moduleIsTopLevelPage,
|
|
26
29
|
walkParentInfos
|
|
27
30
|
};
|
|
@@ -2,9 +2,6 @@ import { prependForwardSlash } from "../path.js";
|
|
|
2
2
|
import { viteID } from "../util.js";
|
|
3
3
|
function createBuildInternals() {
|
|
4
4
|
const pureCSSChunks = /* @__PURE__ */ new Set();
|
|
5
|
-
const chunkToReferenceIdMap = /* @__PURE__ */ new Map();
|
|
6
|
-
const astroStyleMap = /* @__PURE__ */ new Map();
|
|
7
|
-
const astroPageStyleMap = /* @__PURE__ */ new Map();
|
|
8
5
|
const hoistedScriptIdToHoistedMap = /* @__PURE__ */ new Map();
|
|
9
6
|
const hoistedScriptIdToPagesMap = /* @__PURE__ */ new Map();
|
|
10
7
|
return {
|
|
@@ -88,6 +85,20 @@ function sortedCSS(pageData) {
|
|
|
88
85
|
}
|
|
89
86
|
}).map(([id]) => id);
|
|
90
87
|
}
|
|
88
|
+
function isHoistedScript(internals, id) {
|
|
89
|
+
return internals.hoistedScriptIdToPagesMap.has(id);
|
|
90
|
+
}
|
|
91
|
+
function* getPageDatasByHoistedScriptId(internals, id) {
|
|
92
|
+
const set = internals.hoistedScriptIdToPagesMap.get(id);
|
|
93
|
+
if (set) {
|
|
94
|
+
for (const pageId of set) {
|
|
95
|
+
const pageData = getPageDataByComponent(internals, pageId.slice(1));
|
|
96
|
+
if (pageData) {
|
|
97
|
+
yield pageData;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
91
102
|
export {
|
|
92
103
|
createBuildInternals,
|
|
93
104
|
eachPageData,
|
|
@@ -95,7 +106,9 @@ export {
|
|
|
95
106
|
getPageDataByViteID,
|
|
96
107
|
getPageDatasByChunk,
|
|
97
108
|
getPageDatasByClientOnlyID,
|
|
109
|
+
getPageDatasByHoistedScriptId,
|
|
98
110
|
hasPageDataByViteID,
|
|
111
|
+
isHoistedScript,
|
|
99
112
|
sortedCSS,
|
|
100
113
|
trackClientOnlyPageDatas,
|
|
101
114
|
trackPageData
|
|
@@ -122,7 +122,8 @@ async function ssrBuild(opts, internals, input) {
|
|
|
122
122
|
vitePluginAnalyzer(internals)
|
|
123
123
|
],
|
|
124
124
|
publicDir: ssr ? false : viteConfig.publicDir,
|
|
125
|
-
envPrefix: "PUBLIC_"
|
|
125
|
+
envPrefix: "PUBLIC_",
|
|
126
|
+
base: astroConfig.base
|
|
126
127
|
};
|
|
127
128
|
await runHookBuildSetup({
|
|
128
129
|
config: astroConfig,
|
|
@@ -181,7 +182,8 @@ ${bgGreen(black(" building client "))}`);
|
|
|
181
182
|
}),
|
|
182
183
|
...viteConfig.plugins || []
|
|
183
184
|
],
|
|
184
|
-
envPrefix: "PUBLIC_"
|
|
185
|
+
envPrefix: "PUBLIC_",
|
|
186
|
+
base: astroConfig.base
|
|
185
187
|
};
|
|
186
188
|
await runHookBuildSetup({
|
|
187
189
|
config: astroConfig,
|
|
@@ -3,12 +3,19 @@ import esbuild from "esbuild";
|
|
|
3
3
|
import npath from "path";
|
|
4
4
|
import { isCSSRequest } from "../render/util.js";
|
|
5
5
|
import { relativeToSrcDir } from "../util.js";
|
|
6
|
-
import { getTopLevelPages, walkParentInfos } from "./graph.js";
|
|
7
|
-
import {
|
|
6
|
+
import { getTopLevelPages, moduleIsTopLevelPage, walkParentInfos } from "./graph.js";
|
|
7
|
+
import {
|
|
8
|
+
eachPageData,
|
|
9
|
+
getPageDataByViteID,
|
|
10
|
+
getPageDatasByClientOnlyID,
|
|
11
|
+
getPageDatasByHoistedScriptId,
|
|
12
|
+
isHoistedScript
|
|
13
|
+
} from "./internal.js";
|
|
8
14
|
const MAX_NAME_LENGTH = 70;
|
|
9
15
|
function rollupPluginAstroBuildCSS(options) {
|
|
10
16
|
const { internals, buildOptions } = options;
|
|
11
17
|
const { astroConfig } = buildOptions;
|
|
18
|
+
let resolvedConfig;
|
|
12
19
|
function nameifyPage(id) {
|
|
13
20
|
let rel = relativeToSrcDir(astroConfig, id);
|
|
14
21
|
if (rel.startsWith("pages/")) {
|
|
@@ -58,13 +65,24 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
58
65
|
};
|
|
59
66
|
},
|
|
60
67
|
async generateBundle(_outputOptions, bundle) {
|
|
68
|
+
const appendCSSToPage = (pageData, meta, depth) => {
|
|
69
|
+
for (const importedCssImport of meta.importedCss) {
|
|
70
|
+
if (pageData == null ? void 0 : pageData.css.has(importedCssImport)) {
|
|
71
|
+
const cssInfo = pageData == null ? void 0 : pageData.css.get(importedCssImport);
|
|
72
|
+
if (depth < cssInfo.depth) {
|
|
73
|
+
cssInfo.depth = depth;
|
|
74
|
+
}
|
|
75
|
+
} else {
|
|
76
|
+
pageData == null ? void 0 : pageData.css.set(importedCssImport, { depth });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
61
80
|
for (const [_, chunk] of Object.entries(bundle)) {
|
|
62
81
|
if (chunk.type === "chunk") {
|
|
63
82
|
const c = chunk;
|
|
64
83
|
if ("viteMetadata" in chunk) {
|
|
65
84
|
const meta = chunk["viteMetadata"];
|
|
66
85
|
if (meta.importedCss.size) {
|
|
67
|
-
debugger;
|
|
68
86
|
if (options.target === "client") {
|
|
69
87
|
for (const [id] of Object.entries(c.modules)) {
|
|
70
88
|
for (const pageData of getParentClientOnlys(id, this)) {
|
|
@@ -75,18 +93,19 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
75
93
|
}
|
|
76
94
|
}
|
|
77
95
|
for (const [id] of Object.entries(c.modules)) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
96
|
+
for (const [pageInfo, depth] of walkParentInfos(id, this)) {
|
|
97
|
+
if (moduleIsTopLevelPage(pageInfo)) {
|
|
98
|
+
const pageViteID = pageInfo.id;
|
|
99
|
+
const pageData = getPageDataByViteID(internals, pageViteID);
|
|
100
|
+
if (pageData) {
|
|
101
|
+
appendCSSToPage(pageData, meta, depth);
|
|
102
|
+
}
|
|
103
|
+
} else if (options.target === "client" && isHoistedScript(internals, pageInfo.id)) {
|
|
104
|
+
for (const pageData of getPageDatasByHoistedScriptId(
|
|
105
|
+
internals,
|
|
106
|
+
pageInfo.id
|
|
107
|
+
)) {
|
|
108
|
+
appendCSSToPage(pageData, meta, -1);
|
|
90
109
|
}
|
|
91
110
|
}
|
|
92
111
|
}
|
|
@@ -97,6 +116,25 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
97
116
|
}
|
|
98
117
|
}
|
|
99
118
|
},
|
|
119
|
+
{
|
|
120
|
+
name: "astro:rollup-plugin-single-css",
|
|
121
|
+
enforce: "post",
|
|
122
|
+
configResolved(config) {
|
|
123
|
+
resolvedConfig = config;
|
|
124
|
+
},
|
|
125
|
+
generateBundle(_, bundle) {
|
|
126
|
+
if (!resolvedConfig.build.cssCodeSplit) {
|
|
127
|
+
const cssChunk = Object.values(bundle).find(
|
|
128
|
+
(chunk) => chunk.type === "asset" && chunk.name === "style.css"
|
|
129
|
+
);
|
|
130
|
+
if (cssChunk) {
|
|
131
|
+
for (const pageData of eachPageData(internals)) {
|
|
132
|
+
pageData.css.set(cssChunk.fileName, { depth: -1 });
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
},
|
|
100
138
|
{
|
|
101
139
|
name: "astro:rollup-plugin-build-css-minify",
|
|
102
140
|
enforce: "post",
|
package/dist/core/dev/index.js
CHANGED
|
@@ -46,7 +46,7 @@ async function dev(config, options) {
|
|
|
46
46
|
https: !!((_a = viteConfig.server) == null ? void 0 : _a.https)
|
|
47
47
|
})
|
|
48
48
|
);
|
|
49
|
-
const currentVersion = "1.0.
|
|
49
|
+
const currentVersion = "1.0.9";
|
|
50
50
|
if (currentVersion.includes("-")) {
|
|
51
51
|
warn(options.logging, null, msg.prerelease({ currentVersion }));
|
|
52
52
|
}
|
package/dist/core/messages.js
CHANGED
|
@@ -46,7 +46,7 @@ function devStart({
|
|
|
46
46
|
https,
|
|
47
47
|
site
|
|
48
48
|
}) {
|
|
49
|
-
const version = "1.0.
|
|
49
|
+
const version = "1.0.9";
|
|
50
50
|
const rootPath = site ? site.pathname : "/";
|
|
51
51
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
52
52
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
@@ -225,7 +225,7 @@ function printHelp({
|
|
|
225
225
|
message.push(
|
|
226
226
|
linebreak(),
|
|
227
227
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
228
|
-
`v${"1.0.
|
|
228
|
+
`v${"1.0.9"}`
|
|
229
229
|
)} ${headline}`
|
|
230
230
|
);
|
|
231
231
|
}
|
|
@@ -16,7 +16,7 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
16
16
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
17
17
|
return value;
|
|
18
18
|
};
|
|
19
|
-
var _cache, _result, _slots;
|
|
19
|
+
var _cache, _result, _slots, _loggingOpts;
|
|
20
20
|
import { bold } from "kleur/colors";
|
|
21
21
|
import { renderSlot } from "../../runtime/server/index.js";
|
|
22
22
|
import { warn } from "../logger/core.js";
|
|
@@ -37,12 +37,14 @@ function getFunctionExpression(slot) {
|
|
|
37
37
|
return slot.expressions[0];
|
|
38
38
|
}
|
|
39
39
|
class Slots {
|
|
40
|
-
constructor(result, slots) {
|
|
40
|
+
constructor(result, slots, logging) {
|
|
41
41
|
__privateAdd(this, _cache, /* @__PURE__ */ new Map());
|
|
42
42
|
__privateAdd(this, _result, void 0);
|
|
43
43
|
__privateAdd(this, _slots, void 0);
|
|
44
|
+
__privateAdd(this, _loggingOpts, void 0);
|
|
44
45
|
__privateSet(this, _result, result);
|
|
45
46
|
__privateSet(this, _slots, slots);
|
|
47
|
+
__privateSet(this, _loggingOpts, logging);
|
|
46
48
|
if (slots) {
|
|
47
49
|
for (const key of Object.keys(slots)) {
|
|
48
50
|
if (this[key] !== void 0) {
|
|
@@ -78,11 +80,19 @@ Please update the name of this slot.`
|
|
|
78
80
|
if (!cacheable) {
|
|
79
81
|
const component = await __privateGet(this, _slots)[name]();
|
|
80
82
|
const expression = getFunctionExpression(component);
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
if (!Array.isArray(args)) {
|
|
84
|
+
warn(
|
|
85
|
+
__privateGet(this, _loggingOpts),
|
|
86
|
+
"Astro.slots.render",
|
|
87
|
+
`Expected second parameter to be an array, received a ${typeof args}. If you're trying to pass an array as a single argument and getting unexpected results, make sure you're passing your array as a item of an array. Ex: Astro.slots.render('default', [["Hello", "World"]])`
|
|
85
88
|
);
|
|
89
|
+
} else {
|
|
90
|
+
if (expression) {
|
|
91
|
+
const slot = expression(...args);
|
|
92
|
+
return await renderSlot(__privateGet(this, _result), slot).then(
|
|
93
|
+
(res) => res != null ? String(res) : res
|
|
94
|
+
);
|
|
95
|
+
}
|
|
86
96
|
}
|
|
87
97
|
}
|
|
88
98
|
const content = await renderSlot(__privateGet(this, _result), __privateGet(this, _slots)[name]).then(
|
|
@@ -96,6 +106,7 @@ Please update the name of this slot.`
|
|
|
96
106
|
_cache = new WeakMap();
|
|
97
107
|
_result = new WeakMap();
|
|
98
108
|
_slots = new WeakMap();
|
|
109
|
+
_loggingOpts = new WeakMap();
|
|
99
110
|
let renderMarkdown = null;
|
|
100
111
|
function createResult(args) {
|
|
101
112
|
const { markdown, params, pathname, props: pageProps, renderers, request, resolve } = args;
|
|
@@ -122,7 +133,7 @@ function createResult(args) {
|
|
|
122
133
|
scripts: args.scripts ?? /* @__PURE__ */ new Set(),
|
|
123
134
|
links: args.links ?? /* @__PURE__ */ new Set(),
|
|
124
135
|
createAstro(astroGlobal, props, slots) {
|
|
125
|
-
const astroSlots = new Slots(result, slots);
|
|
136
|
+
const astroSlots = new Slots(result, slots, args.logging);
|
|
126
137
|
const Astro = {
|
|
127
138
|
__proto__: astroGlobal,
|
|
128
139
|
get clientAddress() {
|
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.0.
|
|
8
|
+
const ASTRO_VERSION = "1.0.9";
|
|
9
9
|
function isObject(value) {
|
|
10
10
|
return typeof value === "object" && value != null;
|
|
11
11
|
}
|
|
@@ -23,21 +23,22 @@ var _a;
|
|
|
23
23
|
constructor() {
|
|
24
24
|
super(...arguments);
|
|
25
25
|
this.hydrate = () => {
|
|
26
|
-
|
|
27
|
-
if (!this.hydrator || ((_a2 = this.parentElement) == null ? void 0 : _a2.closest("astro-island[ssr]"))) {
|
|
26
|
+
if (!this.hydrator || this.parentElement && this.parentElement.closest("astro-island[ssr]")) {
|
|
28
27
|
return;
|
|
29
28
|
}
|
|
30
29
|
const slotted = this.querySelectorAll("astro-slot");
|
|
31
30
|
const slots = {};
|
|
32
31
|
const templates = this.querySelectorAll("template[data-astro-template]");
|
|
33
32
|
for (const template of templates) {
|
|
34
|
-
|
|
33
|
+
const closest = template.closest(this.tagName);
|
|
34
|
+
if (!closest || !closest.isSameNode(this))
|
|
35
35
|
continue;
|
|
36
36
|
slots[template.getAttribute("data-astro-template") || "default"] = template.innerHTML;
|
|
37
37
|
template.remove();
|
|
38
38
|
}
|
|
39
39
|
for (const slot of slotted) {
|
|
40
|
-
|
|
40
|
+
const closest = slot.closest(this.tagName);
|
|
41
|
+
if (!closest || !closest.isSameNode(this))
|
|
41
42
|
continue;
|
|
42
43
|
slots[slot.getAttribute("name") || "default"] = slot.innerHTML;
|
|
43
44
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var astro_island_prebuilt_default = `var
|
|
1
|
+
var astro_island_prebuilt_default = `var l;{const c={0:t=>t,1:t=>JSON.parse(t,o),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,o)),5:t=>new Set(JSON.parse(t,o)),6:t=>BigInt(t),7:t=>new URL(t)},o=(t,i)=>{if(t===""||!Array.isArray(i))return i;const[e,n]=i;return e in c?c[e](n):void 0};customElements.get("astro-island")||customElements.define("astro-island",(l=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=()=>{if(!this.hydrator||this.parentElement&&this.parentElement.closest("astro-island[ssr]"))return;const i=this.querySelectorAll("astro-slot"),e={},n=this.querySelectorAll("template[data-astro-template]");for(const s of n){const r=s.closest(this.tagName);!r||!r.isSameNode(this)||(e[s.getAttribute("data-astro-template")||"default"]=s.innerHTML,s.remove())}for(const s of i){const r=s.closest(this.tagName);!r||!r.isSameNode(this)||(e[s.getAttribute("name")||"default"]=s.innerHTML)}const a=this.hasAttribute("props")?JSON.parse(this.getAttribute("props"),o):{};this.hydrator(this)(this.Component,a,e,{client:this.getAttribute("client")}),this.removeAttribute("ssr"),window.removeEventListener("astro:hydrate",this.hydrate),window.dispatchEvent(new CustomEvent("astro:hydrate"))}}connectedCallback(){!this.hasAttribute("await-children")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((i,e)=>{e.disconnect(),this.childrenConnectedCallback()}).observe(this,{childList:!0})}async childrenConnectedCallback(){window.addEventListener("astro:hydrate",this.hydrate),await import(this.getAttribute("before-hydration-url")),this.start()}start(){const i=JSON.parse(this.getAttribute("opts")),e=this.getAttribute("client");if(Astro[e]===void 0){window.addEventListener(\`astro:\${e}\`,()=>this.start(),{once:!0});return}Astro[e](async()=>{const n=this.getAttribute("renderer-url"),[a,{default:s}]=await Promise.all([import(this.getAttribute("component-url")),n?import(n):()=>()=>{}]),r=this.getAttribute("component-export")||"default";if(!r.includes("."))this.Component=a[r];else{this.Component=a;for(const d of r.split("."))this.Component=this.Component[d]}return this.hydrator=s,this.hydrate},i,this)}attributeChangedCallback(){this.hydrator&&this.hydrate()}},l.observedAttributes=["props"],l))}`;
|
|
2
2
|
export {
|
|
3
3
|
astro_island_prebuilt_default as default
|
|
4
4
|
};
|
|
@@ -179,7 +179,7 @@ export interface AstroGlobal extends AstroGlobalPartial {
|
|
|
179
179
|
*/
|
|
180
180
|
has(slotName: string): boolean;
|
|
181
181
|
/**
|
|
182
|
-
*
|
|
182
|
+
* Asynchronously renders this slot and returns a string
|
|
183
183
|
*
|
|
184
184
|
* Example usage:
|
|
185
185
|
* ```astro
|
|
@@ -192,6 +192,21 @@ export interface AstroGlobal extends AstroGlobalPartial {
|
|
|
192
192
|
* <Fragment set:html={html} />
|
|
193
193
|
* ```
|
|
194
194
|
*
|
|
195
|
+
* A second parameters can be used to pass arguments to a slotted callback
|
|
196
|
+
*
|
|
197
|
+
* Example usage:
|
|
198
|
+
* ```astro
|
|
199
|
+
* ---
|
|
200
|
+
* html = await Astro.slots.render('default', ["Hello", "World"])
|
|
201
|
+
* ---
|
|
202
|
+
* ```
|
|
203
|
+
* Each item in the array will be passed as an argument that you can use like so:
|
|
204
|
+
* ```astro
|
|
205
|
+
* <Component>
|
|
206
|
+
* {(hello, world) => <div>{hello}, {world}!</div>}
|
|
207
|
+
* </Component>
|
|
208
|
+
* ```
|
|
209
|
+
*
|
|
195
210
|
* [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots)
|
|
196
211
|
*/
|
|
197
212
|
render(slotName: string, args?: any[]): Promise<string>;
|
|
@@ -2,6 +2,7 @@ import type { GetModuleInfo, ModuleInfo } from 'rollup';
|
|
|
2
2
|
export declare function walkParentInfos(id: string, ctx: {
|
|
3
3
|
getModuleInfo: GetModuleInfo;
|
|
4
4
|
}, depth?: number, seen?: Set<string>): Generator<[ModuleInfo, number], void, unknown>;
|
|
5
|
+
export declare function moduleIsTopLevelPage(info: ModuleInfo): boolean;
|
|
5
6
|
export declare function getTopLevelPages(id: string, ctx: {
|
|
6
7
|
getModuleInfo: GetModuleInfo;
|
|
7
8
|
}): Generator<[ModuleInfo, number], void, unknown>;
|
|
@@ -58,3 +58,5 @@ export declare function eachPageData(internals: BuildInternals): Generator<PageB
|
|
|
58
58
|
* and page-level CSS on bottom.
|
|
59
59
|
*/
|
|
60
60
|
export declare function sortedCSS(pageData: PageBuildData): string[];
|
|
61
|
+
export declare function isHoistedScript(internals: BuildInternals, id: string): boolean;
|
|
62
|
+
export declare function getPageDatasByHoistedScriptId(internals: BuildInternals, id: string): Generator<PageBuildData, void, unknown>;
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* Do not edit this directly, but instead edit that file and rerun the prebuild
|
|
4
4
|
* to generate this file.
|
|
5
5
|
*/
|
|
6
|
-
declare const _default: "var
|
|
6
|
+
declare const _default: "var l;{const c={0:t=>t,1:t=>JSON.parse(t,o),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,o)),5:t=>new Set(JSON.parse(t,o)),6:t=>BigInt(t),7:t=>new URL(t)},o=(t,i)=>{if(t===\"\"||!Array.isArray(i))return i;const[e,n]=i;return e in c?c[e](n):void 0};customElements.get(\"astro-island\")||customElements.define(\"astro-island\",(l=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=()=>{if(!this.hydrator||this.parentElement&&this.parentElement.closest(\"astro-island[ssr]\"))return;const i=this.querySelectorAll(\"astro-slot\"),e={},n=this.querySelectorAll(\"template[data-astro-template]\");for(const s of n){const r=s.closest(this.tagName);!r||!r.isSameNode(this)||(e[s.getAttribute(\"data-astro-template\")||\"default\"]=s.innerHTML,s.remove())}for(const s of i){const r=s.closest(this.tagName);!r||!r.isSameNode(this)||(e[s.getAttribute(\"name\")||\"default\"]=s.innerHTML)}const a=this.hasAttribute(\"props\")?JSON.parse(this.getAttribute(\"props\"),o):{};this.hydrator(this)(this.Component,a,e,{client:this.getAttribute(\"client\")}),this.removeAttribute(\"ssr\"),window.removeEventListener(\"astro:hydrate\",this.hydrate),window.dispatchEvent(new CustomEvent(\"astro:hydrate\"))}}connectedCallback(){!this.hasAttribute(\"await-children\")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((i,e)=>{e.disconnect(),this.childrenConnectedCallback()}).observe(this,{childList:!0})}async childrenConnectedCallback(){window.addEventListener(\"astro:hydrate\",this.hydrate),await import(this.getAttribute(\"before-hydration-url\")),this.start()}start(){const i=JSON.parse(this.getAttribute(\"opts\")),e=this.getAttribute(\"client\");if(Astro[e]===void 0){window.addEventListener(`astro:${e}`,()=>this.start(),{once:!0});return}Astro[e](async()=>{const n=this.getAttribute(\"renderer-url\"),[a,{default:s}]=await Promise.all([import(this.getAttribute(\"component-url\")),n?import(n):()=>()=>{}]),r=this.getAttribute(\"component-export\")||\"default\";if(!r.includes(\".\"))this.Component=a[r];else{this.Component=a;for(const d of r.split(\".\"))this.Component=this.Component[d]}return this.hydrator=s,this.hydrate},i,this)}attributeChangedCallback(){this.hydrator&&this.hydrate()}},l.observedAttributes=[\"props\"],l))}";
|
|
7
7
|
export default _default;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { TransformResult } from '@astrojs/compiler';
|
|
2
2
|
import type { PluginContext } from 'rollup';
|
|
3
|
+
import type { ViteDevServer } from 'vite';
|
|
3
4
|
import type { AstroConfig } from '../@types/astro';
|
|
4
|
-
import type {
|
|
5
|
+
import type { TransformStyleWithVite } from './styles';
|
|
5
6
|
declare type CompileResult = TransformResult & {
|
|
6
|
-
|
|
7
|
+
cssDeps: Set<string>;
|
|
7
8
|
source: string;
|
|
8
9
|
};
|
|
9
10
|
export interface CompileProps {
|
|
@@ -12,7 +13,8 @@ export interface CompileProps {
|
|
|
12
13
|
moduleId: string;
|
|
13
14
|
source: string;
|
|
14
15
|
ssr: boolean;
|
|
15
|
-
|
|
16
|
+
transformStyleWithVite: TransformStyleWithVite;
|
|
17
|
+
viteDevServer?: ViteDevServer;
|
|
16
18
|
pluginContext: PluginContext;
|
|
17
19
|
}
|
|
18
20
|
export declare function isCached(config: AstroConfig, filename: string): boolean;
|
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { HmrContext, ModuleNode, ViteDevServer } from 'vite';
|
|
1
|
+
import type { HmrContext, ModuleNode } from 'vite';
|
|
3
2
|
import type { AstroConfig } from '../@types/astro';
|
|
4
3
|
import type { LogOptions } from '../core/logger/core.js';
|
|
5
4
|
import { cachedCompilation } from './compile.js';
|
|
6
|
-
interface TrackCSSDependenciesOptions {
|
|
7
|
-
viteDevServer: ViteDevServer | null;
|
|
8
|
-
filename: string;
|
|
9
|
-
id: string;
|
|
10
|
-
deps: Set<string>;
|
|
11
|
-
}
|
|
12
|
-
export declare function trackCSSDependencies(this: RollupPluginContext, opts: TrackCSSDependenciesOptions): Promise<void>;
|
|
13
5
|
export interface HandleHotUpdateOptions {
|
|
14
6
|
config: AstroConfig;
|
|
15
7
|
logging: LogOptions;
|
|
16
8
|
compile: () => ReturnType<typeof cachedCompilation>;
|
|
17
9
|
}
|
|
18
10
|
export declare function handleHotUpdate(ctx: HmrContext, { config, logging, compile }: HandleHotUpdateOptions): Promise<ModuleNode[] | undefined>;
|
|
19
|
-
export {};
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import type { PluginContext } from 'rollup';
|
|
2
1
|
import type * as vite from 'vite';
|
|
3
2
|
export declare type TransformHook = (code: string, id: string, ssr?: boolean) => Promise<vite.TransformResult>;
|
|
4
|
-
|
|
5
|
-
export declare function getViteTransform(viteConfig: vite.ResolvedConfig): TransformHook;
|
|
6
|
-
interface TransformWithViteOptions {
|
|
7
|
-
value: string;
|
|
8
|
-
lang: string;
|
|
3
|
+
interface TransformStyleWithViteOptions {
|
|
9
4
|
id: string;
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
source: string;
|
|
6
|
+
lang: string;
|
|
12
7
|
ssr?: boolean;
|
|
8
|
+
viteDevServer?: vite.ViteDevServer;
|
|
9
|
+
}
|
|
10
|
+
export interface TransformStyleWithVite {
|
|
11
|
+
(options: TransformStyleWithViteOptions): Promise<{
|
|
12
|
+
code: string;
|
|
13
|
+
map: vite.TransformResult['map'];
|
|
14
|
+
deps: Set<string>;
|
|
15
|
+
} | null>;
|
|
13
16
|
}
|
|
14
|
-
|
|
15
|
-
export declare function transformWithVite({ value, lang, transformHook, id, ssr, pluginContext, }: TransformWithViteOptions): Promise<vite.TransformResult | null>;
|
|
17
|
+
export declare function createTransformStyleWithViteFn(viteConfig: vite.ResolvedConfig): TransformStyleWithVite;
|
|
16
18
|
export {};
|
|
@@ -3,13 +3,6 @@ import { fileURLToPath } from "url";
|
|
|
3
3
|
import { AstroErrorCodes } from "../core/errors.js";
|
|
4
4
|
import { prependForwardSlash } from "../core/path.js";
|
|
5
5
|
import { viteID } from "../core/util.js";
|
|
6
|
-
import { transformWithVite } from "./styles.js";
|
|
7
|
-
function createImportPlaceholder(spec) {
|
|
8
|
-
return `/*IMPORT:${spec}*/`;
|
|
9
|
-
}
|
|
10
|
-
function safelyReplaceImportPlaceholder(code) {
|
|
11
|
-
return code.replace(/\/\*IMPORT\:(.*?)\*\//g, `@import '$1';`);
|
|
12
|
-
}
|
|
13
6
|
const configCache = /* @__PURE__ */ new WeakMap();
|
|
14
7
|
function getNormalizedID(filename) {
|
|
15
8
|
try {
|
|
@@ -25,13 +18,18 @@ async function compile({
|
|
|
25
18
|
moduleId,
|
|
26
19
|
source,
|
|
27
20
|
ssr,
|
|
28
|
-
|
|
21
|
+
transformStyleWithVite,
|
|
22
|
+
viteDevServer,
|
|
29
23
|
pluginContext
|
|
30
24
|
}) {
|
|
31
25
|
var _a;
|
|
32
26
|
const normalizedID = getNormalizedID(filename);
|
|
33
|
-
let
|
|
27
|
+
let cssDeps = /* @__PURE__ */ new Set();
|
|
34
28
|
let cssTransformError;
|
|
29
|
+
if (!pluginContext.addWatchFile) {
|
|
30
|
+
pluginContext.addWatchFile = () => {
|
|
31
|
+
};
|
|
32
|
+
}
|
|
35
33
|
const transformResult = await transform(source, {
|
|
36
34
|
pathname: `/@fs${prependForwardSlash(moduleId)}`,
|
|
37
35
|
projectRoot: config.root.toString(),
|
|
@@ -45,28 +43,19 @@ async function compile({
|
|
|
45
43
|
preprocessStyle: async (value, attrs) => {
|
|
46
44
|
const lang = `.${(attrs == null ? void 0 : attrs.lang) || "css"}`.toLowerCase();
|
|
47
45
|
try {
|
|
48
|
-
|
|
49
|
-
/(?:@import)\s(?:url\()?\s?["\'](.*?)["\']\s?\)?(?:[^;]*);?/gi,
|
|
50
|
-
(match, spec) => {
|
|
51
|
-
rawCSSDeps.add(spec);
|
|
52
|
-
if (lang === ".css") {
|
|
53
|
-
return createImportPlaceholder(spec);
|
|
54
|
-
} else {
|
|
55
|
-
return match;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
);
|
|
59
|
-
const result = await transformWithVite({
|
|
60
|
-
value,
|
|
61
|
-
lang,
|
|
46
|
+
const result = await transformStyleWithVite.call(pluginContext, {
|
|
62
47
|
id: normalizedID,
|
|
63
|
-
|
|
48
|
+
source: value,
|
|
49
|
+
lang,
|
|
64
50
|
ssr,
|
|
65
|
-
|
|
51
|
+
viteDevServer
|
|
66
52
|
});
|
|
67
|
-
let map;
|
|
68
53
|
if (!result)
|
|
69
54
|
return null;
|
|
55
|
+
for (const dep of result.deps) {
|
|
56
|
+
cssDeps.add(dep);
|
|
57
|
+
}
|
|
58
|
+
let map;
|
|
70
59
|
if (result.map) {
|
|
71
60
|
if (typeof result.map === "string") {
|
|
72
61
|
map = result.map;
|
|
@@ -74,8 +63,7 @@ async function compile({
|
|
|
74
63
|
map = result.map.toString();
|
|
75
64
|
}
|
|
76
65
|
}
|
|
77
|
-
|
|
78
|
-
return { code, map };
|
|
66
|
+
return { code: result.code, map };
|
|
79
67
|
} catch (err) {
|
|
80
68
|
cssTransformError = err;
|
|
81
69
|
return null;
|
|
@@ -92,8 +80,8 @@ async function compile({
|
|
|
92
80
|
return result;
|
|
93
81
|
});
|
|
94
82
|
const compileResult = Object.create(transformResult, {
|
|
95
|
-
|
|
96
|
-
value:
|
|
83
|
+
cssDeps: {
|
|
84
|
+
value: cssDeps
|
|
97
85
|
},
|
|
98
86
|
source: {
|
|
99
87
|
value: source
|
|
@@ -3,28 +3,6 @@ import { info } from "../core/logger/core.js";
|
|
|
3
3
|
import * as msg from "../core/messages.js";
|
|
4
4
|
import { invalidateCompilation, isCached } from "./compile.js";
|
|
5
5
|
import { isAstroScript } from "./query.js";
|
|
6
|
-
async function trackCSSDependencies(opts) {
|
|
7
|
-
const { viteDevServer, filename, deps, id } = opts;
|
|
8
|
-
if (viteDevServer) {
|
|
9
|
-
const mod = viteDevServer.moduleGraph.getModuleById(id);
|
|
10
|
-
if (mod) {
|
|
11
|
-
const cssDeps = (await Promise.all(
|
|
12
|
-
Array.from(deps).map((spec) => {
|
|
13
|
-
return this.resolve(spec, id);
|
|
14
|
-
})
|
|
15
|
-
)).filter(Boolean).map((dep) => dep.id);
|
|
16
|
-
const { moduleGraph } = viteDevServer;
|
|
17
|
-
const depModules = new Set(mod.importedModules);
|
|
18
|
-
for (const dep of cssDeps) {
|
|
19
|
-
depModules.add(moduleGraph.createFileOnlyEntry(dep));
|
|
20
|
-
}
|
|
21
|
-
moduleGraph.updateModuleInfo(mod, depModules, /* @__PURE__ */ new Map(), /* @__PURE__ */ new Set(), /* @__PURE__ */ new Set(), true);
|
|
22
|
-
for (const dep of cssDeps) {
|
|
23
|
-
this.addWatchFile(dep);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
6
|
const PKG_PREFIX = new URL("../../", import.meta.url);
|
|
29
7
|
const isPkgFile = (id) => {
|
|
30
8
|
return (id == null ? void 0 : id.startsWith(fileURLToPath(PKG_PREFIX))) || (id == null ? void 0 : id.startsWith(PKG_PREFIX.pathname));
|
|
@@ -75,6 +53,9 @@ async function handleHotUpdate(ctx, { config, logging, compile }) {
|
|
|
75
53
|
if (isStyleOnlyChange && file2 === ctx.file)
|
|
76
54
|
continue;
|
|
77
55
|
invalidateCompilation(config, file2);
|
|
56
|
+
if (file2.endsWith(".astro")) {
|
|
57
|
+
ctx.server.moduleGraph.onFileChange(file2);
|
|
58
|
+
}
|
|
78
59
|
}
|
|
79
60
|
const mods = ctx.modules.filter((m) => !m.url.endsWith("="));
|
|
80
61
|
const file = ctx.file.replace(config.root.pathname, "/");
|
|
@@ -109,6 +90,5 @@ async function handleHotUpdate(ctx, { config, logging, compile }) {
|
|
|
109
90
|
return mods;
|
|
110
91
|
}
|
|
111
92
|
export {
|
|
112
|
-
handleHotUpdate
|
|
113
|
-
trackCSSDependencies
|
|
93
|
+
handleHotUpdate
|
|
114
94
|
};
|
|
@@ -5,9 +5,9 @@ import { fileURLToPath } from "url";
|
|
|
5
5
|
import { isRelativePath, startsWithForwardSlash } from "../core/path.js";
|
|
6
6
|
import { getFileInfo } from "../vite-plugin-utils/index.js";
|
|
7
7
|
import { cachedCompilation, getCachedSource } from "./compile.js";
|
|
8
|
-
import { handleHotUpdate
|
|
8
|
+
import { handleHotUpdate } from "./hmr.js";
|
|
9
9
|
import { parseAstroRequest } from "./query.js";
|
|
10
|
-
import {
|
|
10
|
+
import { createTransformStyleWithViteFn } from "./styles.js";
|
|
11
11
|
const FRONTMATTER_PARSE_REGEXP = /^\-\-\-(.*)^\-\-\-/ms;
|
|
12
12
|
function astro({ config, logging }) {
|
|
13
13
|
function normalizeFilename(filename) {
|
|
@@ -24,8 +24,8 @@ function astro({ config, logging }) {
|
|
|
24
24
|
return slash(fileURLToPath(url)) + url.search;
|
|
25
25
|
}
|
|
26
26
|
let resolvedConfig;
|
|
27
|
-
let
|
|
28
|
-
let viteDevServer
|
|
27
|
+
let transformStyleWithVite;
|
|
28
|
+
let viteDevServer;
|
|
29
29
|
const srcRootWeb = config.srcDir.pathname.slice(config.root.pathname.length - 1);
|
|
30
30
|
const isBrowserPath = (path) => path.startsWith(srcRootWeb);
|
|
31
31
|
function resolveRelativeFromAstroParent(id, parsedFrom) {
|
|
@@ -42,7 +42,7 @@ function astro({ config, logging }) {
|
|
|
42
42
|
enforce: "pre",
|
|
43
43
|
configResolved(_resolvedConfig) {
|
|
44
44
|
resolvedConfig = _resolvedConfig;
|
|
45
|
-
|
|
45
|
+
transformStyleWithVite = createTransformStyleWithViteFn(_resolvedConfig);
|
|
46
46
|
},
|
|
47
47
|
configureServer(server) {
|
|
48
48
|
viteDevServer = server;
|
|
@@ -87,7 +87,8 @@ function astro({ config, logging }) {
|
|
|
87
87
|
moduleId: id,
|
|
88
88
|
source,
|
|
89
89
|
ssr: Boolean(opts == null ? void 0 : opts.ssr),
|
|
90
|
-
|
|
90
|
+
transformStyleWithVite,
|
|
91
|
+
viteDevServer,
|
|
91
92
|
pluginContext: this
|
|
92
93
|
};
|
|
93
94
|
switch (query.type) {
|
|
@@ -96,12 +97,6 @@ function astro({ config, logging }) {
|
|
|
96
97
|
throw new Error(`Requests for Astro CSS must include an index.`);
|
|
97
98
|
}
|
|
98
99
|
const transformResult = await cachedCompilation(compileProps);
|
|
99
|
-
await trackCSSDependencies.call(this, {
|
|
100
|
-
viteDevServer,
|
|
101
|
-
id,
|
|
102
|
-
filename,
|
|
103
|
-
deps: transformResult.rawCSSDeps
|
|
104
|
-
});
|
|
105
100
|
const csses = transformResult.css;
|
|
106
101
|
const code = csses[query.index];
|
|
107
102
|
return {
|
|
@@ -184,12 +179,16 @@ File: ${filename}`
|
|
|
184
179
|
moduleId: id,
|
|
185
180
|
source,
|
|
186
181
|
ssr: Boolean(opts == null ? void 0 : opts.ssr),
|
|
187
|
-
|
|
182
|
+
transformStyleWithVite,
|
|
183
|
+
viteDevServer,
|
|
188
184
|
pluginContext: this
|
|
189
185
|
};
|
|
190
186
|
try {
|
|
191
187
|
const transformResult = await cachedCompilation(compileProps);
|
|
192
188
|
const { fileId: file, fileUrl: url } = getFileInfo(id, config);
|
|
189
|
+
for (const dep of transformResult.cssDeps) {
|
|
190
|
+
this.addWatchFile(dep);
|
|
191
|
+
}
|
|
193
192
|
const { code, map } = await esbuild.transform(transformResult.code, {
|
|
194
193
|
loader: "ts",
|
|
195
194
|
sourcemap: "external",
|
|
@@ -290,7 +289,8 @@ ${source}
|
|
|
290
289
|
moduleId: context.file,
|
|
291
290
|
source: await context.read(),
|
|
292
291
|
ssr: true,
|
|
293
|
-
|
|
292
|
+
transformStyleWithVite,
|
|
293
|
+
viteDevServer,
|
|
294
294
|
pluginContext: this
|
|
295
295
|
};
|
|
296
296
|
const compile = () => cachedCompilation(compileProps);
|
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
import { STYLE_EXTENSIONS } from "../core/render/util.js";
|
|
2
|
-
function
|
|
2
|
+
function createTransformStyleWithViteFn(viteConfig) {
|
|
3
3
|
const viteCSSPlugin = viteConfig.plugins.find(({ name }) => name === "vite:css");
|
|
4
4
|
if (!viteCSSPlugin)
|
|
5
|
-
throw new Error(`vite:css plugin couldn
|
|
5
|
+
throw new Error(`vite:css plugin couldn't be found`);
|
|
6
6
|
if (!viteCSSPlugin.transform)
|
|
7
7
|
throw new Error(`vite:css has no transform() hook`);
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
const transformCss = viteCSSPlugin.transform;
|
|
9
|
+
return async function({ id, source, lang, ssr, viteDevServer }) {
|
|
10
|
+
if (!STYLE_EXTENSIONS.has(lang)) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const styleId = `${id}?astro&type=style&lang${lang}`;
|
|
14
|
+
viteDevServer == null ? void 0 : viteDevServer.moduleGraph.ensureEntryFromUrl(styleId, ssr, false);
|
|
15
|
+
const transformResult = await transformCss.call(this, source, styleId, ssr);
|
|
16
|
+
const { code, map } = transformResult;
|
|
17
|
+
const deps = /* @__PURE__ */ new Set();
|
|
18
|
+
const mod = viteDevServer == null ? void 0 : viteDevServer.moduleGraph.getModuleById(styleId);
|
|
19
|
+
if (mod) {
|
|
20
|
+
for (const imported of mod.importedModules) {
|
|
21
|
+
if (imported.file) {
|
|
22
|
+
deps.add(imported.file);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return { code, map, deps };
|
|
27
|
+
};
|
|
22
28
|
}
|
|
23
29
|
export {
|
|
24
|
-
|
|
25
|
-
transformWithVite
|
|
30
|
+
createTransformStyleWithViteFn
|
|
26
31
|
};
|
|
@@ -37,39 +37,27 @@ function tagExportsWithRenderer({
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
ExportDeclaration(path, state) {
|
|
40
|
-
var _a, _b
|
|
40
|
+
var _a, _b;
|
|
41
41
|
const node = path.node;
|
|
42
42
|
if (node.exportKind === "type")
|
|
43
43
|
return;
|
|
44
44
|
if (node.type === "ExportAllDeclaration")
|
|
45
45
|
return;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
(_b = node.declaration.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
} else if (t.isObjectExpression(node.declaration)) {
|
|
62
|
-
(_c = node.declaration.properties) == null ? void 0 : _c.forEach((property) => {
|
|
63
|
-
if (t.isProperty(property) && t.isIdentifier(property.key)) {
|
|
64
|
-
addTag(property.key.name);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
} else if (t.isExportNamedDeclaration(node)) {
|
|
68
|
-
node.specifiers.forEach((specifier) => {
|
|
69
|
-
if (t.isExportSpecifier(specifier) && t.isIdentifier(specifier.exported)) {
|
|
70
|
-
addTag(specifier.local.name);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
46
|
+
if (node.type === "ExportNamedDeclaration") {
|
|
47
|
+
if (t.isFunctionDeclaration(node.declaration)) {
|
|
48
|
+
if ((_a = node.declaration.id) == null ? void 0 : _a.name) {
|
|
49
|
+
const id = node.declaration.id.name;
|
|
50
|
+
const tags = state.get("astro:tags") ?? [];
|
|
51
|
+
state.set("astro:tags", [...tags, id]);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
} else if (node.type === "ExportDefaultDeclaration") {
|
|
55
|
+
if (t.isFunctionDeclaration(node.declaration)) {
|
|
56
|
+
if ((_b = node.declaration.id) == null ? void 0 : _b.name) {
|
|
57
|
+
const id = node.declaration.id.name;
|
|
58
|
+
const tags = state.get("astro:tags") ?? [];
|
|
59
|
+
state.set("astro:tags", [...tags, id]);
|
|
60
|
+
}
|
|
73
61
|
}
|
|
74
62
|
}
|
|
75
63
|
}
|
|
@@ -7,7 +7,9 @@ import { fileURLToPath } from "url";
|
|
|
7
7
|
import { pagesVirtualModuleId } from "../core/app/index.js";
|
|
8
8
|
import { collectErrorMetadata } from "../core/errors.js";
|
|
9
9
|
import { cachedCompilation } from "../vite-plugin-astro/compile.js";
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
createTransformStyleWithViteFn
|
|
12
|
+
} from "../vite-plugin-astro/styles.js";
|
|
11
13
|
import { getFileInfo } from "../vite-plugin-utils/index.js";
|
|
12
14
|
const MARKDOWN_IMPORT_FLAG = "?mdImport";
|
|
13
15
|
const MARKDOWN_CONTENT_FLAG = "?content";
|
|
@@ -41,12 +43,13 @@ function markdown({ config, logging }) {
|
|
|
41
43
|
}
|
|
42
44
|
return false;
|
|
43
45
|
}
|
|
44
|
-
let
|
|
46
|
+
let transformStyleWithVite;
|
|
47
|
+
let viteDevServer;
|
|
45
48
|
return {
|
|
46
49
|
name: "astro:markdown",
|
|
47
50
|
enforce: "pre",
|
|
48
51
|
configResolved(_resolvedConfig) {
|
|
49
|
-
|
|
52
|
+
transformStyleWithVite = createTransformStyleWithViteFn(_resolvedConfig);
|
|
50
53
|
},
|
|
51
54
|
async resolveId(id, importer, options) {
|
|
52
55
|
if (id.endsWith(`.md${MARKDOWN_CONTENT_FLAG}`)) {
|
|
@@ -159,7 +162,8 @@ ${astroResult}
|
|
|
159
162
|
moduleId: id,
|
|
160
163
|
source: astroResult,
|
|
161
164
|
ssr: Boolean(opts == null ? void 0 : opts.ssr),
|
|
162
|
-
|
|
165
|
+
transformStyleWithVite,
|
|
166
|
+
viteDevServer,
|
|
163
167
|
pluginContext: this
|
|
164
168
|
};
|
|
165
169
|
let transformResult = await cachedCompilation(compileProps);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
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",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"vendor"
|
|
75
75
|
],
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@astrojs/compiler": "^0.23.
|
|
77
|
+
"@astrojs/compiler": "^0.23.4",
|
|
78
78
|
"@astrojs/language-server": "^0.20.0",
|
|
79
79
|
"@astrojs/markdown-remark": "^1.0.0",
|
|
80
80
|
"@astrojs/telemetry": "^1.0.0",
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"recast": "^0.20.5",
|
|
116
116
|
"rehype": "^12.0.1",
|
|
117
117
|
"resolve": "^1.22.0",
|
|
118
|
-
"rollup": "
|
|
118
|
+
"rollup": "~2.77.0",
|
|
119
119
|
"semver": "^7.3.7",
|
|
120
120
|
"shiki": "^0.10.1",
|
|
121
121
|
"sirv": "^2.0.2",
|