@marko/language-tools 2.2.0 → 2.2.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.
package/dist/index.js CHANGED
@@ -1533,14 +1533,17 @@ var import_fs = __toESM(require("fs"));
1533
1533
  var import_path = __toESM(require("path"));
1534
1534
  function getComponentFilename(from) {
1535
1535
  const dir = import_path.default.dirname(from);
1536
- const nameNoExt = import_path.default.basename(from, ".marko");
1536
+ let nameNoExt = import_path.default.basename(from, ".marko");
1537
+ if (nameNoExt.endsWith(".d")) {
1538
+ nameNoExt = nameNoExt.slice(0, -2);
1539
+ }
1537
1540
  const isEntry = nameNoExt === "index";
1538
- const componentFull = `${nameNoExt}.component.`;
1539
- const componentBrowserFull = `${nameNoExt}.component-browser.`;
1540
- const componentPartial = isEntry ? "component." : void 0;
1541
- const componentBrowserPartial = isEntry ? "component-browser." : void 0;
1541
+ const fileMatch = `(${nameNoExt.replace(/[.*+?^$[\]()|\\:!{}]/g, "\\$&")}\\.${isEntry ? "|" : ""})`;
1542
+ const componentMatch = new RegExp(
1543
+ `^${fileMatch}component(-browser)?\\.\\w+$`
1544
+ );
1542
1545
  for (const entry of tryReaddirSync(dir)) {
1543
- if (entry !== from && (isEntry && entry.startsWith(componentBrowserPartial) || entry.startsWith(componentPartial)) || entry.startsWith(componentBrowserFull) || entry.startsWith(componentFull)) {
1546
+ if (componentMatch.test(entry)) {
1544
1547
  return import_path.default.join(dir, entry);
1545
1548
  }
1546
1549
  }
package/dist/index.mjs CHANGED
@@ -1501,14 +1501,17 @@ import fs from "fs";
1501
1501
  import path from "path";
1502
1502
  function getComponentFilename(from) {
1503
1503
  const dir = path.dirname(from);
1504
- const nameNoExt = path.basename(from, ".marko");
1504
+ let nameNoExt = path.basename(from, ".marko");
1505
+ if (nameNoExt.endsWith(".d")) {
1506
+ nameNoExt = nameNoExt.slice(0, -2);
1507
+ }
1505
1508
  const isEntry = nameNoExt === "index";
1506
- const componentFull = `${nameNoExt}.component.`;
1507
- const componentBrowserFull = `${nameNoExt}.component-browser.`;
1508
- const componentPartial = isEntry ? "component." : void 0;
1509
- const componentBrowserPartial = isEntry ? "component-browser." : void 0;
1509
+ const fileMatch = `(${nameNoExt.replace(/[.*+?^$[\]()|\\:!{}]/g, "\\$&")}\\.${isEntry ? "|" : ""})`;
1510
+ const componentMatch = new RegExp(
1511
+ `^${fileMatch}component(-browser)?\\.\\w+$`
1512
+ );
1510
1513
  for (const entry of tryReaddirSync(dir)) {
1511
- if (entry !== from && (isEntry && entry.startsWith(componentBrowserPartial) || entry.startsWith(componentPartial)) || entry.startsWith(componentBrowserFull) || entry.startsWith(componentFull)) {
1514
+ if (componentMatch.test(entry)) {
1512
1515
  return path.join(dir, entry);
1513
1516
  }
1514
1517
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@marko/language-tools",
3
3
  "description": "Marko Language Tools",
4
- "version": "2.2.0",
4
+ "version": "2.2.2",
5
5
  "bugs": "https://github.com/marko-js/language-server/issues/new?template=Bug_report.md",
6
6
  "peerDependencies": {
7
7
  "@marko/compiler": "^5.28.4"