@marko/vite 2.4.4 → 2.4.5
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/{chunk-ZCKVZIQN.mjs → chunk-2E5QX7AF.mjs} +9 -7
- package/dist/{chunk-BV667Z5U.mjs → chunk-NTHVNXFC.mjs} +7 -3
- package/dist/components/vite.marko +32 -6
- package/dist/index.js +8 -4
- package/dist/index.mjs +10 -6
- package/dist/manifest-generator.d.ts +1 -0
- package/dist/manifest-generator.js +8 -6
- package/dist/manifest-generator.mjs +2 -2
- package/dist/serializer.d.ts +1 -1
- package/dist/serializer.js +7 -3
- package/dist/serializer.mjs +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
serialize
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-NTHVNXFC.mjs";
|
|
4
4
|
|
|
5
5
|
// src/manifest-generator.ts
|
|
6
6
|
import { Parser } from "htmlparser2";
|
|
@@ -15,6 +15,7 @@ function generateDocManifest(basePath, rawHtml) {
|
|
|
15
15
|
return reject(err);
|
|
16
16
|
}
|
|
17
17
|
const htmlChildren = dom.find(isElement).childNodes;
|
|
18
|
+
const entries = [];
|
|
18
19
|
const headPrepend = [];
|
|
19
20
|
const head = [];
|
|
20
21
|
const bodyPrepend = [];
|
|
@@ -34,10 +35,11 @@ function generateDocManifest(basePath, rawHtml) {
|
|
|
34
35
|
body
|
|
35
36
|
);
|
|
36
37
|
resolve({
|
|
37
|
-
|
|
38
|
-
head: serializeOrNull(basePath,
|
|
39
|
-
|
|
40
|
-
body: serializeOrNull(basePath,
|
|
38
|
+
entries,
|
|
39
|
+
"head-prepend": serializeOrNull(basePath, headPrepend, entries),
|
|
40
|
+
head: serializeOrNull(basePath, head, entries),
|
|
41
|
+
"body-prepend": serializeOrNull(basePath, bodyPrepend, entries),
|
|
42
|
+
body: serializeOrNull(basePath, body, entries)
|
|
41
43
|
});
|
|
42
44
|
})
|
|
43
45
|
);
|
|
@@ -50,8 +52,8 @@ function generateInputDoc(entry) {
|
|
|
50
52
|
entry
|
|
51
53
|
)}></script></body></html>`;
|
|
52
54
|
}
|
|
53
|
-
function serializeOrNull(basePath, nodes) {
|
|
54
|
-
const result = serialize(basePath, nodes);
|
|
55
|
+
function serializeOrNull(basePath, nodes, entries) {
|
|
56
|
+
const result = serialize(basePath, nodes, entries);
|
|
55
57
|
if (result.length) {
|
|
56
58
|
return result;
|
|
57
59
|
}
|
|
@@ -16,7 +16,7 @@ var voidElements = /* @__PURE__ */ new Set([
|
|
|
16
16
|
"track",
|
|
17
17
|
"wbr"
|
|
18
18
|
]);
|
|
19
|
-
function serialize(basePath, nodes, parts) {
|
|
19
|
+
function serialize(basePath, nodes, entries, parts) {
|
|
20
20
|
let curString = parts ? parts.pop() : "";
|
|
21
21
|
parts ?? (parts = []);
|
|
22
22
|
for (const node of nodes) {
|
|
@@ -50,11 +50,15 @@ function serialize(basePath, nodes, parts) {
|
|
|
50
50
|
if (attr.value === "") {
|
|
51
51
|
curString += ` ${attr.name}`;
|
|
52
52
|
} else if (attr.name === urlAttr) {
|
|
53
|
+
const id = stripBasePath(basePath, attr.value).replace(/^\.\//, "");
|
|
54
|
+
if (tag.name === "script") {
|
|
55
|
+
entries.push(id);
|
|
56
|
+
}
|
|
53
57
|
curString += ` ${attr.name}="`;
|
|
54
58
|
parts.push(
|
|
55
59
|
curString,
|
|
56
60
|
1 /* PublicPath */,
|
|
57
|
-
|
|
61
|
+
id.replace(/"/g, "'") + '"'
|
|
58
62
|
);
|
|
59
63
|
curString = "";
|
|
60
64
|
} else {
|
|
@@ -64,7 +68,7 @@ function serialize(basePath, nodes, parts) {
|
|
|
64
68
|
curString += ">";
|
|
65
69
|
if (tag.children.length) {
|
|
66
70
|
parts.push(curString);
|
|
67
|
-
serialize(basePath, tag.children, parts);
|
|
71
|
+
serialize(basePath, tag.children, entries, parts);
|
|
68
72
|
curString = parts.pop();
|
|
69
73
|
}
|
|
70
74
|
if (!voidElements.has(name)) {
|
|
@@ -8,11 +8,35 @@ static function renderAssets(slot) {
|
|
|
8
8
|
const writtenEntries = (this[slotWrittenEntriesKey] = entries.length);
|
|
9
9
|
|
|
10
10
|
for (let i = lastWrittenEntry; i < writtenEntries; i++) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
let entry = entries[i];
|
|
12
|
+
|
|
13
|
+
if (typeof __MARKO_MANIFEST__ === "object") {
|
|
14
|
+
entry = __MARKO_MANIFEST__[entry] || {};
|
|
15
|
+
} else if (slot === "head") {
|
|
16
|
+
// In dev mode we have is a list entries of the top level modules that need to be imported.
|
|
17
|
+
// To avoid FOUC we will hide the page until all of these modules are loaded.
|
|
18
|
+
const { entries } = entry;
|
|
19
|
+
if (entries) {
|
|
20
|
+
let sep = "";
|
|
21
|
+
html += `<script${this.___viteInjectAttrs}>((root=document.documentElement)=>{`;
|
|
22
|
+
html += "root.style.visibility='hidden';";
|
|
23
|
+
html += "document.currentScript.remove();";
|
|
24
|
+
html += "Promise.allSettled([";
|
|
25
|
+
|
|
26
|
+
for (const id of entries) {
|
|
27
|
+
html += `${sep}import(${JSON.stringify(this.___viteBasePath + id)})`;
|
|
28
|
+
sep = ",";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
html += "]).then(()=>{";
|
|
32
|
+
html += "root.style.visibility='';";
|
|
33
|
+
html +=
|
|
34
|
+
"if(root.getAttribute('style')==='')root.removeAttribute('style')";
|
|
35
|
+
html += "})})()</script>";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const parts = entry[slot];
|
|
16
40
|
|
|
17
41
|
if (parts) {
|
|
18
42
|
for (const part of parts) {
|
|
@@ -40,7 +64,9 @@ $ if (!out.global.___viteRenderAssets) {
|
|
|
40
64
|
<__flush_here_and_after__>
|
|
41
65
|
<if(input.base && !out.global.___flushedMBP)>
|
|
42
66
|
$ out.global.___flushedMBP = true;
|
|
43
|
-
$!{`<script${out.global.___viteInjectAttrs}>${
|
|
67
|
+
$!{`<script${out.global.___viteInjectAttrs}>${
|
|
68
|
+
out.global.___viteBaseVar
|
|
69
|
+
}=${JSON.stringify(input.base)}</script>`}
|
|
44
70
|
</if>
|
|
45
71
|
$!{out.global.___viteRenderAssets(input.slot)}
|
|
46
72
|
</__flush_here_and_after__>
|
package/dist/index.js
CHANGED
|
@@ -485,10 +485,14 @@ if (import.meta.hot) import.meta.hot.accept(() => {});`;
|
|
|
485
485
|
chunk = bundle[chunkId];
|
|
486
486
|
}
|
|
487
487
|
if ((chunk == null ? void 0 : chunk.type) === "asset") {
|
|
488
|
-
browserManifest[entryId] =
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
488
|
+
browserManifest[entryId] = {
|
|
489
|
+
...await (0, import_manifest_generator.generateDocManifest)(
|
|
490
|
+
basePath,
|
|
491
|
+
chunk.source.toString()
|
|
492
|
+
),
|
|
493
|
+
entries: void 0
|
|
494
|
+
// clear out entries for prod builds.
|
|
495
|
+
};
|
|
492
496
|
delete bundle[chunkId];
|
|
493
497
|
} else {
|
|
494
498
|
this.error(
|
package/dist/index.mjs
CHANGED
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
generateDocManifest,
|
|
6
6
|
generateInputDoc
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-2E5QX7AF.mjs";
|
|
8
|
+
import "./chunk-NTHVNXFC.mjs";
|
|
9
9
|
import {
|
|
10
10
|
server_entry_template_default
|
|
11
11
|
} from "./chunk-6IJ5UJ3N.mjs";
|
|
@@ -465,10 +465,14 @@ if (import.meta.hot) import.meta.hot.accept(() => {});`;
|
|
|
465
465
|
chunk = bundle[chunkId];
|
|
466
466
|
}
|
|
467
467
|
if ((chunk == null ? void 0 : chunk.type) === "asset") {
|
|
468
|
-
browserManifest[entryId] =
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
468
|
+
browserManifest[entryId] = {
|
|
469
|
+
...await generateDocManifest(
|
|
470
|
+
basePath,
|
|
471
|
+
chunk.source.toString()
|
|
472
|
+
),
|
|
473
|
+
entries: void 0
|
|
474
|
+
// clear out entries for prod builds.
|
|
475
|
+
};
|
|
472
476
|
delete bundle[chunkId];
|
|
473
477
|
} else {
|
|
474
478
|
this.error(
|
|
@@ -45,6 +45,7 @@ function generateDocManifest(basePath, rawHtml) {
|
|
|
45
45
|
return reject(err);
|
|
46
46
|
}
|
|
47
47
|
const htmlChildren = dom.find(isElement).childNodes;
|
|
48
|
+
const entries = [];
|
|
48
49
|
const headPrepend = [];
|
|
49
50
|
const head = [];
|
|
50
51
|
const bodyPrepend = [];
|
|
@@ -64,10 +65,11 @@ function generateDocManifest(basePath, rawHtml) {
|
|
|
64
65
|
body
|
|
65
66
|
);
|
|
66
67
|
resolve({
|
|
67
|
-
|
|
68
|
-
head: serializeOrNull(basePath,
|
|
69
|
-
|
|
70
|
-
body: serializeOrNull(basePath,
|
|
68
|
+
entries,
|
|
69
|
+
"head-prepend": serializeOrNull(basePath, headPrepend, entries),
|
|
70
|
+
head: serializeOrNull(basePath, head, entries),
|
|
71
|
+
"body-prepend": serializeOrNull(basePath, bodyPrepend, entries),
|
|
72
|
+
body: serializeOrNull(basePath, body, entries)
|
|
71
73
|
});
|
|
72
74
|
})
|
|
73
75
|
);
|
|
@@ -80,8 +82,8 @@ function generateInputDoc(entry) {
|
|
|
80
82
|
entry
|
|
81
83
|
)}></script></body></html>`;
|
|
82
84
|
}
|
|
83
|
-
function serializeOrNull(basePath, nodes) {
|
|
84
|
-
const result = (0, import_serializer.default)(basePath, nodes);
|
|
85
|
+
function serializeOrNull(basePath, nodes, entries) {
|
|
86
|
+
const result = (0, import_serializer.default)(basePath, nodes, entries);
|
|
85
87
|
if (result.length) {
|
|
86
88
|
return result;
|
|
87
89
|
}
|
package/dist/serializer.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ declare enum InjectType {
|
|
|
3
3
|
AssetAttrs = 0,
|
|
4
4
|
PublicPath = 1
|
|
5
5
|
}
|
|
6
|
-
export default function serialize(basePath: string, nodes: Node[], parts?: (string | InjectType)[]): (string | InjectType)[];
|
|
6
|
+
export default function serialize(basePath: string, nodes: Node[], entries: string[], parts?: (string | InjectType)[]): (string | InjectType)[];
|
|
7
7
|
export {};
|
package/dist/serializer.js
CHANGED
|
@@ -43,7 +43,7 @@ const voidElements = /* @__PURE__ */ new Set([
|
|
|
43
43
|
"track",
|
|
44
44
|
"wbr"
|
|
45
45
|
]);
|
|
46
|
-
function serialize(basePath, nodes, parts) {
|
|
46
|
+
function serialize(basePath, nodes, entries, parts) {
|
|
47
47
|
let curString = parts ? parts.pop() : "";
|
|
48
48
|
parts ?? (parts = []);
|
|
49
49
|
for (const node of nodes) {
|
|
@@ -77,11 +77,15 @@ function serialize(basePath, nodes, parts) {
|
|
|
77
77
|
if (attr.value === "") {
|
|
78
78
|
curString += ` ${attr.name}`;
|
|
79
79
|
} else if (attr.name === urlAttr) {
|
|
80
|
+
const id = stripBasePath(basePath, attr.value).replace(/^\.\//, "");
|
|
81
|
+
if (tag.name === "script") {
|
|
82
|
+
entries.push(id);
|
|
83
|
+
}
|
|
80
84
|
curString += ` ${attr.name}="`;
|
|
81
85
|
parts.push(
|
|
82
86
|
curString,
|
|
83
87
|
1 /* PublicPath */,
|
|
84
|
-
|
|
88
|
+
id.replace(/"/g, "'") + '"'
|
|
85
89
|
);
|
|
86
90
|
curString = "";
|
|
87
91
|
} else {
|
|
@@ -91,7 +95,7 @@ function serialize(basePath, nodes, parts) {
|
|
|
91
95
|
curString += ">";
|
|
92
96
|
if (tag.children.length) {
|
|
93
97
|
parts.push(curString);
|
|
94
|
-
serialize(basePath, tag.children, parts);
|
|
98
|
+
serialize(basePath, tag.children, entries, parts);
|
|
95
99
|
curString = parts.pop();
|
|
96
100
|
}
|
|
97
101
|
if (!voidElements.has(name)) {
|
package/dist/serializer.mjs
CHANGED