@marko/vite 4.1.16 → 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.
@@ -0,0 +1,8 @@
1
+ import { types as t } from "@marko/compiler";
2
+ declare const _default: {
3
+ MetaProperty(tag: t.NodePath<t.MetaProperty>): void;
4
+ Program: {
5
+ exit(tag: t.NodePath<t.Program>): void;
6
+ };
7
+ };
8
+ export default _default;
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/index.ts
2
2
  import fs4 from "fs";
3
- import path5 from "path";
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
- } else {
22
- g.___viteEntries = newEntries;
23
- g.___viteRenderAssets = renderAssets;
24
- g.___viteInjectAttrs = g.cspNonce
25
- ? \` nonce="\${g.cspNonce.replace(/"/g, "&#39;")}"\`
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, "&#39;")}"\`
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 (const part of parts) {
73
- html +=
74
- part === 0 /** InjectType.AssetAttrs */
75
- ? this.___viteInjectAttrs
76
- : part === 1 /** InjectType.PublicPath */
77
- ? base
78
- : part;
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
- <__flush_here_and_after__>
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
- </__flush_here_and_after__>
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
- <__flush_here_and_after__>
138
+ <if(writeSync)>
112
139
  $!{g.___viteRenderAssets("body")}
113
- </__flush_here_and_after__>
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
- curString += `<${name}`;
183
+ let isDedupe = 0;
152
184
  switch (tag.tagName) {
153
185
  case "script":
154
- parts.push(curString, 0 /* AssetAttrs */);
155
- urlAttr = "src";
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, 0 /* AssetAttrs */);
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, 0 /* AssetAttrs */);
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, path6) {
218
- if (path6.startsWith(basePath)) return path6.slice(basePath.length);
219
- return path6;
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(path6) {
443
- if (!path6.node.specifiers.length || /\.(?:mjs|marko)$|\?/.test(path6.node.source.value) || options.filter?.(path6.node.source.value) === false) {
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
- path6.node.source.value,
449
- path6.hub.file.opts.filename,
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 path6.node.specifiers) {
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 ||= path6.scope.generateUidIdentifier(
475
- defaultImportId?.name || path6.node.source.value
536
+ namespaceId ||= path7.scope.generateUidIdentifier(
537
+ defaultImportId?.name || path7.node.source.value
476
538
  );
477
- path6.node.specifiers = [t.importDefaultSpecifier(namespaceId)];
539
+ path7.node.specifiers = [t.importDefaultSpecifier(namespaceId)];
478
540
  if (defaultImportId) {
479
- path6.insertAfter(
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
- path6.insertAfter(
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, t2) => {
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(t2, `${tagName}-prepend`));
527
- body.pushContainer("body", renderAssetsCall(t2, tagName));
588
+ body.unshiftContainer("body", renderAssetsCall(t3, `${tagName}-prepend`));
589
+ body.pushContainer("body", renderAssetsCall(t3, tagName));
528
590
  }
529
591
  };
530
- function renderAssetsCall(t2, slot) {
531
- return t2.markoPlaceholder(
532
- t2.callExpression(
533
- t2.memberExpression(
534
- t2.memberExpression(t2.identifier("out"), t2.identifier("global")),
535
- t2.identifier("___viteRenderAssets")
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
- [t2.stringLiteral(slot)]
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, t2) {
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 = t2.identifier(importedId);
639
+ attr.value = t3.identifier(importedId);
578
640
  tag.hub.file.path.unshiftContainer(
579
641
  "body",
580
- t2.importDeclaration(
581
- [t2.importDefaultSpecifier(t2.identifier(importedId))],
582
- t2.stringLiteral(value)
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 path4 from "path";
706
+ import path5 from "path";
593
707
  import { promises as fs3 } from "fs";
594
708
  var noop = () => {
595
709
  };
596
- var tmpFile = path4.join(os.tmpdir(), "marko-vite-storage.json");
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 = path5.sep === WINDOWS_SEP ? (id) => id.replace(/\\/g, POSIX_SEP) : (id) => id;
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") + path5.extname(dep.virtualPath)}`;
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 `./${path5.posix.basename(normalizedFrom) + query}`;
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 = path5.join(root, "index.html");
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,18 +902,21 @@ 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 }
794
909
  });
795
910
  }
796
911
  const optimizeDeps = config.optimizeDeps ??= {};
797
- optimizeDeps.entries ??= [
798
- "**/*.marko",
799
- "!**/__snapshots__/**",
800
- `!**/__tests__/**`,
801
- `!**/coverage/**`
802
- ];
912
+ if (!isTest) {
913
+ optimizeDeps.entries ??= [
914
+ "**/*.marko",
915
+ "!**/__snapshots__/**",
916
+ `!**/__tests__/**`,
917
+ `!**/coverage/**`
918
+ ];
919
+ }
803
920
  const domDeps = compiler.getRuntimeEntryFiles("dom", opts.translator);
804
921
  optimizeDeps.include = optimizeDeps.include ? [...optimizeDeps.include, ...domDeps] : domDeps;
805
922
  const optimizeExtensions = optimizeDeps.extensions ??= [];
@@ -882,7 +999,7 @@ function markoPlugin(opts = {}) {
882
999
  plugin({
883
1000
  extensions: config.resolve.extensions,
884
1001
  conditions: config.resolve.conditions,
885
- filter: isBuild ? void 0 : (path6) => !/^\./.test(path6)
1002
+ filter: isBuild ? void 0 : (path7) => !/^\./.test(path7)
886
1003
  })
887
1004
  )
888
1005
  }
@@ -942,7 +1059,7 @@ function markoPlugin(opts = {}) {
942
1059
  serverManifest = await store.read();
943
1060
  inputOptions.input = toHTMLEntries(root, serverManifest.entries);
944
1061
  for (const entry in serverManifest.entrySources) {
945
- const id = normalizePath(path5.resolve(root, entry));
1062
+ const id = normalizePath(path6.resolve(root, entry));
946
1063
  entryIds.add(id);
947
1064
  cachedSources.set(id, serverManifest.entrySources[entry]);
948
1065
  }
@@ -979,7 +1096,7 @@ function markoPlugin(opts = {}) {
979
1096
  if (importeeQuery) {
980
1097
  const resolved = importee[0] === "." ? {
981
1098
  id: normalizePath(
982
- importer ? path5.resolve(importer, "..", importee) : path5.resolve(root, importee)
1099
+ importer ? path6.resolve(importer, "..", importee) : path6.resolve(root, importee)
983
1100
  )
984
1101
  } : await this.resolve(importee, importer, resolveOpts);
985
1102
  if (resolved) {
@@ -993,7 +1110,7 @@ function markoPlugin(opts = {}) {
993
1110
  importer = importer.slice(0, -importerQuery.length);
994
1111
  if (importee[0] === ".") {
995
1112
  const resolved = normalizePath(
996
- path5.resolve(importer, "..", importee)
1113
+ path6.resolve(importer, "..", importee)
997
1114
  );
998
1115
  if (resolved === normalizePath(importer)) return resolved;
999
1116
  }
@@ -1038,7 +1155,7 @@ function markoPlugin(opts = {}) {
1038
1155
  id = `${id.slice(0, -markoExt.length)}.entry.marko`;
1039
1156
  cachedSources.set(fileName, source);
1040
1157
  if (isBuild) {
1041
- const relativeFileName = path5.posix.relative(root, fileName);
1158
+ const relativeFileName = path6.posix.relative(root, fileName);
1042
1159
  const entryId = toEntryId(relativeFileName);
1043
1160
  serverManifest ??= {
1044
1161
  entries: {},
@@ -1080,7 +1197,7 @@ function markoPlugin(opts = {}) {
1080
1197
  }
1081
1198
  if (!isMarkoFile(id)) {
1082
1199
  if (!isBuild) {
1083
- const ext = path5.extname(id);
1200
+ const ext = path6.extname(id);
1084
1201
  if (ext === ".cjs" || ext === ".js" && isCJSModule(id)) {
1085
1202
  if (cjsToEsm === void 0) {
1086
1203
  try {
@@ -1136,7 +1253,7 @@ if (import.meta.hot) import.meta.hot.accept(() => {});`;
1136
1253
  }
1137
1254
  if (devServer) {
1138
1255
  const templateName = getPosixBasenameWithoutExt(id);
1139
- const optionalFilePrefix = path5.dirname(id) + path5.sep + (templateName === "index" ? "" : `${templateName}.`);
1256
+ const optionalFilePrefix = path6.dirname(id) + path6.sep + (templateName === "index" ? "" : `${templateName}.`);
1140
1257
  for (const file of meta.watchFiles) {
1141
1258
  this.addWatchFile(file);
1142
1259
  }
@@ -1175,13 +1292,13 @@ if (import.meta.hot) import.meta.hot.accept(() => {});`;
1175
1292
  );
1176
1293
  }
1177
1294
  if (isSSRBuild) {
1178
- const dir = outputOptions.dir ? path5.resolve(outputOptions.dir) : path5.resolve(outputOptions.file, "..");
1295
+ const dir = outputOptions.dir ? path6.resolve(outputOptions.dir) : path6.resolve(outputOptions.file, "..");
1179
1296
  for (const fileName in bundle) {
1180
1297
  const chunk = bundle[fileName];
1181
1298
  if (chunk.type === "chunk") {
1182
1299
  if (chunk.moduleIds.includes(renderAssetsRuntimeId)) {
1183
1300
  serverManifest.chunksNeedingAssets.push(
1184
- path5.resolve(dir, fileName)
1301
+ path6.resolve(dir, fileName)
1185
1302
  );
1186
1303
  }
1187
1304
  }
@@ -1230,7 +1347,7 @@ function isMarkoFile(id) {
1230
1347
  function toHTMLEntries(root, serverEntries) {
1231
1348
  const result = [];
1232
1349
  for (const id in serverEntries) {
1233
- const markoFile = path5.posix.join(root, serverEntries[id]);
1350
+ const markoFile = path6.posix.join(root, serverEntries[id]);
1234
1351
  const htmlFile = markoFile + htmlExt;
1235
1352
  virtualFiles.set(htmlFile, {
1236
1353
  code: generateInputDoc(markoFile + browserEntryQuery)
@@ -1251,7 +1368,7 @@ function toEntryId(id) {
1251
1368
  return `${name}_${crypto.createHash("SHA1").update(id).digest("base64").replace(/[/+]/g, "-").slice(0, 4)}`;
1252
1369
  }
1253
1370
  function posixFileNameToURL(fileName, root) {
1254
- const relativeURL = path5.posix.relative(
1371
+ const relativeURL = path6.posix.relative(
1255
1372
  pathToFileURL(root).pathname,
1256
1373
  pathToFileURL(fileName).pathname
1257
1374
  );
@@ -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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@marko/vite",
3
3
  "description": "A Marko plugin for Vite",
4
- "version": "4.1.16",
4
+ "version": "4.1.18",
5
5
  "author": "Dylan Piercey <dpiercey@ebay.com>",
6
6
  "bugs": "https://github.com/marko-js/vite/issues",
7
7
  "dependencies": {