@stati/core 1.20.2 → 1.20.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.
@@ -171,6 +171,17 @@ async function collectTemplateDependencies(templatePath, srcDir, visited, curren
171
171
  async function parseTemplateDependencies(content, templatePath, srcDir) {
172
172
  const dependencies = [];
173
173
  const templateDir = dirname(templatePath);
174
+ // Strip comments from template content to avoid false positives
175
+ // This removes:
176
+ // 1. Eta block comments: <% /* ... */ %> or <% /** ... */ %>
177
+ // 2. JavaScript single-line comments within Eta blocks: <% // ... %>
178
+ // 3. JavaScript block comments within Eta blocks (handles multi-line)
179
+ const contentWithoutComments = content
180
+ // Remove JS block comments (/* ... */) - handles multi-line
181
+ .replace(/\/\*[\s\S]*?\*\//g, '')
182
+ // Remove JS single-line comments (// ...) but only within Eta blocks
183
+ // This is tricky - we'll be conservative and just remove // comments to end of line
184
+ .replace(/\/\/[^\n]*/g, '');
174
185
  // Look for Eta include patterns: <%~ include('template') %>
175
186
  const includePatterns = [
176
187
  /<%[~-]?\s*include\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g,
@@ -178,7 +189,7 @@ async function parseTemplateDependencies(content, templatePath, srcDir) {
178
189
  ];
179
190
  for (const pattern of includePatterns) {
180
191
  let match;
181
- while ((match = pattern.exec(content)) !== null) {
192
+ while ((match = pattern.exec(contentWithoutComments)) !== null) {
182
193
  const includePath = match[1];
183
194
  if (includePath) {
184
195
  const resolvedPath = await resolveTemplatePathInternal(includePath, srcDir, templateDir);
@@ -195,7 +206,7 @@ async function parseTemplateDependencies(content, templatePath, srcDir) {
195
206
  ];
196
207
  for (const pattern of layoutPatterns) {
197
208
  let match;
198
- while ((match = pattern.exec(content)) !== null) {
209
+ while ((match = pattern.exec(contentWithoutComments)) !== null) {
199
210
  const layoutPath = match[1];
200
211
  if (layoutPath) {
201
212
  const resolvedPath = await resolveTemplatePathInternal(layoutPath, srcDir, templateDir);
@@ -236,7 +247,7 @@ async function parseTemplateDependencies(content, templatePath, srcDir) {
236
247
  const foundPartials = new Set();
237
248
  for (const pattern of partialPatterns) {
238
249
  let match;
239
- while ((match = pattern.exec(content)) !== null) {
250
+ while ((match = pattern.exec(contentWithoutComments)) !== null) {
240
251
  const partialName = match[1];
241
252
  if (partialName) {
242
253
  foundPartials.add(partialName);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stati/core",
3
- "version": "1.20.2",
3
+ "version": "1.20.3",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",