@webjsdev/server 0.8.37 → 0.8.38

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/vendor.js +24 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webjsdev/server",
3
- "version": "0.8.37",
3
+ "version": "0.8.38",
4
4
  "type": "module",
5
5
  "description": "webjs dev/prod server: SSR, router, API, server actions, live reload",
6
6
  "main": "index.js",
package/src/vendor.js CHANGED
@@ -67,6 +67,18 @@ import { resolveDepVersions } from './bun-pin-rewrite.js';
67
67
  */
68
68
  const BUILTIN = new Set(['@webjsdev/core', '@webjsdev/core/']);
69
69
 
70
+ /**
71
+ * Server-only framework packages that must NEVER be vendored to the browser.
72
+ * Unlike `@webjsdev/core` (browser-bound, served locally via `/__webjs/core/*`),
73
+ * these are pure server packages: the CLI (and its `webjs-bun.mjs` bootstrap
74
+ * import, #675), the SSR runtime, the MCP server. A stray browser-graph scan
75
+ * that surfaces one of them must not push it onto the jspm path (#713). Matched
76
+ * on the extracted package name, so subpaths (`@webjsdev/cli/bin/webjs.js`) are
77
+ * covered. `@webjsdev/ui` is intentionally absent: its components ARE
78
+ * browser-bound, so it stays vendorable.
79
+ */
80
+ const FRAMEWORK_SERVER_ONLY = new Set(['@webjsdev/cli', '@webjsdev/server', '@webjsdev/mcp']);
81
+
70
82
  /**
71
83
  * Scan source files under `dir` for bare import specifiers reachable
72
84
  * from the browser. Returns a Set of package names.
@@ -91,6 +103,12 @@ export async function scanBareImports(dir, skipFiles) {
91
103
  const found = new Set();
92
104
  await walk(dir, found, skipFiles);
93
105
  for (const b of BUILTIN) found.delete(b);
106
+ // Drop server-only framework packages (and their subpaths) so they never
107
+ // reach the importmap / jspm path (#713).
108
+ for (const spec of found) {
109
+ const p = extractPackageName(spec);
110
+ if (p && FRAMEWORK_SERVER_ONLY.has(p)) found.delete(spec);
111
+ }
94
112
  return found;
95
113
  }
96
114
 
@@ -140,6 +158,10 @@ function isServerOnlyFile(name) {
140
158
  if (/\.server\.(js|ts|mjs|mts)$/.test(name)) return true;
141
159
  if (/^route\.(js|ts|mjs|mts)$/.test(name)) return true;
142
160
  if (/^middleware\.(js|ts|mjs|mts)$/.test(name)) return true;
161
+ // The zero-install Bun bootstrap (#675): a server-only entry that imports
162
+ // `@webjsdev/cli`. It never loads in the browser, so keep it out of the
163
+ // vendor scan, else the CLI would be pushed onto the jspm path (#713).
164
+ if (name === 'webjs-bun.mjs') return true;
143
165
  return false;
144
166
  }
145
167
 
@@ -667,7 +689,7 @@ export async function vendorImportMapEntries(bareImports, appDir) {
667
689
  for (const spec of bareImports) {
668
690
  if (BUILTIN.has(spec)) continue;
669
691
  const pkg = extractPackageName(spec);
670
- if (!pkg || BUILTIN.has(pkg)) continue;
692
+ if (!pkg || BUILTIN.has(pkg) || FRAMEWORK_SERVER_ONLY.has(pkg)) continue;
671
693
  const version = getPackageVersion(pkg, appDir) || declared[pkg];
672
694
  if (!version) continue;
673
695
  // Splice the version into the specifier: 'dayjs/plugin/utc' with
@@ -1236,7 +1258,7 @@ export async function pinAll(appDir, opts = {}) {
1236
1258
  for (const spec of bare) {
1237
1259
  if (BUILTIN.has(spec)) continue;
1238
1260
  const pkg = extractPackageName(spec);
1239
- if (!pkg || BUILTIN.has(pkg)) continue;
1261
+ if (!pkg || BUILTIN.has(pkg) || FRAMEWORK_SERVER_ONLY.has(pkg)) continue;
1240
1262
  const version = getPackageVersion(pkg, appDir);
1241
1263
  if (!version) continue;
1242
1264
  const subpath = spec.slice(pkg.length);