@stacksjs/stx 0.2.194 → 0.2.195

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.
@@ -280,9 +280,13 @@ export async function extractVariables(scriptContent, context, filePath, options
280
280
  } catch {
281
281
  jsContent = stripTypeScript(scriptContent);
282
282
  }
283
- const module = { exports: {} }, exports = module.exports, projectRoot = process.cwd(), preloaded = {}, serverRequires = [...jsContent.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g) || []].map((m) => m[1]).filter((id) => !id.startsWith("node:") && !id.startsWith(".") && !["fs", "path", "os", "child_process", "crypto", "http", "https", "url", "util", "stream", "events", "buffer", "net", "querystring", "zlib", "tls"].includes(id));
283
+ const module = { exports: {} }, exports = module.exports, projectRoot = process.cwd(), preloaded = {}, serverRequires = [...jsContent.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g) || []].map((m) => m[1]).filter((id) => !id.startsWith("node:") && !["fs", "path", "os", "child_process", "crypto", "http", "https", "url", "util", "stream", "events", "buffer", "net", "querystring", "zlib", "tls"].includes(id)), unresolvable = new Map;
284
284
  for (const id of serverRequires)
285
285
  try {
286
+ if (id.startsWith(".")) {
287
+ preloaded[id] = await import(path.resolve(path.dirname(filePath), id));
288
+ continue;
289
+ }
286
290
  const pkgDir = path.resolve(projectRoot, "node_modules", id), pkgJsonPath = path.join(pkgDir, "package.json"), pkgJson = JSON.parse(require("fs").readFileSync(pkgJsonPath, "utf8"));
287
291
  let entry = pkgJson.main || "index.js";
288
292
  if (pkgJson.exports) {
@@ -297,10 +301,16 @@ export async function extractVariables(scriptContent, context, filePath, options
297
301
  entry = exp.default;
298
302
  }
299
303
  preloaded[id] = await import(path.resolve(pkgDir, entry));
300
- } catch {}
304
+ } catch (error) {
305
+ if (id.startsWith("."))
306
+ unresolvable.set(id, error instanceof Error ? error.message : String(error));
307
+ }
301
308
  const requireFn = (id) => {
302
309
  if (preloaded[id])
303
310
  return preloaded[id];
311
+ const reason = unresolvable.get(id);
312
+ if (reason !== void 0)
313
+ throw Error(`Cannot require '${id}' from ${filePath}: ${reason}`);
304
314
  return require(id);
305
315
  }, propsObj = context.props || {}, $props = (defaults) => {
306
316
  if (!defaults)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx",
3
3
  "type": "module",
4
- "version": "0.2.194",
4
+ "version": "0.2.195",
5
5
  "description": "A performant UI Framework. Powered by Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -117,12 +117,12 @@
117
117
  "dependencies": {
118
118
  "@cwcss/crosswind": "^0.2.14",
119
119
  "@stacksjs/clapp": "^0.2.0",
120
- "@stacksjs/desktop": "0.2.194",
121
- "@stacksjs/sanitizer": "0.2.194",
120
+ "@stacksjs/desktop": "0.2.195",
121
+ "@stacksjs/sanitizer": "0.2.195",
122
122
  "@stacksjs/ts-i18n": "^0.1.11",
123
- "bun-plugin-stx": "0.2.194",
123
+ "bun-plugin-stx": "0.2.195",
124
124
  "bunfig": "^0.15.17",
125
- "stx-router": "0.2.194",
125
+ "stx-router": "0.2.195",
126
126
  "ts-broadcasting": "^0.0.9",
127
127
  "ts-images": "^0.2.11",
128
128
  "ts-syntax-highlighter": "^0.2.1"