@marko/vite 5.0.10 → 5.0.12
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 +15 -14
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,6 @@ import glob2 from "fast-glob";
|
|
|
6
6
|
import fs4 from "fs";
|
|
7
7
|
import { createRequire } from "module";
|
|
8
8
|
import path6 from "path";
|
|
9
|
-
import { pathToFileURL } from "url";
|
|
10
9
|
|
|
11
10
|
// src/babel-plugin-cjs-interop.ts
|
|
12
11
|
import * as t from "@babel/types";
|
|
@@ -792,6 +791,7 @@ static const assets = [${opts.entryData.join(",")}];
|
|
|
792
791
|
// src/index.ts
|
|
793
792
|
var POSIX_SEP = "/";
|
|
794
793
|
var WINDOWS_SEP = "\\";
|
|
794
|
+
var TEMPLATE_ID_HASH_OPTS = { outputLength: 3 };
|
|
795
795
|
var normalizePath = path6.sep === WINDOWS_SEP ? (id) => id.replace(/\\/g, POSIX_SEP) : (id) => id;
|
|
796
796
|
var virtualFiles = /* @__PURE__ */ new Map();
|
|
797
797
|
var extReg = /\.[^.]+$/;
|
|
@@ -829,7 +829,7 @@ function markoPlugin(opts = {}) {
|
|
|
829
829
|
const resolveVirtualDependency = (from, dep) => {
|
|
830
830
|
const normalizedFrom = normalizePath(from);
|
|
831
831
|
const query = `${virtualFileQuery}&id=${Buffer.from(dep.virtualPath).toString("base64url") + path6.extname(dep.virtualPath)}`;
|
|
832
|
-
const id =
|
|
832
|
+
const id = normalizedFrom + query;
|
|
833
833
|
if (devServer) {
|
|
834
834
|
const prev = virtualFiles.get(id);
|
|
835
835
|
if (isDeferredPromise(prev)) {
|
|
@@ -865,6 +865,11 @@ function markoPlugin(opts = {}) {
|
|
|
865
865
|
// Must be pre to allow us to resolve assets before vite.
|
|
866
866
|
async config(config, env) {
|
|
867
867
|
let optimize = env.mode === "production";
|
|
868
|
+
isTest = env.mode === "test";
|
|
869
|
+
isBuild = env.command === "build";
|
|
870
|
+
if (isTest) {
|
|
871
|
+
linked = false;
|
|
872
|
+
}
|
|
868
873
|
if ("MARKO_DEBUG" in process.env) {
|
|
869
874
|
optimize = process.env.MARKO_DEBUG === "false" || process.env.MARKO_DEBUG === "0";
|
|
870
875
|
} else {
|
|
@@ -921,8 +926,6 @@ function markoPlugin(opts = {}) {
|
|
|
921
926
|
compiler2.configure(baseConfig);
|
|
922
927
|
devEntryFile = path6.join(root, "index.html");
|
|
923
928
|
devEntryFilePosix = normalizePath(devEntryFile);
|
|
924
|
-
isTest = env.mode === "test";
|
|
925
|
-
isBuild = env.command === "build";
|
|
926
929
|
isSSRBuild = isBuild && linked && Boolean(config.build.ssr);
|
|
927
930
|
renderAssetsRuntimeCode = getRenderAssetsRuntime({
|
|
928
931
|
isBuild,
|
|
@@ -930,7 +933,6 @@ function markoPlugin(opts = {}) {
|
|
|
930
933
|
runtimeId
|
|
931
934
|
});
|
|
932
935
|
if (isTest) {
|
|
933
|
-
linked = false;
|
|
934
936
|
const { test } = config;
|
|
935
937
|
if (test.environment?.includes("dom")) {
|
|
936
938
|
config.resolve ??= {};
|
|
@@ -1205,7 +1207,9 @@ function markoPlugin(opts = {}) {
|
|
|
1205
1207
|
id = `${id.slice(0, -markoExt.length)}.entry.marko`;
|
|
1206
1208
|
cachedSources.set(fileName, source);
|
|
1207
1209
|
if (isBuild) {
|
|
1208
|
-
const relativeFileName =
|
|
1210
|
+
const relativeFileName = normalizePath(
|
|
1211
|
+
path6.relative(root, fileName)
|
|
1212
|
+
);
|
|
1209
1213
|
const entryId = toEntryId(relativeFileName);
|
|
1210
1214
|
serverManifest ??= {
|
|
1211
1215
|
entries: {},
|
|
@@ -1223,7 +1227,7 @@ function markoPlugin(opts = {}) {
|
|
|
1223
1227
|
await devServer.transformIndexHtml(
|
|
1224
1228
|
"/",
|
|
1225
1229
|
generateInputDoc(
|
|
1226
|
-
|
|
1230
|
+
fileNameToURL(fileName, root) + browserEntryQuery
|
|
1227
1231
|
)
|
|
1228
1232
|
)
|
|
1229
1233
|
)
|
|
@@ -1425,7 +1429,7 @@ function isMarkoFile(id) {
|
|
|
1425
1429
|
function toHTMLEntries(root, serverEntries) {
|
|
1426
1430
|
const result = [];
|
|
1427
1431
|
for (const id in serverEntries) {
|
|
1428
|
-
const markoFile = path6.
|
|
1432
|
+
const markoFile = normalizePath(path6.join(root, serverEntries[id]));
|
|
1429
1433
|
const htmlFile = markoFile + htmlExt;
|
|
1430
1434
|
virtualFiles.set(htmlFile, {
|
|
1431
1435
|
code: generateInputDoc(markoFile + browserEntryQuery)
|
|
@@ -1443,13 +1447,10 @@ function toEntryId(id) {
|
|
|
1443
1447
|
lastSepIndex
|
|
1444
1448
|
);
|
|
1445
1449
|
}
|
|
1446
|
-
return `${name}_${crypto.createHash("
|
|
1450
|
+
return `${name}_${crypto.createHash("shake256", TEMPLATE_ID_HASH_OPTS).update(id).digest("base64url")}`;
|
|
1447
1451
|
}
|
|
1448
|
-
function
|
|
1449
|
-
const relativeURL = path6.
|
|
1450
|
-
pathToFileURL(root).pathname,
|
|
1451
|
-
pathToFileURL(fileName).pathname
|
|
1452
|
-
);
|
|
1452
|
+
function fileNameToURL(fileName, root) {
|
|
1453
|
+
const relativeURL = normalizePath(path6.relative(root, fileName));
|
|
1453
1454
|
if (relativeURL[0] === ".") {
|
|
1454
1455
|
throw new Error(
|
|
1455
1456
|
"@marko/vite: Entry templates must exist under the current root directory."
|