@marko/vite 4.1.17 → 4.1.18
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/glob-import-transform.d.ts +8 -0
- package/dist/index.mjs +185 -70
- package/dist/serializer.d.ts +2 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import fs4 from "fs";
|
|
3
|
-
import
|
|
3
|
+
import path6 from "path";
|
|
4
4
|
import crypto from "crypto";
|
|
5
5
|
import anyMatch from "anymatch";
|
|
6
6
|
import { pathToFileURL } from "url";
|
|
@@ -18,14 +18,15 @@ export function addAssets(g, newEntries) {
|
|
|
18
18
|
const entries = g.___viteEntries;
|
|
19
19
|
if (entries) {
|
|
20
20
|
g.___viteEntries = entries.concat(newEntries);
|
|
21
|
-
|
|
22
|
-
g.___viteEntries = newEntries;
|
|
23
|
-
g.___viteRenderAssets = renderAssets;
|
|
24
|
-
g.___viteInjectAttrs = g.cspNonce
|
|
25
|
-
? \` nonce="\${g.cspNonce.replace(/"/g, "'")}"\`
|
|
26
|
-
: "";
|
|
27
|
-
${opts.runtimeId ? `g.runtimeId = ${JSON.stringify(opts.runtimeId)};` : ""}
|
|
21
|
+
return true;
|
|
28
22
|
}
|
|
23
|
+
g.___viteEntries = newEntries;
|
|
24
|
+
g.___viteRenderAssets = renderAssets;
|
|
25
|
+
g.___viteInjectAttrs = g.cspNonce
|
|
26
|
+
? \` nonce="\${g.cspNonce.replace(/"/g, "'")}"\`
|
|
27
|
+
: "";
|
|
28
|
+
g.___viteSeenIds = new Set();
|
|
29
|
+
${opts.runtimeId ? `g.runtimeId = ${JSON.stringify(opts.runtimeId)};` : ""}
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
function renderAssets(slot) {
|
|
@@ -33,6 +34,7 @@ function renderAssets(slot) {
|
|
|
33
34
|
let html = "";
|
|
34
35
|
|
|
35
36
|
if (entries) {
|
|
37
|
+
const seenIds = this.___viteSeenIds;
|
|
36
38
|
const slotWrittenEntriesKey = \`___viteWrittenEntries-\${slot}\`;
|
|
37
39
|
const lastWrittenEntry = this[slotWrittenEntriesKey] || 0;
|
|
38
40
|
const writtenEntries = (this[slotWrittenEntriesKey] = entries.length);
|
|
@@ -69,13 +71,29 @@ function renderAssets(slot) {
|
|
|
69
71
|
const parts = entry[slot];
|
|
70
72
|
|
|
71
73
|
if (parts) {
|
|
72
|
-
for (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
for (let i = 0; i < parts.length; i++) {
|
|
75
|
+
const part = parts[i];
|
|
76
|
+
switch (part) {
|
|
77
|
+
case 0: /** InjectType.AssetAttrs */
|
|
78
|
+
html += this.___viteInjectAttrs;
|
|
79
|
+
break;
|
|
80
|
+
case 1: /** InjectType.PublicPath */
|
|
81
|
+
html += base;
|
|
82
|
+
break;
|
|
83
|
+
case 2: /** InjectType.Dedupe */ {
|
|
84
|
+
const id = parts[++i];
|
|
85
|
+
const skipParts = parts[++i];
|
|
86
|
+
if (seenIds.has(id)) {
|
|
87
|
+
i += skipParts;
|
|
88
|
+
} else {
|
|
89
|
+
seenIds.add(id);
|
|
90
|
+
}
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
default:
|
|
94
|
+
html += part;
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
79
97
|
}
|
|
80
98
|
}
|
|
81
99
|
}
|
|
@@ -94,23 +112,37 @@ export * from ${fileNameStr};
|
|
|
94
112
|
import { addAssets } from "${renderAssetsRuntimeId}";
|
|
95
113
|
|
|
96
114
|
$ const g = out.global;
|
|
97
|
-
$ addAssets(g, [${opts.entryData.join(",")}]);
|
|
115
|
+
$ const writeSync = addAssets(g, [${opts.entryData.join(",")}]);
|
|
98
116
|
|
|
99
|
-
<
|
|
117
|
+
<if(writeSync)>
|
|
100
118
|
$!{
|
|
101
119
|
g.___viteRenderAssets("head-prepend") +
|
|
102
120
|
g.___viteRenderAssets("head") +
|
|
103
121
|
g.___viteRenderAssets("body-prepend")
|
|
104
122
|
}
|
|
105
|
-
|
|
123
|
+
</>
|
|
124
|
+
<else>
|
|
125
|
+
<__flush_here_and_after__>
|
|
126
|
+
$!{
|
|
127
|
+
g.___viteRenderAssets("head-prepend") +
|
|
128
|
+
g.___viteRenderAssets("head") +
|
|
129
|
+
g.___viteRenderAssets("body-prepend")
|
|
130
|
+
}
|
|
131
|
+
</__flush_here_and_after__>
|
|
132
|
+
</>
|
|
106
133
|
|
|
107
134
|
<\${template} ...input/>
|
|
108
135
|
<init-components/>
|
|
109
136
|
<await-reorderer/>
|
|
110
137
|
|
|
111
|
-
<
|
|
138
|
+
<if(writeSync)>
|
|
112
139
|
$!{g.___viteRenderAssets("body")}
|
|
113
|
-
|
|
140
|
+
</>
|
|
141
|
+
<else>
|
|
142
|
+
<__flush_here_and_after__>
|
|
143
|
+
$!{g.___viteRenderAssets("body")}
|
|
144
|
+
</__flush_here_and_after__>
|
|
145
|
+
</>
|
|
114
146
|
`;
|
|
115
147
|
};
|
|
116
148
|
|
|
@@ -148,24 +180,47 @@ function serialize(basePath, nodes, preload, parts) {
|
|
|
148
180
|
const tag = node;
|
|
149
181
|
const { name } = tag;
|
|
150
182
|
let urlAttr;
|
|
151
|
-
|
|
183
|
+
let isDedupe = 0;
|
|
152
184
|
switch (tag.tagName) {
|
|
153
185
|
case "script":
|
|
154
|
-
|
|
155
|
-
|
|
186
|
+
if (tag.attribs.src) {
|
|
187
|
+
if (curString) {
|
|
188
|
+
parts.push(curString);
|
|
189
|
+
curString = "";
|
|
190
|
+
}
|
|
191
|
+
isDedupe = parts.push(2 /* Dedupe */, tag.attribs.src, 0) - 1;
|
|
192
|
+
}
|
|
193
|
+
parts.push(`${curString}<${name}`, 0 /* AssetAttrs */);
|
|
156
194
|
curString = "";
|
|
195
|
+
urlAttr = "src";
|
|
157
196
|
break;
|
|
158
197
|
case "style":
|
|
159
|
-
parts.push(curString
|
|
198
|
+
parts.push(`${curString}<${name}`, 0 /* AssetAttrs */);
|
|
160
199
|
curString = "";
|
|
161
200
|
break;
|
|
162
201
|
case "link":
|
|
202
|
+
if (tag.attribs.href) {
|
|
203
|
+
if (curString) {
|
|
204
|
+
parts.push(curString);
|
|
205
|
+
curString = "";
|
|
206
|
+
}
|
|
207
|
+
isDedupe = parts.push(
|
|
208
|
+
2 /* Dedupe */,
|
|
209
|
+
[tag.attribs.rel || "", tag.attribs.href, tag.attribs.as].filter((it) => it != null).join("#"),
|
|
210
|
+
0
|
|
211
|
+
) - 1;
|
|
212
|
+
}
|
|
163
213
|
urlAttr = "href";
|
|
164
214
|
if (tag.attribs.rel === "stylesheet" || tag.attribs.rel === "modulepreload" || tag.attribs.as === "style" || tag.attribs.as === "script") {
|
|
165
|
-
parts.push(curString
|
|
215
|
+
parts.push(`${curString}<${name}`, 0 /* AssetAttrs */);
|
|
166
216
|
curString = "";
|
|
217
|
+
} else {
|
|
218
|
+
curString += `<${name}`;
|
|
167
219
|
}
|
|
168
220
|
break;
|
|
221
|
+
default:
|
|
222
|
+
curString += `<${name}`;
|
|
223
|
+
break;
|
|
169
224
|
}
|
|
170
225
|
for (const attr of tag.attributes) {
|
|
171
226
|
if (attr.value === "") {
|
|
@@ -195,6 +250,13 @@ function serialize(basePath, nodes, preload, parts) {
|
|
|
195
250
|
if (!voidElements.has(name)) {
|
|
196
251
|
curString += `</${name}>`;
|
|
197
252
|
}
|
|
253
|
+
if (isDedupe) {
|
|
254
|
+
if (curString) {
|
|
255
|
+
parts.push(curString);
|
|
256
|
+
curString = "";
|
|
257
|
+
}
|
|
258
|
+
parts[isDedupe] = parts.length - isDedupe - 1;
|
|
259
|
+
}
|
|
198
260
|
break;
|
|
199
261
|
}
|
|
200
262
|
case ElementType.Text: {
|
|
@@ -214,9 +276,9 @@ function serialize(basePath, nodes, preload, parts) {
|
|
|
214
276
|
}
|
|
215
277
|
return parts;
|
|
216
278
|
}
|
|
217
|
-
function stripBasePath(basePath,
|
|
218
|
-
if (
|
|
219
|
-
return
|
|
279
|
+
function stripBasePath(basePath, path7) {
|
|
280
|
+
if (path7.startsWith(basePath)) return path7.slice(basePath.length);
|
|
281
|
+
return path7;
|
|
220
282
|
}
|
|
221
283
|
|
|
222
284
|
// src/manifest-generator.ts
|
|
@@ -439,14 +501,14 @@ function plugin(options) {
|
|
|
439
501
|
return {
|
|
440
502
|
name: "marko-import-interop",
|
|
441
503
|
visitor: {
|
|
442
|
-
ImportDeclaration(
|
|
443
|
-
if (!
|
|
504
|
+
ImportDeclaration(path7) {
|
|
505
|
+
if (!path7.node.specifiers.length || /\.(?:mjs|marko)$|\?/.test(path7.node.source.value) || options.filter?.(path7.node.source.value) === false) {
|
|
444
506
|
return;
|
|
445
507
|
}
|
|
446
508
|
try {
|
|
447
509
|
const resolved = resolve(
|
|
448
|
-
|
|
449
|
-
|
|
510
|
+
path7.node.source.value,
|
|
511
|
+
path7.hub.file.opts.filename,
|
|
450
512
|
options.extensions,
|
|
451
513
|
options.conditions
|
|
452
514
|
);
|
|
@@ -459,7 +521,7 @@ function plugin(options) {
|
|
|
459
521
|
let namespaceId;
|
|
460
522
|
let defaultImportId;
|
|
461
523
|
let imports;
|
|
462
|
-
for (const s of
|
|
524
|
+
for (const s of path7.node.specifiers) {
|
|
463
525
|
if (t.isImportSpecifier(s)) {
|
|
464
526
|
(imports ||= []).push({
|
|
465
527
|
name: t.isStringLiteral(s.imported) ? s.imported.value : s.imported.name,
|
|
@@ -471,12 +533,12 @@ function plugin(options) {
|
|
|
471
533
|
namespaceId = s.local;
|
|
472
534
|
}
|
|
473
535
|
}
|
|
474
|
-
namespaceId ||=
|
|
475
|
-
defaultImportId?.name ||
|
|
536
|
+
namespaceId ||= path7.scope.generateUidIdentifier(
|
|
537
|
+
defaultImportId?.name || path7.node.source.value
|
|
476
538
|
);
|
|
477
|
-
|
|
539
|
+
path7.node.specifiers = [t.importDefaultSpecifier(namespaceId)];
|
|
478
540
|
if (defaultImportId) {
|
|
479
|
-
|
|
541
|
+
path7.insertAfter(
|
|
480
542
|
t.variableDeclaration("const", [
|
|
481
543
|
t.variableDeclarator(
|
|
482
544
|
defaultImportId,
|
|
@@ -495,7 +557,7 @@ function plugin(options) {
|
|
|
495
557
|
);
|
|
496
558
|
}
|
|
497
559
|
if (imports) {
|
|
498
|
-
|
|
560
|
+
path7.insertAfter(
|
|
499
561
|
t.variableDeclaration("const", [
|
|
500
562
|
t.variableDeclarator(
|
|
501
563
|
t.objectPattern(
|
|
@@ -519,22 +581,22 @@ function plugin(options) {
|
|
|
519
581
|
}
|
|
520
582
|
|
|
521
583
|
// src/render-assets-transform.ts
|
|
522
|
-
var render_assets_transform_default = (tag,
|
|
584
|
+
var render_assets_transform_default = (tag, t3) => {
|
|
523
585
|
if (tag.hub.file.markoOpts.markoViteLinked) {
|
|
524
586
|
const body = tag.get("body");
|
|
525
587
|
const tagName = tag.get("name").node.value;
|
|
526
|
-
body.unshiftContainer("body", renderAssetsCall(
|
|
527
|
-
body.pushContainer("body", renderAssetsCall(
|
|
588
|
+
body.unshiftContainer("body", renderAssetsCall(t3, `${tagName}-prepend`));
|
|
589
|
+
body.pushContainer("body", renderAssetsCall(t3, tagName));
|
|
528
590
|
}
|
|
529
591
|
};
|
|
530
|
-
function renderAssetsCall(
|
|
531
|
-
return
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
592
|
+
function renderAssetsCall(t3, slot) {
|
|
593
|
+
return t3.markoPlaceholder(
|
|
594
|
+
t3.callExpression(
|
|
595
|
+
t3.memberExpression(
|
|
596
|
+
t3.memberExpression(t3.identifier("out"), t3.identifier("global")),
|
|
597
|
+
t3.identifier("___viteRenderAssets")
|
|
536
598
|
),
|
|
537
|
-
[
|
|
599
|
+
[t3.stringLiteral(slot)]
|
|
538
600
|
),
|
|
539
601
|
false
|
|
540
602
|
);
|
|
@@ -560,7 +622,7 @@ var assetAttrsByTag = /* @__PURE__ */ new Map([
|
|
|
560
622
|
["script", /* @__PURE__ */ new Set(["src"])]
|
|
561
623
|
]);
|
|
562
624
|
var assetFileReg = /(?:^\..*\.(?:a?png|jpe?g|jfif|pipeg|pjp|gif|svg|ico|web[pm]|avif|mp4|ogg|mp3|wav|flac|aac|opus|woff2?|eot|[ot]tf|webmanifest|pdf|txt)(\?|$)|\?url\b)/;
|
|
563
|
-
function transform(tag,
|
|
625
|
+
function transform(tag, t3) {
|
|
564
626
|
const { name, attributes } = tag.node;
|
|
565
627
|
if (name.type !== "StringLiteral") {
|
|
566
628
|
return;
|
|
@@ -574,12 +636,12 @@ function transform(tag, t2) {
|
|
|
574
636
|
const { value } = attr.value;
|
|
575
637
|
if (assetFileReg.test(value)) {
|
|
576
638
|
const importedId = tag.scope.generateUid(value);
|
|
577
|
-
attr.value =
|
|
639
|
+
attr.value = t3.identifier(importedId);
|
|
578
640
|
tag.hub.file.path.unshiftContainer(
|
|
579
641
|
"body",
|
|
580
|
-
|
|
581
|
-
[
|
|
582
|
-
|
|
642
|
+
t3.importDeclaration(
|
|
643
|
+
[t3.importDefaultSpecifier(t3.identifier(importedId))],
|
|
644
|
+
t3.stringLiteral(value)
|
|
583
645
|
)
|
|
584
646
|
);
|
|
585
647
|
}
|
|
@@ -587,13 +649,65 @@ function transform(tag, t2) {
|
|
|
587
649
|
}
|
|
588
650
|
}
|
|
589
651
|
|
|
652
|
+
// src/glob-import-transform.ts
|
|
653
|
+
import { types as t2 } from "@marko/compiler";
|
|
654
|
+
import glob from "fast-glob";
|
|
655
|
+
import path4 from "path";
|
|
656
|
+
var programGlobImports = /* @__PURE__ */ new WeakMap();
|
|
657
|
+
var glob_import_transform_default = {
|
|
658
|
+
MetaProperty(tag) {
|
|
659
|
+
const memberExpression2 = tag.parentPath;
|
|
660
|
+
if (memberExpression2.node.type === "MemberExpression" && memberExpression2.node.property.type === "Identifier" && memberExpression2.node.property.name === "glob") {
|
|
661
|
+
const callExpression = memberExpression2.parentPath;
|
|
662
|
+
if (callExpression?.node.type === "CallExpression") {
|
|
663
|
+
const args = callExpression.get("arguments").map((arg) => arg.evaluate().value);
|
|
664
|
+
if (args[1]?.eager) {
|
|
665
|
+
const program = tag.hub.file.path;
|
|
666
|
+
const existing = programGlobImports.get(program);
|
|
667
|
+
if (!existing) {
|
|
668
|
+
programGlobImports.set(program, [args]);
|
|
669
|
+
} else {
|
|
670
|
+
existing.push(args);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
},
|
|
676
|
+
Program: {
|
|
677
|
+
exit(tag) {
|
|
678
|
+
const globImports = programGlobImports.get(tag);
|
|
679
|
+
if (!globImports) {
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
const { cwd, filename } = tag.hub.file.opts;
|
|
683
|
+
const dir = path4.dirname(filename);
|
|
684
|
+
const seen = /* @__PURE__ */ new Set();
|
|
685
|
+
for (const [patterns, options] of globImports) {
|
|
686
|
+
const resolvedPatterns = Array.isArray(patterns) ? patterns.map((p) => path4.resolve(dir, p)) : path4.resolve(dir, patterns);
|
|
687
|
+
const results = glob.globSync(resolvedPatterns, {
|
|
688
|
+
cwd,
|
|
689
|
+
absolute: true,
|
|
690
|
+
dot: !!options.exhaustive,
|
|
691
|
+
ignore: options.exhaustive ? [] : [path4.join(cwd, "**/node_modules/**")]
|
|
692
|
+
});
|
|
693
|
+
for (const file of results) {
|
|
694
|
+
if (file.endsWith(".marko") && file !== filename && !seen.has(file)) {
|
|
695
|
+
seen.add(file);
|
|
696
|
+
tag.node.body.push(t2.importDeclaration([], t2.stringLiteral(file)));
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
|
|
590
704
|
// src/read-once-persisted-store.ts
|
|
591
705
|
import os from "os";
|
|
592
|
-
import
|
|
706
|
+
import path5 from "path";
|
|
593
707
|
import { promises as fs3 } from "fs";
|
|
594
708
|
var noop = () => {
|
|
595
709
|
};
|
|
596
|
-
var tmpFile =
|
|
710
|
+
var tmpFile = path5.join(os.tmpdir(), "marko-vite-storage.json");
|
|
597
711
|
var values = /* @__PURE__ */ new Map();
|
|
598
712
|
var loadedFromDisk;
|
|
599
713
|
var ReadOncePersistedStore = class {
|
|
@@ -636,7 +750,7 @@ process.once("beforeExit", (code) => {
|
|
|
636
750
|
// src/index.ts
|
|
637
751
|
var POSIX_SEP = "/";
|
|
638
752
|
var WINDOWS_SEP = "\\";
|
|
639
|
-
var normalizePath =
|
|
753
|
+
var normalizePath = path6.sep === WINDOWS_SEP ? (id) => id.replace(/\\/g, POSIX_SEP) : (id) => id;
|
|
640
754
|
var virtualFiles = /* @__PURE__ */ new Map();
|
|
641
755
|
var extReg = /\.[^.]+$/;
|
|
642
756
|
var queryReg = /\?marko-[^?]+$/;
|
|
@@ -670,7 +784,7 @@ function markoPlugin(opts = {}) {
|
|
|
670
784
|
let hydrateConfig;
|
|
671
785
|
const resolveVirtualDependency = (from, dep) => {
|
|
672
786
|
const normalizedFrom = normalizePath(from);
|
|
673
|
-
const query = `${virtualFileQuery}&id=${Buffer.from(dep.virtualPath).toString("base64url") +
|
|
787
|
+
const query = `${virtualFileQuery}&id=${Buffer.from(dep.virtualPath).toString("base64url") + path6.extname(dep.virtualPath)}`;
|
|
674
788
|
const id = normalizePath(normalizedFrom) + query;
|
|
675
789
|
if (devServer) {
|
|
676
790
|
const prev = virtualFiles.get(id);
|
|
@@ -679,7 +793,7 @@ function markoPlugin(opts = {}) {
|
|
|
679
793
|
}
|
|
680
794
|
}
|
|
681
795
|
virtualFiles.set(id, dep);
|
|
682
|
-
return `./${
|
|
796
|
+
return `./${path6.posix.basename(normalizedFrom) + query}`;
|
|
683
797
|
};
|
|
684
798
|
let root;
|
|
685
799
|
let devEntryFile;
|
|
@@ -762,7 +876,7 @@ function markoPlugin(opts = {}) {
|
|
|
762
876
|
};
|
|
763
877
|
compiler.configure(baseConfig);
|
|
764
878
|
root = normalizePath(config.root || process.cwd());
|
|
765
|
-
devEntryFile =
|
|
879
|
+
devEntryFile = path6.join(root, "index.html");
|
|
766
880
|
devEntryFilePosix = normalizePath(devEntryFile);
|
|
767
881
|
isTest = env.mode === "test";
|
|
768
882
|
isBuild = env.command === "build";
|
|
@@ -788,6 +902,7 @@ function markoPlugin(opts = {}) {
|
|
|
788
902
|
if (!registeredTagLib) {
|
|
789
903
|
registeredTagLib = true;
|
|
790
904
|
compiler.taglib.register("@marko/vite", {
|
|
905
|
+
transform: glob_import_transform_default,
|
|
791
906
|
"<head>": { transformer: render_assets_transform_default },
|
|
792
907
|
"<body>": { transformer: render_assets_transform_default },
|
|
793
908
|
"<*>": { transformer: transform }
|
|
@@ -884,7 +999,7 @@ function markoPlugin(opts = {}) {
|
|
|
884
999
|
plugin({
|
|
885
1000
|
extensions: config.resolve.extensions,
|
|
886
1001
|
conditions: config.resolve.conditions,
|
|
887
|
-
filter: isBuild ? void 0 : (
|
|
1002
|
+
filter: isBuild ? void 0 : (path7) => !/^\./.test(path7)
|
|
888
1003
|
})
|
|
889
1004
|
)
|
|
890
1005
|
}
|
|
@@ -944,7 +1059,7 @@ function markoPlugin(opts = {}) {
|
|
|
944
1059
|
serverManifest = await store.read();
|
|
945
1060
|
inputOptions.input = toHTMLEntries(root, serverManifest.entries);
|
|
946
1061
|
for (const entry in serverManifest.entrySources) {
|
|
947
|
-
const id = normalizePath(
|
|
1062
|
+
const id = normalizePath(path6.resolve(root, entry));
|
|
948
1063
|
entryIds.add(id);
|
|
949
1064
|
cachedSources.set(id, serverManifest.entrySources[entry]);
|
|
950
1065
|
}
|
|
@@ -981,7 +1096,7 @@ function markoPlugin(opts = {}) {
|
|
|
981
1096
|
if (importeeQuery) {
|
|
982
1097
|
const resolved = importee[0] === "." ? {
|
|
983
1098
|
id: normalizePath(
|
|
984
|
-
importer ?
|
|
1099
|
+
importer ? path6.resolve(importer, "..", importee) : path6.resolve(root, importee)
|
|
985
1100
|
)
|
|
986
1101
|
} : await this.resolve(importee, importer, resolveOpts);
|
|
987
1102
|
if (resolved) {
|
|
@@ -995,7 +1110,7 @@ function markoPlugin(opts = {}) {
|
|
|
995
1110
|
importer = importer.slice(0, -importerQuery.length);
|
|
996
1111
|
if (importee[0] === ".") {
|
|
997
1112
|
const resolved = normalizePath(
|
|
998
|
-
|
|
1113
|
+
path6.resolve(importer, "..", importee)
|
|
999
1114
|
);
|
|
1000
1115
|
if (resolved === normalizePath(importer)) return resolved;
|
|
1001
1116
|
}
|
|
@@ -1040,7 +1155,7 @@ function markoPlugin(opts = {}) {
|
|
|
1040
1155
|
id = `${id.slice(0, -markoExt.length)}.entry.marko`;
|
|
1041
1156
|
cachedSources.set(fileName, source);
|
|
1042
1157
|
if (isBuild) {
|
|
1043
|
-
const relativeFileName =
|
|
1158
|
+
const relativeFileName = path6.posix.relative(root, fileName);
|
|
1044
1159
|
const entryId = toEntryId(relativeFileName);
|
|
1045
1160
|
serverManifest ??= {
|
|
1046
1161
|
entries: {},
|
|
@@ -1082,7 +1197,7 @@ function markoPlugin(opts = {}) {
|
|
|
1082
1197
|
}
|
|
1083
1198
|
if (!isMarkoFile(id)) {
|
|
1084
1199
|
if (!isBuild) {
|
|
1085
|
-
const ext =
|
|
1200
|
+
const ext = path6.extname(id);
|
|
1086
1201
|
if (ext === ".cjs" || ext === ".js" && isCJSModule(id)) {
|
|
1087
1202
|
if (cjsToEsm === void 0) {
|
|
1088
1203
|
try {
|
|
@@ -1138,7 +1253,7 @@ if (import.meta.hot) import.meta.hot.accept(() => {});`;
|
|
|
1138
1253
|
}
|
|
1139
1254
|
if (devServer) {
|
|
1140
1255
|
const templateName = getPosixBasenameWithoutExt(id);
|
|
1141
|
-
const optionalFilePrefix =
|
|
1256
|
+
const optionalFilePrefix = path6.dirname(id) + path6.sep + (templateName === "index" ? "" : `${templateName}.`);
|
|
1142
1257
|
for (const file of meta.watchFiles) {
|
|
1143
1258
|
this.addWatchFile(file);
|
|
1144
1259
|
}
|
|
@@ -1177,13 +1292,13 @@ if (import.meta.hot) import.meta.hot.accept(() => {});`;
|
|
|
1177
1292
|
);
|
|
1178
1293
|
}
|
|
1179
1294
|
if (isSSRBuild) {
|
|
1180
|
-
const dir = outputOptions.dir ?
|
|
1295
|
+
const dir = outputOptions.dir ? path6.resolve(outputOptions.dir) : path6.resolve(outputOptions.file, "..");
|
|
1181
1296
|
for (const fileName in bundle) {
|
|
1182
1297
|
const chunk = bundle[fileName];
|
|
1183
1298
|
if (chunk.type === "chunk") {
|
|
1184
1299
|
if (chunk.moduleIds.includes(renderAssetsRuntimeId)) {
|
|
1185
1300
|
serverManifest.chunksNeedingAssets.push(
|
|
1186
|
-
|
|
1301
|
+
path6.resolve(dir, fileName)
|
|
1187
1302
|
);
|
|
1188
1303
|
}
|
|
1189
1304
|
}
|
|
@@ -1232,7 +1347,7 @@ function isMarkoFile(id) {
|
|
|
1232
1347
|
function toHTMLEntries(root, serverEntries) {
|
|
1233
1348
|
const result = [];
|
|
1234
1349
|
for (const id in serverEntries) {
|
|
1235
|
-
const markoFile =
|
|
1350
|
+
const markoFile = path6.posix.join(root, serverEntries[id]);
|
|
1236
1351
|
const htmlFile = markoFile + htmlExt;
|
|
1237
1352
|
virtualFiles.set(htmlFile, {
|
|
1238
1353
|
code: generateInputDoc(markoFile + browserEntryQuery)
|
|
@@ -1253,7 +1368,7 @@ function toEntryId(id) {
|
|
|
1253
1368
|
return `${name}_${crypto.createHash("SHA1").update(id).digest("base64").replace(/[/+]/g, "-").slice(0, 4)}`;
|
|
1254
1369
|
}
|
|
1255
1370
|
function posixFileNameToURL(fileName, root) {
|
|
1256
|
-
const relativeURL =
|
|
1371
|
+
const relativeURL = path6.posix.relative(
|
|
1257
1372
|
pathToFileURL(root).pathname,
|
|
1258
1373
|
pathToFileURL(fileName).pathname
|
|
1259
1374
|
);
|
package/dist/serializer.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Node } from "domhandler";
|
|
2
2
|
declare enum InjectType {
|
|
3
3
|
AssetAttrs = 0,
|
|
4
|
-
PublicPath = 1
|
|
4
|
+
PublicPath = 1,
|
|
5
|
+
Dedupe = 2
|
|
5
6
|
}
|
|
6
7
|
export default function serialize(basePath: string, nodes: Node[], preload: string[], parts?: (string | InjectType)[]): (string | InjectType)[];
|
|
7
8
|
export {};
|
package/package.json
CHANGED