@marko/vite 5.0.9 → 5.0.11
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 +13 -12
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4,8 +4,8 @@ import anyMatch from "anymatch";
|
|
|
4
4
|
import crypto from "crypto";
|
|
5
5
|
import glob2 from "fast-glob";
|
|
6
6
|
import fs4 from "fs";
|
|
7
|
+
import { createRequire } from "module";
|
|
7
8
|
import path6 from "path";
|
|
8
|
-
import { pathToFileURL } from "url";
|
|
9
9
|
|
|
10
10
|
// src/babel-plugin-cjs-interop.ts
|
|
11
11
|
import * as t from "@babel/types";
|
|
@@ -791,6 +791,7 @@ static const assets = [${opts.entryData.join(",")}];
|
|
|
791
791
|
// src/index.ts
|
|
792
792
|
var POSIX_SEP = "/";
|
|
793
793
|
var WINDOWS_SEP = "\\";
|
|
794
|
+
var TEMPLATE_ID_HASH_OPTS = { outputLength: 3 };
|
|
794
795
|
var normalizePath = path6.sep === WINDOWS_SEP ? (id) => id.replace(/\\/g, POSIX_SEP) : (id) => id;
|
|
795
796
|
var virtualFiles = /* @__PURE__ */ new Map();
|
|
796
797
|
var extReg = /\.[^.]+$/;
|
|
@@ -828,7 +829,7 @@ function markoPlugin(opts = {}) {
|
|
|
828
829
|
const resolveVirtualDependency = (from, dep) => {
|
|
829
830
|
const normalizedFrom = normalizePath(from);
|
|
830
831
|
const query = `${virtualFileQuery}&id=${Buffer.from(dep.virtualPath).toString("base64url") + path6.extname(dep.virtualPath)}`;
|
|
831
|
-
const id =
|
|
832
|
+
const id = normalizedFrom + query;
|
|
832
833
|
if (devServer) {
|
|
833
834
|
const prev = virtualFiles.get(id);
|
|
834
835
|
if (isDeferredPromise(prev)) {
|
|
@@ -1204,7 +1205,9 @@ function markoPlugin(opts = {}) {
|
|
|
1204
1205
|
id = `${id.slice(0, -markoExt.length)}.entry.marko`;
|
|
1205
1206
|
cachedSources.set(fileName, source);
|
|
1206
1207
|
if (isBuild) {
|
|
1207
|
-
const relativeFileName =
|
|
1208
|
+
const relativeFileName = normalizePath(
|
|
1209
|
+
path6.relative(root, fileName)
|
|
1210
|
+
);
|
|
1208
1211
|
const entryId = toEntryId(relativeFileName);
|
|
1209
1212
|
serverManifest ??= {
|
|
1210
1213
|
entries: {},
|
|
@@ -1222,7 +1225,7 @@ function markoPlugin(opts = {}) {
|
|
|
1222
1225
|
await devServer.transformIndexHtml(
|
|
1223
1226
|
"/",
|
|
1224
1227
|
generateInputDoc(
|
|
1225
|
-
|
|
1228
|
+
fileNameToURL(fileName, root) + browserEntryQuery
|
|
1226
1229
|
)
|
|
1227
1230
|
)
|
|
1228
1231
|
)
|
|
@@ -1245,7 +1248,8 @@ function markoPlugin(opts = {}) {
|
|
|
1245
1248
|
tagsAPI = false;
|
|
1246
1249
|
} else {
|
|
1247
1250
|
try {
|
|
1248
|
-
|
|
1251
|
+
const require2 = createRequire(import.meta.url);
|
|
1252
|
+
tagsAPI = require2(translatorPackage).preferAPI !== "class";
|
|
1249
1253
|
} catch {
|
|
1250
1254
|
tagsAPI = true;
|
|
1251
1255
|
}
|
|
@@ -1423,7 +1427,7 @@ function isMarkoFile(id) {
|
|
|
1423
1427
|
function toHTMLEntries(root, serverEntries) {
|
|
1424
1428
|
const result = [];
|
|
1425
1429
|
for (const id in serverEntries) {
|
|
1426
|
-
const markoFile = path6.
|
|
1430
|
+
const markoFile = normalizePath(path6.join(root, serverEntries[id]));
|
|
1427
1431
|
const htmlFile = markoFile + htmlExt;
|
|
1428
1432
|
virtualFiles.set(htmlFile, {
|
|
1429
1433
|
code: generateInputDoc(markoFile + browserEntryQuery)
|
|
@@ -1441,13 +1445,10 @@ function toEntryId(id) {
|
|
|
1441
1445
|
lastSepIndex
|
|
1442
1446
|
);
|
|
1443
1447
|
}
|
|
1444
|
-
return `${name}_${crypto.createHash("
|
|
1448
|
+
return `${name}_${crypto.createHash("shake256", TEMPLATE_ID_HASH_OPTS).update(id).digest("base64url")}`;
|
|
1445
1449
|
}
|
|
1446
|
-
function
|
|
1447
|
-
const relativeURL = path6.
|
|
1448
|
-
pathToFileURL(root).pathname,
|
|
1449
|
-
pathToFileURL(fileName).pathname
|
|
1450
|
-
);
|
|
1450
|
+
function fileNameToURL(fileName, root) {
|
|
1451
|
+
const relativeURL = normalizePath(path6.relative(root, fileName));
|
|
1451
1452
|
if (relativeURL[0] === ".") {
|
|
1452
1453
|
throw new Error(
|
|
1453
1454
|
"@marko/vite: Entry templates must exist under the current root directory."
|