@marko/vite 5.0.10 → 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.
Files changed (2) hide show
  1. package/dist/index.mjs +10 -11
  2. 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 = normalizePath(normalizedFrom) + query;
832
+ const id = normalizedFrom + query;
833
833
  if (devServer) {
834
834
  const prev = virtualFiles.get(id);
835
835
  if (isDeferredPromise(prev)) {
@@ -1205,7 +1205,9 @@ function markoPlugin(opts = {}) {
1205
1205
  id = `${id.slice(0, -markoExt.length)}.entry.marko`;
1206
1206
  cachedSources.set(fileName, source);
1207
1207
  if (isBuild) {
1208
- const relativeFileName = path6.posix.relative(root, fileName);
1208
+ const relativeFileName = normalizePath(
1209
+ path6.relative(root, fileName)
1210
+ );
1209
1211
  const entryId = toEntryId(relativeFileName);
1210
1212
  serverManifest ??= {
1211
1213
  entries: {},
@@ -1223,7 +1225,7 @@ function markoPlugin(opts = {}) {
1223
1225
  await devServer.transformIndexHtml(
1224
1226
  "/",
1225
1227
  generateInputDoc(
1226
- posixFileNameToURL(fileName, root) + browserEntryQuery
1228
+ fileNameToURL(fileName, root) + browserEntryQuery
1227
1229
  )
1228
1230
  )
1229
1231
  )
@@ -1425,7 +1427,7 @@ function isMarkoFile(id) {
1425
1427
  function toHTMLEntries(root, serverEntries) {
1426
1428
  const result = [];
1427
1429
  for (const id in serverEntries) {
1428
- const markoFile = path6.posix.join(root, serverEntries[id]);
1430
+ const markoFile = normalizePath(path6.join(root, serverEntries[id]));
1429
1431
  const htmlFile = markoFile + htmlExt;
1430
1432
  virtualFiles.set(htmlFile, {
1431
1433
  code: generateInputDoc(markoFile + browserEntryQuery)
@@ -1443,13 +1445,10 @@ function toEntryId(id) {
1443
1445
  lastSepIndex
1444
1446
  );
1445
1447
  }
1446
- return `${name}_${crypto.createHash("SHA1").update(id).digest("base64").replace(/[/+]/g, "-").slice(0, 4)}`;
1448
+ return `${name}_${crypto.createHash("shake256", TEMPLATE_ID_HASH_OPTS).update(id).digest("base64url")}`;
1447
1449
  }
1448
- function posixFileNameToURL(fileName, root) {
1449
- const relativeURL = path6.posix.relative(
1450
- pathToFileURL(root).pathname,
1451
- pathToFileURL(fileName).pathname
1452
- );
1450
+ function fileNameToURL(fileName, root) {
1451
+ const relativeURL = normalizePath(path6.relative(root, fileName));
1453
1452
  if (relativeURL[0] === ".") {
1454
1453
  throw new Error(
1455
1454
  "@marko/vite: Entry templates must exist under the current root directory."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/vite",
3
- "version": "5.0.10",
3
+ "version": "5.0.11",
4
4
  "description": "A Marko plugin for Vite",
5
5
  "keywords": [
6
6
  "loader",