juxscript 1.0.80 → 1.0.82

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.
@@ -189,6 +189,12 @@ export async function bundleJuxFilesToRouter(projectRoot, distDir, options = {})
189
189
  if (isJux) {
190
190
  fileToFunction.set(relativePath, cleanFunctionName);
191
191
  fileToFunction.set(relativePath.split(path.sep).join('/'), cleanFunctionName);
192
+
193
+ // ✅ FIX: Register lookup without extension to match juxconfig routes like "/path/to/view"
194
+ const noExt = relativePath.replace(/\.jux$/, '');
195
+ const noExtNormalized = noExt.split(path.sep).join('/');
196
+ fileToFunction.set(noExt, cleanFunctionName);
197
+ fileToFunction.set(noExtNormalized, cleanFunctionName);
192
198
  }
193
199
 
194
200
  const routePath = routePrefix + '/' + (parsedPath.dir ? `${parsedPath.dir}/` : '') + parsedPath.name;
@@ -250,12 +256,20 @@ export async function bundleJuxFilesToRouter(projectRoot, distDir, options = {})
250
256
 
251
257
  if (pages) {
252
258
  const resolveAndAddRoute = (urlPath, targetFile) => {
259
+ // ✅ FIX: Handle ./ and / prefixes in config paths
253
260
  const cleanTarget = targetFile.replace(/^(\.\/|\/)/, '');
254
- const funcName = fileToFunction.get(cleanTarget);
261
+ let funcName = fileToFunction.get(cleanTarget);
262
+
263
+ // Try appending .jux if not found and no extension provided
264
+ if (!funcName && !cleanTarget.endsWith('.jux')) {
265
+ funcName = fileToFunction.get(cleanTarget + '.jux');
266
+ }
267
+
255
268
  if (funcName) {
269
+ console.log(` 📍 Custom Route: ${urlPath.padEnd(25)} -> ${funcName} (${targetFile})`);
256
270
  routes.unshift({ path: urlPath, functionName: funcName });
257
271
  } else {
258
- console.warn(` ⚠️ Route target not found: ${targetFile}`);
272
+ console.warn(` ⚠️ Route target not found: ${targetFile} (Cleaned: ${cleanTarget})`);
259
273
  }
260
274
  };
261
275
  Object.entries(pages).forEach(([key, value]) => {
@@ -350,9 +364,13 @@ function transformJuxToViewFunction(juxContent, functionName, pageName, relative
350
364
  importReplacements.set(spec.local.name, `${spec.imported.name}$${namespace}`);
351
365
  }
352
366
  });
353
- // Remove local imports as they will be inlined in main.js
354
- nodesToRemove.push({ start: node.start, end: node.end });
355
367
  }
368
+
369
+ // 🔥 FIX: Always remove ImportDeclaration from the view function contents.
370
+ // External imports are hoisted to 'allImports' and placed at the top of main.js.
371
+ // Local/Bundled imports are hoisted via sharedModules mechanism with namespacing.
372
+ // Leaving import statements inside the function body causes SyntaxError.
373
+ nodesToRemove.push({ start: node.start, end: node.end });
356
374
  }
357
375
  if (node.type === 'ExportNamedDeclaration' || node.type === 'ExportDefaultDeclaration') {
358
376
  nodesToRemove.push({ start: node.start, end: node.end });
@@ -398,6 +416,7 @@ function resolveImportPath(importPath, currentFilePath) {
398
416
  // ✅ Ensure normalized separators
399
417
  const resolved = path.join(currentDir, importPath).replace(/\\/g, '/');
400
418
  // console.log(`[Resolve] Relative: "${importPath}" (from ${currentFilePath}) -> "${resolved}"`);
419
+ console.log(`[Resolve] Importing "${importPath}" from "${currentFilePath}" -> Resolved: "${resolved}"`);
401
420
  return resolved;
402
421
  }
403
422
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "juxscript",
3
- "version": "1.0.80",
3
+ "version": "1.0.82",
4
4
  "type": "module",
5
5
  "description": "A JavaScript UX authorship platform",
6
6
  "main": "lib/jux.js",