@marko/vite 5.0.3 → 5.0.4

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 +27 -3
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -3,6 +3,7 @@ import * as compiler2 from "@marko/compiler";
3
3
  import fs4 from "fs";
4
4
  import path6 from "path";
5
5
  import crypto from "crypto";
6
+ import glob2 from "fast-glob";
6
7
  import anyMatch from "anymatch";
7
8
  import { pathToFileURL } from "url";
8
9
 
@@ -802,6 +803,7 @@ var babelCaller = {
802
803
  supportsTopLevelAwait: true,
803
804
  supportsExportNamespaceFrom: true
804
805
  };
806
+ var optimizeKnownTemplatesForRoot = /* @__PURE__ */ new Map();
805
807
  var registeredTagLib = false;
806
808
  var cjsToEsm;
807
809
  function noop2() {
@@ -866,14 +868,14 @@ function markoPlugin(opts = {}) {
866
868
  if ("BASE_URL" in process.env && config.base == null) {
867
869
  config.base = process.env.BASE_URL;
868
870
  }
871
+ root = normalizePath(config.root || process.cwd());
869
872
  baseConfig = {
870
873
  cache,
871
874
  optimize,
872
- // optimizedRegistryIds:
873
- // optimize && linked ? optimizedRegistryIds : undefined,
874
875
  runtimeId,
875
876
  sourceMaps: true,
876
877
  writeVersionComment: false,
878
+ optimizeKnownTemplates: optimize && linked ? await getKnownTemplates(root) : void 0,
877
879
  babelConfig: opts.babelConfig ? {
878
880
  ...opts.babelConfig,
879
881
  caller: opts.babelConfig.caller ? {
@@ -910,7 +912,6 @@ function markoPlugin(opts = {}) {
910
912
  output: "hydrate"
911
913
  };
912
914
  compiler2.configure(baseConfig);
913
- root = normalizePath(config.root || process.cwd());
914
915
  devEntryFile = path6.join(root, "index.html");
915
916
  devEntryFilePosix = normalizePath(devEntryFile);
916
917
  isTest = env.mode === "test";
@@ -1079,6 +1080,7 @@ function markoPlugin(opts = {}) {
1079
1080
  handleHotUpdate(ctx) {
1080
1081
  compiler2.taglib.clearCaches();
1081
1082
  baseConfig.cache.clear();
1083
+ optimizeKnownTemplatesForRoot.clear();
1082
1084
  for (const [, cache2] of configsByFileSystem) {
1083
1085
  cache2.clear();
1084
1086
  }
@@ -1485,6 +1487,28 @@ function getConfigForFileSystem(info, config) {
1485
1487
  }
1486
1488
  return configForFileSystem;
1487
1489
  }
1490
+ function getKnownTemplates(root) {
1491
+ let knownTemplates = optimizeKnownTemplatesForRoot.get(root);
1492
+ if (!knownTemplates) {
1493
+ optimizeKnownTemplatesForRoot.set(
1494
+ root,
1495
+ knownTemplates = glob2.globSync("**/*.marko", {
1496
+ absolute: true,
1497
+ cwd: root,
1498
+ ignore: [
1499
+ "**/*test*/**",
1500
+ "**/*example*/**",
1501
+ "**/*stories*/**",
1502
+ "**/*coverage*/**",
1503
+ "**/*snapshots*/**",
1504
+ "**/node_modules/**",
1505
+ "**/*.d.marko"
1506
+ ]
1507
+ })
1508
+ );
1509
+ }
1510
+ return knownTemplates;
1511
+ }
1488
1512
  export {
1489
1513
  markoPlugin as default
1490
1514
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@marko/vite",
3
3
  "description": "A Marko plugin for Vite",
4
- "version": "5.0.3",
4
+ "version": "5.0.4",
5
5
  "author": "Dylan Piercey <dpiercey@ebay.com>",
6
6
  "bugs": "https://github.com/marko-js/vite/issues",
7
7
  "dependencies": {