@marko/vite 5.0.5 → 5.0.6
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/index.mjs +41 -31
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -15,6 +15,19 @@ function getRenderAssetsRuntime(opts) {
|
|
|
15
15
|
return `${opts.basePathVar && opts.isBuild ? `const base = globalThis.${opts.basePathVar};
|
|
16
16
|
if (typeof base !== "string") throw new Error("${opts.basePathVar} must be defined when using basePathVar.");
|
|
17
17
|
if (!base.endsWith("/")) throw new Error("${opts.basePathVar} must end with a '/' when using basePathVar.");` : "const base = import.meta.env.BASE_URL;"}
|
|
18
|
+
|
|
19
|
+
export function getPrepend(g) {
|
|
20
|
+
return (
|
|
21
|
+
g.___viteRenderAssets("head-prepend") +
|
|
22
|
+
g.___viteRenderAssets("head") +
|
|
23
|
+
g.___viteRenderAssets("body-prepend")
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
export function getAppend(g) {
|
|
27
|
+
return (
|
|
28
|
+
g.___viteRenderAssets("body-prepend")
|
|
29
|
+
);
|
|
30
|
+
}
|
|
18
31
|
export function addAssets(g, newEntries) {
|
|
19
32
|
const entries = g.___viteEntries;
|
|
20
33
|
if (entries) {
|
|
@@ -107,42 +120,39 @@ function renderAssets(slot) {
|
|
|
107
120
|
|
|
108
121
|
// src/server-entry-template.ts
|
|
109
122
|
var server_entry_template_default = async (opts) => {
|
|
110
|
-
const addAssetsCall = `addAssets($global, [${opts.entryData.join(",")}])`;
|
|
111
123
|
const fileNameStr = JSON.stringify(`./${path.basename(opts.fileName)}`);
|
|
112
|
-
|
|
124
|
+
if (opts.tagsAPI) {
|
|
125
|
+
return `import Template from ${fileNameStr};
|
|
113
126
|
export * from ${fileNameStr};
|
|
114
|
-
import { addAssets } from "${renderAssetsRuntimeId}";
|
|
115
|
-
|
|
116
|
-
$
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
127
|
+
import { addAssets, getPrepend, getAppend } from "${renderAssetsRuntimeId}";
|
|
128
|
+
static function flush($global, html) {
|
|
129
|
+
return getPrepend($global) + html + getAppend($global);
|
|
130
|
+
}
|
|
131
|
+
static function setFlush($global) {
|
|
132
|
+
$global.__flush__ = flush;
|
|
133
|
+
}
|
|
134
|
+
static const assets = [${opts.entryData.join(",")}];
|
|
135
|
+
<const/writeSync=addAssets($global, assets) || setFlush($global)/>
|
|
136
|
+
-- $!{writeSync && getPrepend($global)}
|
|
137
|
+
<Template ...input/>
|
|
138
|
+
-- $!{writeSync && getAppend($global)}
|
|
139
|
+
`;
|
|
123
140
|
}
|
|
141
|
+
return `import template from ${fileNameStr};
|
|
142
|
+
export * from ${fileNameStr};
|
|
143
|
+
import { addAssets, getPrepend, getAppend } from "${renderAssetsRuntimeId}";
|
|
144
|
+
static const assets = [${opts.entryData.join(",")}];
|
|
145
|
+
<if(addAssets($global, assets))>
|
|
146
|
+
$!{getPrepend($global)}
|
|
147
|
+
<\${template} ...input/>
|
|
148
|
+
$!{getAppend($global)}
|
|
124
149
|
</>
|
|
125
150
|
<else>
|
|
126
|
-
<__flush_here_and_after__
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
</__flush_here_and_after__>
|
|
133
|
-
</>
|
|
134
|
-
|
|
135
|
-
<\${template} ...input/>${opts.tagsAPI ? "" : `
|
|
136
|
-
<init-components/>
|
|
137
|
-
<await-reorderer/>`}
|
|
138
|
-
|
|
139
|
-
${opts.tagsAPI ? "<if=writeSync>" : "<if(writeSync)>"}
|
|
140
|
-
$!{$global.___viteRenderAssets("body")}
|
|
141
|
-
</>
|
|
142
|
-
<else>
|
|
143
|
-
<__flush_here_and_after__>
|
|
144
|
-
$!{$global.___viteRenderAssets("body")}
|
|
145
|
-
</__flush_here_and_after__>
|
|
151
|
+
<__flush_here_and_after__>$!{getPrepend($global)}</>
|
|
152
|
+
<\${template} ...input/>
|
|
153
|
+
<init-components/>
|
|
154
|
+
<await-reorderer/>
|
|
155
|
+
<__flush_here_and_after__>$!{getAppend($global)}</>
|
|
146
156
|
</>
|
|
147
157
|
`;
|
|
148
158
|
};
|