@webjsdev/server 0.8.77 → 0.8.78

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": "@webjsdev/server",
3
- "version": "0.8.77",
3
+ "version": "0.8.78",
4
4
  "type": "module",
5
5
  "description": "The server for WebJs, a full-stack JavaScript framework built on web components with server-side rendering and no build step. Provides the file-based router, SSR, server actions, route handlers, middleware, and live reload on Node 24+ or Bun.",
6
6
  "main": "index.js",
@@ -1608,6 +1608,9 @@ export function lazyComponentFiles(components, elidable) {
1608
1608
  return out;
1609
1609
  }
1610
1610
 
1611
+ /** A test module (the same rule the component scanner skips). */
1612
+ const TEST_FILE_RE = /\.(test|spec)\.m?[jt]sx?$/;
1613
+
1611
1614
  /** `import <bindings> from 'x'` (the bindings part is captured). */
1612
1615
  const BINDING_IMPORT_RE = /\bimport\s+(type\s+)?([\w$*{}\s,]+?)\s+from\s+(['"])([^'"]+)\3/g;
1613
1616
  /** `export { a } from 'x'` / `export * from 'x'` (a re-export needs the module too). */
@@ -1636,7 +1639,9 @@ function typeOnlyClause(typeKw, clause) {
1636
1639
  * skip a module the browser still fetches up front, which only makes it slower.
1637
1640
  *
1638
1641
  * Only importers whose graph edges reach a lazy file are read. A server file is
1639
- * never served, so its imports do not count.
1642
+ * never served, and a test file (`*.test.*` / `*.spec.*`) never ships to a
1643
+ * page, so their imports do not count: a component's own browser test imports
1644
+ * it with bindings, and that must not make it eager in the app.
1640
1645
  *
1641
1646
  * @param {Map<string, string[]>} lazyFiles
1642
1647
  * @param {import('./module-graph.js').ModuleGraph | undefined} moduleGraph
@@ -1650,7 +1655,7 @@ export async function bindingImportedLazyFiles(lazyFiles, moduleGraph, readFileF
1650
1655
  const out = new Set();
1651
1656
  if (!lazyFiles.size || !moduleGraph) return out;
1652
1657
  for (const [importer, deps] of moduleGraph) {
1653
- if (SERVER_FILE_RE.test(importer)) continue;
1658
+ if (SERVER_FILE_RE.test(importer) || TEST_FILE_RE.test(importer)) continue;
1654
1659
  let reaches = false;
1655
1660
  for (const d of deps) if (lazyFiles.has(d) && !out.has(d)) { reaches = true; break; }
1656
1661
  if (!reaches) continue;