ember-estree 0.4.1 → 0.4.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-estree",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "ESTree generator for gjs and gts file used by ember",
5
5
  "keywords": [
6
6
  "AST",
@@ -42,16 +42,16 @@
42
42
  "oxfmt": "^0.40.0",
43
43
  "oxlint": "^1.55.0",
44
44
  "publint": "^0.3.18",
45
- "release-plan": "^0.17.4",
45
+ "release-plan": "^0.18.0",
46
46
  "typescript": "^5.9.3",
47
47
  "vitest": "^3.2.4"
48
48
  },
49
49
  "scripts": {
50
- "format": "oxfmt",
51
- "format:check": "oxfmt --check",
52
50
  "bench": "node --expose-gc tests/parser.bench.mjs",
53
51
  "bench:compare": "node scripts/bench-compare.mjs",
54
52
  "bench:summary": "./scripts/local-bench-summary.sh",
53
+ "format": "oxfmt",
54
+ "format:check": "oxfmt --check",
55
55
  "lint": "oxlint && pnpm format:check && publint",
56
56
  "lint:fix": "oxlint --fix && oxfmt",
57
57
  "test": "vitest run"
package/src/parse.js CHANGED
@@ -58,6 +58,9 @@ export function toTree(source, options = {}) {
58
58
  }
59
59
  } else {
60
60
  let filename = options.filePath || "input.ts";
61
+ if (filename.includes(".gts")) {
62
+ filename = filename.replace(/\.gts$/, ".ts");
63
+ }
61
64
  let oxcResult = parseSync(filename, js);
62
65
  result = {
63
66
  ast: {
@@ -81,7 +84,6 @@ export function toTree(source, options = {}) {
81
84
  }
82
85
 
83
86
  const codeLines = new DocumentLines(source);
84
- const allComments = [];
85
87
  const templateInfos = [];
86
88
 
87
89
  // Build a map of template ranges for lookup
@@ -96,12 +98,7 @@ export function toTree(source, options = {}) {
96
98
  ];
97
99
  let fullRange = [parseResult.range.startUtf16Codepoint, parseResult.range.endUtf16Codepoint];
98
100
 
99
- const { ast, comments } = processTemplate(
100
- templateContent,
101
- codeLines,
102
- contentRange,
103
- templateOpts,
104
- );
101
+ const { ast } = processTemplate(templateContent, codeLines, contentRange, templateOpts);
105
102
 
106
103
  // Fix the Template root to cover the full <template>...</template> range
107
104
  ast.range = fullRange;
@@ -134,7 +131,6 @@ export function toTree(source, options = {}) {
134
131
  makeToken(closeTag, [closeStart, fullRange[1]]),
135
132
  ];
136
133
 
137
- allComments.push(...comments);
138
134
  templateInfos.push({ utf16Range: fullRange, ast });
139
135
  return ast;
140
136
  }
@@ -276,12 +272,6 @@ export function toTree(source, options = {}) {
276
272
  }
277
273
  }
278
274
 
279
- // Merge comments
280
- if (allComments.length) {
281
- if (!astRoot.comments) astRoot.comments = [];
282
- astRoot.comments.push(...allComments);
283
- }
284
-
285
275
  if (useCustomParser) {
286
276
  result.visitorKeys = { ...result.visitorKeys, ...glimmerVisitorKeys };
287
277
  result.templateInfos = templateInfos;
package/src/print.js CHANGED
@@ -860,7 +860,7 @@ export function print(node) {
860
860
  return `<!--${node.value ?? ""}-->`;
861
861
 
862
862
  case "GlimmerMustacheCommentStatement":
863
- return `{{! ${node.value ?? ""} }}`;
863
+ return node.longForm ? `{{!-- ${node.value ?? ""} --}}` : `{{! ${node.value ?? ""} }}`;
864
864
 
865
865
  case "GlimmerElementModifierStatement": {
866
866
  const path = print(node.path);
package/src/transforms.js CHANGED
@@ -248,6 +248,10 @@ export function processTemplate(
248
248
  n.end = n.range[1];
249
249
  n.loc = toFileLoc(n.range);
250
250
 
251
+ if (n.type === "MustacheCommentStatement") {
252
+ n.longForm = templateContent.slice(n.start - offset, n.start - offset + 4) === "{{!-";
253
+ }
254
+
251
255
  // Create parts for ElementNode
252
256
  if (n.type === "ElementNode") {
253
257
  n.name = n.tag;
@@ -329,10 +333,6 @@ export function processTemplate(
329
333
  visit(ast, null);
330
334
 
331
335
  removeFromParent(emptyTextNodes);
332
- removeFromParent(comments);
333
- for (const comment of comments) {
334
- comment.type = "Block";
335
- }
336
336
 
337
337
  ast.tokens = buildTokenStream(tokenize(templateContent, codeLines, offset), comments, textNodes);
338
338
  ast.contents = templateContent;