@marko/vite 5.4.0 → 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 -34
  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 [
@@ -1063,10 +1070,6 @@ function markoPlugin(opts = {}) {
1063
1070
  config.build.commonjsOptions ??= {};
1064
1071
  config.build.commonjsOptions.esmExternals = (id) => !isCJSModule(id, rootResolveFile);
1065
1072
  }
1066
- if (linked && !isSSRBuild) {
1067
- config.build ??= {};
1068
- config.build.emptyOutDir = false;
1069
- }
1070
1073
  if (basePathVar) {
1071
1074
  config.experimental ??= {};
1072
1075
  if (config.experimental.renderBuiltUrl) {
@@ -1128,7 +1131,6 @@ function markoPlugin(opts = {}) {
1128
1131
  }
1129
1132
  }
1130
1133
  options.build ??= {};
1131
- options.build.emptyOutDir = true;
1132
1134
  if (!options.build?.rollupOptions?.output) {
1133
1135
  options.build.rollupOptions ??= {};
1134
1136
  options.build.rollupOptions.output = {
@@ -1139,11 +1141,6 @@ function markoPlugin(opts = {}) {
1139
1141
  options.build.commonjsOptions ??= {};
1140
1142
  options.build.commonjsOptions.esmExternals = (id) => !isCJSModule(id, rootResolveFile);
1141
1143
  }
1142
- } else {
1143
- if (linked) {
1144
- options.build ??= {};
1145
- options.build.emptyOutDir = false;
1146
- }
1147
1144
  }
1148
1145
  return options;
1149
1146
  },
@@ -1330,7 +1327,7 @@ function markoPlugin(opts = {}) {
1330
1327
  return cachedSources.get(id.slice(0, -query.length)) || null;
1331
1328
  }
1332
1329
  default:
1333
- return virtualFiles.get(id) || cacheDir && fs4.promises.readFile(
1330
+ return virtualFiles.get(id) || cachedSources.get(id) || cacheDir && fs4.promises.readFile(
1334
1331
  virtualPathToCacheFile(id, root, cacheDir),
1335
1332
  "utf8"
1336
1333
  ).then((code) => {
@@ -1341,7 +1338,7 @@ function markoPlugin(opts = {}) {
1341
1338
  });
1342
1339
  }
1343
1340
  }
1344
- return virtualFiles.get(id) || null;
1341
+ return virtualFiles.get(id) || cachedSources.get(id) || null;
1345
1342
  },
1346
1343
  async transform(source, rawId, ssr) {
1347
1344
  let id = stripViteQueries(rawId);
@@ -1395,7 +1392,9 @@ function markoPlugin(opts = {}) {
1395
1392
  entryData,
1396
1393
  runtimeId,
1397
1394
  basePathVar: isBuild ? basePathVar : void 0,
1398
- 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
+ )
1399
1398
  });
1400
1399
  }
1401
1400
  }
@@ -1436,7 +1435,11 @@ function markoPlugin(opts = {}) {
1436
1435
  return {
1437
1436
  code: code2,
1438
1437
  map: stripSourceRoot(map),
1439
- meta: { arcSourceCode: source, arcScanIds: meta2.analyzedTags }
1438
+ meta: {
1439
+ markoAPI: meta2.api,
1440
+ arcSourceCode: source,
1441
+ arcScanIds: meta2.analyzedTags
1442
+ }
1440
1443
  };
1441
1444
  }
1442
1445
  }
@@ -1451,7 +1454,7 @@ function markoPlugin(opts = {}) {
1451
1454
  );
1452
1455
  const { meta } = compiled;
1453
1456
  let { code } = compiled;
1454
- if (!isTest && query !== browserEntryQuery && devServer && !isTagsApi()) {
1457
+ if (!isTest && query !== browserEntryQuery && devServer && !isTagsApi(meta.api)) {
1455
1458
  code += `
1456
1459
  if (import.meta.hot) import.meta.hot.accept(() => {});`;
1457
1460
  }
@@ -1461,18 +1464,28 @@ if (import.meta.hot) import.meta.hot.accept(() => {});`;
1461
1464
  for (const file of meta.watchFiles) {
1462
1465
  this.addWatchFile(file);
1463
1466
  }
1464
- transformOptionalFiles.set(id, [
1465
- `${optionalFilePrefix}style.*`,
1466
- `${optionalFilePrefix}component.*`,
1467
- `${optionalFilePrefix}component-browser.*`,
1468
- `${optionalFilePrefix}marko-tag.json`
1469
- ]);
1470
- 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
+ );
1471
1480
  }
1472
1481
  return {
1473
1482
  code,
1474
1483
  map: stripSourceRoot(compiled.map),
1475
- 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 }
1476
1489
  };
1477
1490
  }
1478
1491
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/vite",
3
- "version": "5.4.0",
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",