@marko/vite 2.4.4 → 2.4.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/{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 +45 -33
- package/dist/index.mjs +47 -35
- 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
|
@@ -52,6 +52,7 @@ const queryReg = /\?marko-.+$/;
|
|
|
52
52
|
const browserEntryQuery = "?marko-browser-entry";
|
|
53
53
|
const serverEntryQuery = "?marko-server-entry";
|
|
54
54
|
const virtualFileQuery = "?marko-virtual";
|
|
55
|
+
const browserQuery = "?marko-browser";
|
|
55
56
|
const manifestFileName = "manifest.json";
|
|
56
57
|
const markoExt = ".marko";
|
|
57
58
|
const htmlExt = ".html";
|
|
@@ -94,7 +95,8 @@ function markoPlugin(opts = {}) {
|
|
|
94
95
|
let store;
|
|
95
96
|
let CJSTemplates;
|
|
96
97
|
let basePath = "/";
|
|
97
|
-
const
|
|
98
|
+
const entryIds = /* @__PURE__ */ new Set();
|
|
99
|
+
const cachedSources = /* @__PURE__ */ new Map();
|
|
98
100
|
const transformWatchFiles = /* @__PURE__ */ new Map();
|
|
99
101
|
const transformOptionalFiles = /* @__PURE__ */ new Map();
|
|
100
102
|
return [
|
|
@@ -238,8 +240,9 @@ function markoPlugin(opts = {}) {
|
|
|
238
240
|
ssrConfig.hot = domConfig.hot = true;
|
|
239
241
|
devServer = _server;
|
|
240
242
|
devServer.watcher.on("all", (type, filename) => {
|
|
243
|
+
cachedSources.delete(filename);
|
|
241
244
|
if (type === "unlink") {
|
|
242
|
-
|
|
245
|
+
entryIds.delete(filename);
|
|
243
246
|
transformWatchFiles.delete(filename);
|
|
244
247
|
transformOptionalFiles.delete(filename);
|
|
245
248
|
}
|
|
@@ -274,10 +277,9 @@ function markoPlugin(opts = {}) {
|
|
|
274
277
|
);
|
|
275
278
|
inputOptions.input = toHTMLEntries(root, serverManifest.entries);
|
|
276
279
|
for (const entry in serverManifest.entrySources) {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
);
|
|
280
|
+
const id = normalizePath(import_path.default.resolve(root, entry));
|
|
281
|
+
entryIds.add(id);
|
|
282
|
+
cachedSources.set(id, serverManifest.entrySources[entry]);
|
|
281
283
|
}
|
|
282
284
|
} catch (err) {
|
|
283
285
|
this.error(
|
|
@@ -302,6 +304,8 @@ function markoPlugin(opts = {}) {
|
|
|
302
304
|
importeeQuery = serverEntryQuery;
|
|
303
305
|
} else if (!ssr && isBuild && importer && isMarkoFile(importee) && ((_a = this.getModuleInfo(importer)) == null ? void 0 : _a.isEntry)) {
|
|
304
306
|
importeeQuery = browserEntryQuery;
|
|
307
|
+
} else if (linked && !ssr && !importeeQuery && isMarkoFile(importee)) {
|
|
308
|
+
importeeQuery = browserQuery;
|
|
305
309
|
}
|
|
306
310
|
if (importeeQuery) {
|
|
307
311
|
const resolved = importee[0] === "." ? {
|
|
@@ -331,11 +335,12 @@ function markoPlugin(opts = {}) {
|
|
|
331
335
|
return null;
|
|
332
336
|
},
|
|
333
337
|
async load(id) {
|
|
334
|
-
|
|
338
|
+
const query = getMarkoQuery(id);
|
|
339
|
+
switch (query) {
|
|
335
340
|
case serverEntryQuery: {
|
|
336
|
-
const fileName = id.slice(0, -
|
|
341
|
+
const fileName = id.slice(0, -query.length);
|
|
337
342
|
let entryData;
|
|
338
|
-
|
|
343
|
+
entryIds.add(fileName);
|
|
339
344
|
if (isBuild) {
|
|
340
345
|
const relativeFileName = import_path.default.posix.relative(root, fileName);
|
|
341
346
|
const entryId = toEntryId(relativeFileName);
|
|
@@ -364,8 +369,9 @@ function markoPlugin(opts = {}) {
|
|
|
364
369
|
basePathVar: isBuild ? basePathVar : void 0
|
|
365
370
|
});
|
|
366
371
|
}
|
|
367
|
-
case browserEntryQuery:
|
|
368
|
-
|
|
372
|
+
case browserEntryQuery:
|
|
373
|
+
case browserQuery: {
|
|
374
|
+
return cachedSources.get(id.slice(0, -query.length)) || null;
|
|
369
375
|
}
|
|
370
376
|
}
|
|
371
377
|
return virtualFiles.get(id) || null;
|
|
@@ -391,24 +397,26 @@ function markoPlugin(opts = {}) {
|
|
|
391
397
|
if (!isMarkoFile(id)) {
|
|
392
398
|
return null;
|
|
393
399
|
}
|
|
394
|
-
if (
|
|
395
|
-
|
|
396
|
-
id,
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
400
|
+
if (isSSR) {
|
|
401
|
+
if (linked) {
|
|
402
|
+
cachedSources.set(id, source);
|
|
403
|
+
if (serverManifest && entryIds.has(id)) {
|
|
404
|
+
serverManifest.entrySources[import_path.default.posix.relative(root, id)] = source;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
if (CJSTemplates == null ? void 0 : CJSTemplates.has(id)) {
|
|
408
|
+
return createEsmWrapper(
|
|
409
|
+
id,
|
|
410
|
+
getExportIdentifiers(
|
|
411
|
+
(await compiler.compile(source, id, {
|
|
412
|
+
cache,
|
|
413
|
+
ast: true,
|
|
414
|
+
code: false,
|
|
415
|
+
output: "source",
|
|
416
|
+
sourceMaps: false
|
|
417
|
+
})).ast
|
|
418
|
+
)
|
|
419
|
+
);
|
|
412
420
|
}
|
|
413
421
|
}
|
|
414
422
|
const compiled = await compiler.compile(
|
|
@@ -485,10 +493,14 @@ if (import.meta.hot) import.meta.hot.accept(() => {});`;
|
|
|
485
493
|
chunk = bundle[chunkId];
|
|
486
494
|
}
|
|
487
495
|
if ((chunk == null ? void 0 : chunk.type) === "asset") {
|
|
488
|
-
browserManifest[entryId] =
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
496
|
+
browserManifest[entryId] = {
|
|
497
|
+
...await (0, import_manifest_generator.generateDocManifest)(
|
|
498
|
+
basePath,
|
|
499
|
+
chunk.source.toString()
|
|
500
|
+
),
|
|
501
|
+
entries: void 0
|
|
502
|
+
// clear out entries for prod builds.
|
|
503
|
+
};
|
|
492
504
|
delete bundle[chunkId];
|
|
493
505
|
} else {
|
|
494
506
|
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";
|
|
@@ -32,6 +32,7 @@ var queryReg = /\?marko-.+$/;
|
|
|
32
32
|
var browserEntryQuery = "?marko-browser-entry";
|
|
33
33
|
var serverEntryQuery = "?marko-server-entry";
|
|
34
34
|
var virtualFileQuery = "?marko-virtual";
|
|
35
|
+
var browserQuery = "?marko-browser";
|
|
35
36
|
var manifestFileName = "manifest.json";
|
|
36
37
|
var markoExt = ".marko";
|
|
37
38
|
var htmlExt = ".html";
|
|
@@ -74,7 +75,8 @@ function markoPlugin(opts = {}) {
|
|
|
74
75
|
let store;
|
|
75
76
|
let CJSTemplates;
|
|
76
77
|
let basePath = "/";
|
|
77
|
-
const
|
|
78
|
+
const entryIds = /* @__PURE__ */ new Set();
|
|
79
|
+
const cachedSources = /* @__PURE__ */ new Map();
|
|
78
80
|
const transformWatchFiles = /* @__PURE__ */ new Map();
|
|
79
81
|
const transformOptionalFiles = /* @__PURE__ */ new Map();
|
|
80
82
|
return [
|
|
@@ -218,8 +220,9 @@ function markoPlugin(opts = {}) {
|
|
|
218
220
|
ssrConfig.hot = domConfig.hot = true;
|
|
219
221
|
devServer = _server;
|
|
220
222
|
devServer.watcher.on("all", (type, filename) => {
|
|
223
|
+
cachedSources.delete(filename);
|
|
221
224
|
if (type === "unlink") {
|
|
222
|
-
|
|
225
|
+
entryIds.delete(filename);
|
|
223
226
|
transformWatchFiles.delete(filename);
|
|
224
227
|
transformOptionalFiles.delete(filename);
|
|
225
228
|
}
|
|
@@ -254,10 +257,9 @@ function markoPlugin(opts = {}) {
|
|
|
254
257
|
);
|
|
255
258
|
inputOptions.input = toHTMLEntries(root, serverManifest.entries);
|
|
256
259
|
for (const entry in serverManifest.entrySources) {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
);
|
|
260
|
+
const id = normalizePath(path.resolve(root, entry));
|
|
261
|
+
entryIds.add(id);
|
|
262
|
+
cachedSources.set(id, serverManifest.entrySources[entry]);
|
|
261
263
|
}
|
|
262
264
|
} catch (err) {
|
|
263
265
|
this.error(
|
|
@@ -282,6 +284,8 @@ function markoPlugin(opts = {}) {
|
|
|
282
284
|
importeeQuery = serverEntryQuery;
|
|
283
285
|
} else if (!ssr && isBuild && importer && isMarkoFile(importee) && ((_a = this.getModuleInfo(importer)) == null ? void 0 : _a.isEntry)) {
|
|
284
286
|
importeeQuery = browserEntryQuery;
|
|
287
|
+
} else if (linked && !ssr && !importeeQuery && isMarkoFile(importee)) {
|
|
288
|
+
importeeQuery = browserQuery;
|
|
285
289
|
}
|
|
286
290
|
if (importeeQuery) {
|
|
287
291
|
const resolved = importee[0] === "." ? {
|
|
@@ -311,11 +315,12 @@ function markoPlugin(opts = {}) {
|
|
|
311
315
|
return null;
|
|
312
316
|
},
|
|
313
317
|
async load(id) {
|
|
314
|
-
|
|
318
|
+
const query = getMarkoQuery(id);
|
|
319
|
+
switch (query) {
|
|
315
320
|
case serverEntryQuery: {
|
|
316
|
-
const fileName = id.slice(0, -
|
|
321
|
+
const fileName = id.slice(0, -query.length);
|
|
317
322
|
let entryData;
|
|
318
|
-
|
|
323
|
+
entryIds.add(fileName);
|
|
319
324
|
if (isBuild) {
|
|
320
325
|
const relativeFileName = path.posix.relative(root, fileName);
|
|
321
326
|
const entryId = toEntryId(relativeFileName);
|
|
@@ -344,8 +349,9 @@ function markoPlugin(opts = {}) {
|
|
|
344
349
|
basePathVar: isBuild ? basePathVar : void 0
|
|
345
350
|
});
|
|
346
351
|
}
|
|
347
|
-
case browserEntryQuery:
|
|
348
|
-
|
|
352
|
+
case browserEntryQuery:
|
|
353
|
+
case browserQuery: {
|
|
354
|
+
return cachedSources.get(id.slice(0, -query.length)) || null;
|
|
349
355
|
}
|
|
350
356
|
}
|
|
351
357
|
return virtualFiles.get(id) || null;
|
|
@@ -371,24 +377,26 @@ function markoPlugin(opts = {}) {
|
|
|
371
377
|
if (!isMarkoFile(id)) {
|
|
372
378
|
return null;
|
|
373
379
|
}
|
|
374
|
-
if (
|
|
375
|
-
|
|
376
|
-
id,
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
380
|
+
if (isSSR) {
|
|
381
|
+
if (linked) {
|
|
382
|
+
cachedSources.set(id, source);
|
|
383
|
+
if (serverManifest && entryIds.has(id)) {
|
|
384
|
+
serverManifest.entrySources[path.posix.relative(root, id)] = source;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
if (CJSTemplates == null ? void 0 : CJSTemplates.has(id)) {
|
|
388
|
+
return createEsmWrapper(
|
|
389
|
+
id,
|
|
390
|
+
getExportIdentifiers(
|
|
391
|
+
(await compiler.compile(source, id, {
|
|
392
|
+
cache,
|
|
393
|
+
ast: true,
|
|
394
|
+
code: false,
|
|
395
|
+
output: "source",
|
|
396
|
+
sourceMaps: false
|
|
397
|
+
})).ast
|
|
398
|
+
)
|
|
399
|
+
);
|
|
392
400
|
}
|
|
393
401
|
}
|
|
394
402
|
const compiled = await compiler.compile(
|
|
@@ -465,10 +473,14 @@ if (import.meta.hot) import.meta.hot.accept(() => {});`;
|
|
|
465
473
|
chunk = bundle[chunkId];
|
|
466
474
|
}
|
|
467
475
|
if ((chunk == null ? void 0 : chunk.type) === "asset") {
|
|
468
|
-
browserManifest[entryId] =
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
476
|
+
browserManifest[entryId] = {
|
|
477
|
+
...await generateDocManifest(
|
|
478
|
+
basePath,
|
|
479
|
+
chunk.source.toString()
|
|
480
|
+
),
|
|
481
|
+
entries: void 0
|
|
482
|
+
// clear out entries for prod builds.
|
|
483
|
+
};
|
|
472
484
|
delete bundle[chunkId];
|
|
473
485
|
} else {
|
|
474
486
|
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