ember-estree 0.4.2 → 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.2",
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
@@ -84,7 +84,6 @@ export function toTree(source, options = {}) {
84
84
  }
85
85
 
86
86
  const codeLines = new DocumentLines(source);
87
- const allComments = [];
88
87
  const templateInfos = [];
89
88
 
90
89
  // Build a map of template ranges for lookup
@@ -99,12 +98,7 @@ export function toTree(source, options = {}) {
99
98
  ];
100
99
  let fullRange = [parseResult.range.startUtf16Codepoint, parseResult.range.endUtf16Codepoint];
101
100
 
102
- const { ast, comments } = processTemplate(
103
- templateContent,
104
- codeLines,
105
- contentRange,
106
- templateOpts,
107
- );
101
+ const { ast } = processTemplate(templateContent, codeLines, contentRange, templateOpts);
108
102
 
109
103
  // Fix the Template root to cover the full <template>...</template> range
110
104
  ast.range = fullRange;
@@ -137,7 +131,6 @@ export function toTree(source, options = {}) {
137
131
  makeToken(closeTag, [closeStart, fullRange[1]]),
138
132
  ];
139
133
 
140
- allComments.push(...comments);
141
134
  templateInfos.push({ utf16Range: fullRange, ast });
142
135
  return ast;
143
136
  }
@@ -279,12 +272,6 @@ export function toTree(source, options = {}) {
279
272
  }
280
273
  }
281
274
 
282
- // Merge comments
283
- if (allComments.length) {
284
- if (!astRoot.comments) astRoot.comments = [];
285
- astRoot.comments.push(...allComments);
286
- }
287
-
288
275
  if (useCustomParser) {
289
276
  result.visitorKeys = { ...result.visitorKeys, ...glimmerVisitorKeys };
290
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;