@marko/vite 5.4.1 → 5.4.2

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 +47 -24
  2. package/package.json +28 -28
package/dist/index.mjs CHANGED
@@ -750,7 +750,9 @@ import path5 from "path";
750
750
  var server_entry_template_default = async (opts) => {
751
751
  const fileNameStr = JSON.stringify(`./${path5.basename(opts.fileName)}`);
752
752
  if (opts.tagsAPI) {
753
- return `import Template from ${fileNameStr};
753
+ return `
754
+ <!-- use tags -->
755
+ import Template from ${fileNameStr};
754
756
  export * from ${fileNameStr};
755
757
  import { addAssets, getPrepend, getAppend } from "${renderAssetsRuntimeId}";
756
758
  static function flush($global, html) {
@@ -765,17 +767,19 @@ static function setFlush($global) {
765
767
  -- $!{writeSync && getAppend($global)}
766
768
  `;
767
769
  }
768
- return `import template from ${fileNameStr};
770
+ return `
771
+ <!-- use class -->
772
+ import Template from ${fileNameStr};
769
773
  export * from ${fileNameStr};
770
774
  import { addAssets, getPrepend, getAppend } from "${renderAssetsRuntimeId}";
771
775
  <if(addAssets($global, [${opts.entryData.join(",")}]))>
772
776
  $!{getPrepend($global)}
773
- <\${template} ...input/>
777
+ <Template ...input/>
774
778
  $!{getAppend($global)}
775
779
  </>
776
780
  <else>
777
781
  <__flush_here_and_after__>$!{getPrepend($global)}</>
778
- <\${template} ...input/>
782
+ <Template ...input/>
779
783
  <init-components/>
780
784
  <await-reorderer/>
781
785
  <__flush_here_and_after__>$!{getAppend($global)}</>
@@ -862,24 +866,27 @@ function markoPlugin(opts = {}) {
862
866
  `vite-marko${runtimeId ? `-${runtimeId}` : ""}`
863
867
  );
864
868
  const isTagsApi = /* @__PURE__ */ (() => {
865
- let tagsAPI;
866
- return () => {
867
- if (tagsAPI === void 0) {
869
+ let defaultIsTagsAPI;
870
+ return (api) => {
871
+ if (api) {
872
+ return api === "tags";
873
+ }
874
+ if (defaultIsTagsAPI === void 0) {
868
875
  const translatorPackage = opts.translator || compiler2.globalConfig?.translator || "marko/translator";
869
876
  if (/^@marko\/translator-(?:default|interop-class-tags)$/.test(
870
877
  translatorPackage
871
878
  )) {
872
- tagsAPI = false;
879
+ defaultIsTagsAPI = false;
873
880
  } else {
874
881
  try {
875
882
  const require2 = createRequire(import.meta.url);
876
- tagsAPI = require2(translatorPackage).preferAPI !== "class";
883
+ defaultIsTagsAPI = require2(translatorPackage).preferAPI !== "class";
877
884
  } catch {
878
- tagsAPI = true;
885
+ defaultIsTagsAPI = true;
879
886
  }
880
887
  }
881
888
  }
882
- return tagsAPI;
889
+ return defaultIsTagsAPI;
883
890
  };
884
891
  })();
885
892
  return [
@@ -1320,7 +1327,7 @@ function markoPlugin(opts = {}) {
1320
1327
  return cachedSources.get(id.slice(0, -query.length)) || null;
1321
1328
  }
1322
1329
  default:
1323
- return virtualFiles.get(id) || cacheDir && fs4.promises.readFile(
1330
+ return virtualFiles.get(id) || cachedSources.get(id) || cacheDir && fs4.promises.readFile(
1324
1331
  virtualPathToCacheFile(id, root, cacheDir),
1325
1332
  "utf8"
1326
1333
  ).then((code) => {
@@ -1331,7 +1338,7 @@ function markoPlugin(opts = {}) {
1331
1338
  });
1332
1339
  }
1333
1340
  }
1334
- return virtualFiles.get(id) || null;
1341
+ return virtualFiles.get(id) || cachedSources.get(id) || null;
1335
1342
  },
1336
1343
  async transform(source, rawId, ssr) {
1337
1344
  let id = stripViteQueries(rawId);
@@ -1385,7 +1392,9 @@ function markoPlugin(opts = {}) {
1385
1392
  entryData,
1386
1393
  runtimeId,
1387
1394
  basePathVar: isBuild ? basePathVar : void 0,
1388
- tagsAPI: isTagsApi()
1395
+ tagsAPI: isTagsApi(
1396
+ ("transformRequest" in this.environment ? (await this.environment.transformRequest(fileName), this.getModuleInfo(fileName)) : await this.load({ id: fileName }))?.meta.markoAPI
1397
+ )
1389
1398
  });
1390
1399
  }
1391
1400
  }
@@ -1426,7 +1435,11 @@ function markoPlugin(opts = {}) {
1426
1435
  return {
1427
1436
  code: code2,
1428
1437
  map: stripSourceRoot(map),
1429
- meta: { arcSourceCode: source, arcScanIds: meta2.analyzedTags }
1438
+ meta: {
1439
+ markoAPI: meta2.api,
1440
+ arcSourceCode: source,
1441
+ arcScanIds: meta2.analyzedTags
1442
+ }
1430
1443
  };
1431
1444
  }
1432
1445
  }
@@ -1441,7 +1454,7 @@ function markoPlugin(opts = {}) {
1441
1454
  );
1442
1455
  const { meta } = compiled;
1443
1456
  let { code } = compiled;
1444
- if (!isTest && query !== browserEntryQuery && devServer && !isTagsApi()) {
1457
+ if (!isTest && query !== browserEntryQuery && devServer && !isTagsApi(meta.api)) {
1445
1458
  code += `
1446
1459
  if (import.meta.hot) import.meta.hot.accept(() => {});`;
1447
1460
  }
@@ -1451,18 +1464,28 @@ if (import.meta.hot) import.meta.hot.accept(() => {});`;
1451
1464
  for (const file of meta.watchFiles) {
1452
1465
  this.addWatchFile(file);
1453
1466
  }
1454
- transformOptionalFiles.set(id, [
1455
- `${optionalFilePrefix}style.*`,
1456
- `${optionalFilePrefix}component.*`,
1457
- `${optionalFilePrefix}component-browser.*`,
1458
- `${optionalFilePrefix}marko-tag.json`
1459
- ]);
1460
- transformWatchFiles.set(id, meta.watchFiles);
1467
+ transformOptionalFiles.set(
1468
+ id,
1469
+ meta.api === "tags" ? [`${optionalFilePrefix}style.*`] : [
1470
+ `${optionalFilePrefix}style.*`,
1471
+ `${optionalFilePrefix}marko-tag.json`,
1472
+ `${optionalFilePrefix}component.*`,
1473
+ `${optionalFilePrefix}component-browser.*`
1474
+ ]
1475
+ );
1476
+ transformWatchFiles.set(
1477
+ id,
1478
+ meta.analyzedTags ? meta.analyzedTags.concat(meta.watchFiles) : meta.watchFiles
1479
+ );
1461
1480
  }
1462
1481
  return {
1463
1482
  code,
1464
1483
  map: stripSourceRoot(compiled.map),
1465
- meta: isBuild ? { arcSourceCode: source, arcScanIds: meta.analyzedTags } : void 0
1484
+ meta: isBuild ? {
1485
+ markoAPI: meta.api,
1486
+ arcSourceCode: source,
1487
+ arcScanIds: meta.analyzedTags
1488
+ } : { markoAPI: meta.api }
1466
1489
  };
1467
1490
  }
1468
1491
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/vite",
3
- "version": "5.4.1",
3
+ "version": "5.4.2",
4
4
  "description": "A Marko plugin for Vite",
5
5
  "keywords": [
6
6
  "loader",
@@ -41,53 +41,53 @@
41
41
  "version": "changeset version && npm i --package-lock-only"
42
42
  },
43
43
  "dependencies": {
44
- "@chialab/cjs-to-esm": "^0.18.0",
44
+ "@chialab/cjs-to-esm": "^0.19.0",
45
45
  "anymatch": "^3.1.3",
46
46
  "domelementtype": "^2.3.0",
47
47
  "domhandler": "^5.0.3",
48
48
  "fast-glob": "^3.3.3",
49
49
  "htmlparser2": "^10.0.0",
50
50
  "relative-import-path": "^1.0.0",
51
- "resolve": "^1.22.10",
51
+ "resolve": "^1.22.11",
52
52
  "resolve.exports": "^2.0.3"
53
53
  },
54
54
  "devDependencies": {
55
- "@changesets/changelog-github": "^0.5.1",
56
- "@changesets/cli": "^2.29.5",
57
- "@eslint/js": "^9.31.0",
58
- "@marko/compiler": "^5.39.29",
55
+ "@changesets/changelog-github": "^0.5.2",
56
+ "@changesets/cli": "^2.29.8",
57
+ "@eslint/js": "^9.39.1",
58
+ "@marko/compiler": "^5.39.45",
59
59
  "@marko/fixture-snapshots": "^2.2.1",
60
- "@marko/testing-library": "^6.3.1",
60
+ "@marko/testing-library": "^6.4.1",
61
61
  "@types/babel__core": "^7.20.5",
62
62
  "@types/diff": "^8.0.0",
63
- "@types/jsdom": "^21.1.7",
63
+ "@types/jsdom": "^27.0.0",
64
64
  "@types/mocha": "^10.0.10",
65
- "@types/node": "^24.0.14",
65
+ "@types/node": "^25.0.1",
66
66
  "@types/resolve": "^1.20.6",
67
67
  "@types/serve-handler": "^6.1.4",
68
- "cross-env": "^7.0.3",
68
+ "cross-env": "^10.1.0",
69
69
  "diff": "^8.0.2",
70
- "esbuild": "^0.25.6",
71
- "eslint": "^9.31.0",
72
- "eslint-formatter-unix": "^8.40.0",
70
+ "esbuild": "^0.27.1",
71
+ "eslint": "^9.39.1",
72
+ "eslint-formatter-unix": "^9.0.1",
73
73
  "eslint-plugin-simple-import-sort": "^12.1.1",
74
- "globals": "^16.3.0",
74
+ "globals": "^16.5.0",
75
75
  "husky": "^9.1.7",
76
- "jsdom": "^26.1.0",
77
- "less": "^4.3.0",
78
- "lint-staged": "^16.1.2",
79
- "marko": "^5.37.41",
80
- "mocha": "^11.7.1",
81
- "mocha-snap": "^5.0.0",
76
+ "jsdom": "^27.3.0",
77
+ "less": "^4.4.2",
78
+ "lint-staged": "^16.2.7",
79
+ "marko": "^5.38.2",
80
+ "mocha": "^11.7.5",
81
+ "mocha-snap": "^5.0.1",
82
82
  "nyc": "^17.1.0",
83
- "playwright": "^1.54.1",
84
- "prettier": "^3.6.2",
85
- "prettier-plugin-packagejson": "^2.5.18",
83
+ "playwright": "^1.57.0",
84
+ "prettier": "^3.7.4",
85
+ "prettier-plugin-packagejson": "^2.5.20",
86
86
  "serve-handler": "^6.1.6",
87
- "tsx": "^4.20.3",
88
- "typescript": "^5.8.3",
89
- "typescript-eslint": "^8.37.0",
90
- "vite": "^7.1.10"
87
+ "tsx": "^4.21.0",
88
+ "typescript": "^5.9.3",
89
+ "typescript-eslint": "^8.49.0",
90
+ "vite": "^7.2.7"
91
91
  },
92
92
  "peerDependencies": {
93
93
  "@marko/compiler": "^5",