juxscript 1.0.77 → 1.0.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/machinery/compiler.js +17 -3
- package/package.json +1 -1
package/machinery/compiler.js
CHANGED
|
@@ -388,11 +388,15 @@ JuxError.register('${cleanName}', '${relativePath}');
|
|
|
388
388
|
function resolveImportPath(importPath, currentFilePath) {
|
|
389
389
|
// ✅ FIX: Handle root-relative imports (start with /)
|
|
390
390
|
if (importPath.startsWith('/')) {
|
|
391
|
-
|
|
391
|
+
const resolved = importPath.substring(1).replace(/\\/g, '/');
|
|
392
|
+
// console.log(`[Resolve] Root-relative: "${importPath}" -> "${resolved}"`);
|
|
393
|
+
return resolved;
|
|
392
394
|
}
|
|
393
395
|
const currentDir = path.dirname(currentFilePath);
|
|
394
396
|
// ✅ Ensure normalized separators
|
|
395
|
-
|
|
397
|
+
const resolved = path.join(currentDir, importPath).replace(/\\/g, '/');
|
|
398
|
+
// console.log(`[Resolve] Relative: "${importPath}" (from ${currentFilePath}) -> "${resolved}"`);
|
|
399
|
+
return resolved;
|
|
396
400
|
}
|
|
397
401
|
|
|
398
402
|
function generateRouterBundle(views, routes, sharedModules = new Map(), allImports = [], projectRoot = '') {
|
|
@@ -414,7 +418,9 @@ function generateRouterBundle(views, routes, sharedModules = new Map(), allImpor
|
|
|
414
418
|
// If it's a bare filename like "file.js", prefix it to "./file.js"
|
|
415
419
|
// Also check for ":" to avoid messing up URLs like http:// or data:
|
|
416
420
|
if (!normalized.startsWith('.') && !normalized.startsWith('/') && !normalized.includes(':')) {
|
|
421
|
+
const old = normalized;
|
|
417
422
|
normalized = './' + normalized;
|
|
423
|
+
console.log(` 🛠️ Canonicalizing local import: "${old}" -> "${normalized}"`);
|
|
418
424
|
}
|
|
419
425
|
return normalized;
|
|
420
426
|
};
|
|
@@ -429,6 +435,12 @@ function generateRouterBundle(views, routes, sharedModules = new Map(), allImpor
|
|
|
429
435
|
if (node && node.type === 'ImportDeclaration') {
|
|
430
436
|
const rawSource = node.source.value;
|
|
431
437
|
const source = getCanonicalSource(rawSource, filePath);
|
|
438
|
+
|
|
439
|
+
// Debug: Log if an import is being rewritten or handled specially
|
|
440
|
+
if (rawSource !== source && !source.startsWith('juxscript')) {
|
|
441
|
+
console.log(` 📦 Processing Import: "${rawSource}" -> "${source}" (in ${filePath})`);
|
|
442
|
+
}
|
|
443
|
+
|
|
432
444
|
if (!mergedImports.has(source)) mergedImports.set(source, { defaults: new Set(), named: new Set(), namespace: null });
|
|
433
445
|
const storage = mergedImports.get(source);
|
|
434
446
|
node.specifiers.forEach(spec => {
|
|
@@ -437,7 +449,9 @@ function generateRouterBundle(views, routes, sharedModules = new Map(), allImpor
|
|
|
437
449
|
else if (spec.type === 'ImportNamespaceSpecifier') storage.namespace = spec.local.name;
|
|
438
450
|
});
|
|
439
451
|
}
|
|
440
|
-
} catch (e) {
|
|
452
|
+
} catch (e) {
|
|
453
|
+
console.warn(` ⚠️ Failed to process import in bundle:`, item);
|
|
454
|
+
}
|
|
441
455
|
}
|
|
442
456
|
|
|
443
457
|
const filteredImports = [];
|