@marko/language-tools 2.5.15 → 2.5.16

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
@@ -2431,31 +2431,36 @@ constructor(_?: Return) {}
2431
2431
  const renderId = this.#getRenderId(tag);
2432
2432
  const def = tagName ? this.#lookup.getTag(tagName) : void 0;
2433
2433
  const isHTML = def == null ? void 0 : def.html;
2434
- const importPath = !isHTML && resolveTagImport(this.#filename, def);
2434
+ const importPath = !isHTML ? resolveTagImport(this.#filename, def) : void 0;
2435
2435
  let tagIdentifier;
2436
2436
  let isTemplate = false;
2437
2437
  if (!isHTML && (!def || importPath)) {
2438
- const tagId = this.#ensureTagId(tag);
2439
- tagIdentifier = varLocal("tag_" + tagId);
2440
- this.#extractor.write(`const ${tagIdentifier} = (
2438
+ const isIdentifier = tagName && REG_TAG_NAME_IDENTIFIER.test(tagName);
2439
+ const isMarkoFile = importPath == null ? void 0 : importPath.endsWith(".marko");
2440
+ if (isIdentifier || isMarkoFile || !importPath) {
2441
+ tagIdentifier = varLocal("tag_" + this.#ensureTagId(tag));
2442
+ this.#extractor.write(`const ${tagIdentifier} = (
2441
2443
  `);
2442
- if (tagName && REG_TAG_NAME_IDENTIFIER.test(tagName)) {
2443
- if (importPath) {
2444
+ if (isIdentifier) {
2445
+ if (importPath) {
2446
+ this.#extractor.write(
2447
+ `${varShared("fallbackTemplate")}(${tagName},${isMarkoFile ? `import("${importPath}")` : varShared("any")})`
2448
+ );
2449
+ } else {
2450
+ this.#extractor.copy(tag.name);
2451
+ }
2452
+ } else if (isMarkoFile) {
2453
+ isTemplate = true;
2444
2454
  this.#extractor.write(
2445
- `${varShared("fallbackTemplate")}(${tagName},import("${importPath}"))`
2455
+ `${varShared("resolveTemplate")}(import("${importPath}"))`
2446
2456
  );
2447
2457
  } else {
2448
- this.#extractor.copy(tag.name);
2458
+ this.#writeDynamicTagName(tag);
2449
2459
  }
2450
- } else if (importPath) {
2451
- isTemplate = importPath.endsWith(".marko");
2452
- this.#extractor.write(
2453
- `${varShared("resolveTemplate")}(import("${importPath}"))`
2454
- );
2460
+ this.#extractor.write("\n);\n");
2455
2461
  } else {
2456
- this.#writeDynamicTagName(tag);
2462
+ tagIdentifier = varShared("missingTag");
2457
2463
  }
2458
- this.#extractor.write("\n);\n");
2459
2464
  const attrTagTree = this.#getAttrTagTree(tag);
2460
2465
  if (attrTagTree) {
2461
2466
  this.#writeAttrTagTree(attrTagTree, tagIdentifier);
package/dist/index.mjs CHANGED
@@ -2394,31 +2394,36 @@ constructor(_?: Return) {}
2394
2394
  const renderId = this.#getRenderId(tag);
2395
2395
  const def = tagName ? this.#lookup.getTag(tagName) : void 0;
2396
2396
  const isHTML = def == null ? void 0 : def.html;
2397
- const importPath = !isHTML && resolveTagImport(this.#filename, def);
2397
+ const importPath = !isHTML ? resolveTagImport(this.#filename, def) : void 0;
2398
2398
  let tagIdentifier;
2399
2399
  let isTemplate = false;
2400
2400
  if (!isHTML && (!def || importPath)) {
2401
- const tagId = this.#ensureTagId(tag);
2402
- tagIdentifier = varLocal("tag_" + tagId);
2403
- this.#extractor.write(`const ${tagIdentifier} = (
2401
+ const isIdentifier = tagName && REG_TAG_NAME_IDENTIFIER.test(tagName);
2402
+ const isMarkoFile = importPath == null ? void 0 : importPath.endsWith(".marko");
2403
+ if (isIdentifier || isMarkoFile || !importPath) {
2404
+ tagIdentifier = varLocal("tag_" + this.#ensureTagId(tag));
2405
+ this.#extractor.write(`const ${tagIdentifier} = (
2404
2406
  `);
2405
- if (tagName && REG_TAG_NAME_IDENTIFIER.test(tagName)) {
2406
- if (importPath) {
2407
+ if (isIdentifier) {
2408
+ if (importPath) {
2409
+ this.#extractor.write(
2410
+ `${varShared("fallbackTemplate")}(${tagName},${isMarkoFile ? `import("${importPath}")` : varShared("any")})`
2411
+ );
2412
+ } else {
2413
+ this.#extractor.copy(tag.name);
2414
+ }
2415
+ } else if (isMarkoFile) {
2416
+ isTemplate = true;
2407
2417
  this.#extractor.write(
2408
- `${varShared("fallbackTemplate")}(${tagName},import("${importPath}"))`
2418
+ `${varShared("resolveTemplate")}(import("${importPath}"))`
2409
2419
  );
2410
2420
  } else {
2411
- this.#extractor.copy(tag.name);
2421
+ this.#writeDynamicTagName(tag);
2412
2422
  }
2413
- } else if (importPath) {
2414
- isTemplate = importPath.endsWith(".marko");
2415
- this.#extractor.write(
2416
- `${varShared("resolveTemplate")}(import("${importPath}"))`
2417
- );
2423
+ this.#extractor.write("\n);\n");
2418
2424
  } else {
2419
- this.#writeDynamicTagName(tag);
2425
+ tagIdentifier = varShared("missingTag");
2420
2426
  }
2421
- this.#extractor.write("\n);\n");
2422
2427
  const attrTagTree = this.#getAttrTagTree(tag);
2423
2428
  if (attrTagTree) {
2424
2429
  this.#writeAttrTagTree(attrTagTree, tagIdentifier);
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.5.15",
4
+ "version": "2.5.16",
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"