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