juxscript 1.0.76 → 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 +20 -5
- package/machinery/verifier.js +2 -1
- 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 = '') {
|
|
@@ -409,11 +413,14 @@ function generateRouterBundle(views, routes, sharedModules = new Map(), allImpor
|
|
|
409
413
|
}
|
|
410
414
|
if (joinedPath.includes('lib/components')) return 'juxscript/components';
|
|
411
415
|
|
|
412
|
-
//
|
|
416
|
+
// Fix: Ensure local relative paths ALWAYS start with ./
|
|
413
417
|
let normalized = joinedPath.replace(/\\/g, '/');
|
|
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:
|
|
420
|
+
if (!normalized.startsWith('.') && !normalized.startsWith('/') && !normalized.includes(':')) {
|
|
421
|
+
const old = normalized;
|
|
416
422
|
normalized = './' + normalized;
|
|
423
|
+
console.log(` 🛠️ Canonicalizing local import: "${old}" -> "${normalized}"`);
|
|
417
424
|
}
|
|
418
425
|
return normalized;
|
|
419
426
|
};
|
|
@@ -428,6 +435,12 @@ function generateRouterBundle(views, routes, sharedModules = new Map(), allImpor
|
|
|
428
435
|
if (node && node.type === 'ImportDeclaration') {
|
|
429
436
|
const rawSource = node.source.value;
|
|
430
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
|
+
|
|
431
444
|
if (!mergedImports.has(source)) mergedImports.set(source, { defaults: new Set(), named: new Set(), namespace: null });
|
|
432
445
|
const storage = mergedImports.get(source);
|
|
433
446
|
node.specifiers.forEach(spec => {
|
|
@@ -436,7 +449,9 @@ function generateRouterBundle(views, routes, sharedModules = new Map(), allImpor
|
|
|
436
449
|
else if (spec.type === 'ImportNamespaceSpecifier') storage.namespace = spec.local.name;
|
|
437
450
|
});
|
|
438
451
|
}
|
|
439
|
-
} catch (e) {
|
|
452
|
+
} catch (e) {
|
|
453
|
+
console.warn(` ⚠️ Failed to process import in bundle:`, item);
|
|
454
|
+
}
|
|
440
455
|
}
|
|
441
456
|
|
|
442
457
|
const filteredImports = [];
|
package/machinery/verifier.js
CHANGED
|
@@ -67,6 +67,7 @@ export function verifyStaticBuild(distDir) {
|
|
|
67
67
|
|
|
68
68
|
// ✅ FIX: Check if the file exists locally in dist (e.g. copied assets)
|
|
69
69
|
// If it exists on disk, it's not a ghost dependency from node_modules
|
|
70
|
+
// This handles cases where a file was copied but imported as a bare specifier (though compiler should fix that too)
|
|
70
71
|
if (fs.existsSync(path.join(distDir, source))) {
|
|
71
72
|
return;
|
|
72
73
|
}
|
|
@@ -122,7 +123,7 @@ export function verifyRuntime(port) {
|
|
|
122
123
|
check('/main.js', 'application/javascript'),
|
|
123
124
|
]).then(() => {
|
|
124
125
|
if (errors.length > 0) {
|
|
125
|
-
console.error(`\n💥 RUNTIME VERIFICATION FAILED (
|
|
126
|
+
console.error(`\n💥 RUNTIME VERIFICATION FAILED (${errors.length} errors):`);
|
|
126
127
|
errors.forEach(e => console.error(` - ${e}`));
|
|
127
128
|
console.log('');
|
|
128
129
|
resolve(false);
|