juxscript 1.0.74 → 1.0.76
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 +11 -2
- package/machinery/verifier.js +6 -6
- package/package.json +1 -1
package/machinery/compiler.js
CHANGED
|
@@ -206,7 +206,8 @@ export async function bundleJuxFilesToRouter(projectRoot, distDir, options = {})
|
|
|
206
206
|
|
|
207
207
|
// ✅ CHECK: Is this import pointing to a file we are bundling?
|
|
208
208
|
let isBundledLocal = false;
|
|
209
|
-
|
|
209
|
+
// Support relative (./, ../) OR project-root relative (/) imports
|
|
210
|
+
if (moduleName.startsWith('.') || moduleName.startsWith('/')) {
|
|
210
211
|
const resolved = resolveImportPath(moduleName, relativePath);
|
|
211
212
|
if (bundledPaths.has(resolved)) {
|
|
212
213
|
isBundledLocal = true;
|
|
@@ -338,6 +339,7 @@ function transformJuxToViewFunction(juxContent, functionName, pageName, relative
|
|
|
338
339
|
const resolvedPath = resolveImportPath(importPath, relativePath);
|
|
339
340
|
|
|
340
341
|
// ✅ Check if this import is pointing to a bundled file
|
|
342
|
+
// Handle BOTH relative and absolute-relative imports (starting with /)
|
|
341
343
|
const isBundled = (bundledPaths && bundledPaths.has(resolvedPath)) || importPath.endsWith('.jux');
|
|
342
344
|
|
|
343
345
|
if (isBundled) {
|
|
@@ -365,6 +367,7 @@ function transformJuxToViewFunction(juxContent, functionName, pageName, relative
|
|
|
365
367
|
} catch (err) {
|
|
366
368
|
throw new Error(`Invalid JavaScript syntax in ${relativePath}`);
|
|
367
369
|
}
|
|
370
|
+
|
|
368
371
|
result = result.replace(/\.renderTo\(container\)/g, '.render("#app")').replace(/\.render\(\s*\)/g, '.render("#app")');
|
|
369
372
|
const cleanName = functionName.replace(/[-_]/g, ' ').split(' ').map(w => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join('');
|
|
370
373
|
|
|
@@ -383,7 +386,12 @@ JuxError.register('${cleanName}', '${relativePath}');
|
|
|
383
386
|
}
|
|
384
387
|
|
|
385
388
|
function resolveImportPath(importPath, currentFilePath) {
|
|
389
|
+
// ✅ FIX: Handle root-relative imports (start with /)
|
|
390
|
+
if (importPath.startsWith('/')) {
|
|
391
|
+
return importPath.substring(1).replace(/\\/g, '/');
|
|
392
|
+
}
|
|
386
393
|
const currentDir = path.dirname(currentFilePath);
|
|
394
|
+
// ✅ Ensure normalized separators
|
|
387
395
|
return path.join(currentDir, importPath).replace(/\\/g, '/');
|
|
388
396
|
}
|
|
389
397
|
|
|
@@ -401,8 +409,9 @@ function generateRouterBundle(views, routes, sharedModules = new Map(), allImpor
|
|
|
401
409
|
}
|
|
402
410
|
if (joinedPath.includes('lib/components')) return 'juxscript/components';
|
|
403
411
|
|
|
404
|
-
// ✅ Fix: Ensure local relative paths start with ./
|
|
412
|
+
// ✅ Fix: Ensure local relative paths ALWAYS start with ./
|
|
405
413
|
let normalized = joinedPath.replace(/\\/g, '/');
|
|
414
|
+
// If it's a bare filename like "file.js", prefix it to "./file.js"
|
|
406
415
|
if (!normalized.startsWith('.') && !normalized.startsWith('/')) {
|
|
407
416
|
normalized = './' + normalized;
|
|
408
417
|
}
|
package/machinery/verifier.js
CHANGED
|
@@ -16,7 +16,6 @@ export function verifyStaticBuild(distDir) {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
// 1. Critical Files Existence
|
|
19
|
-
// ✅ FIX: Removed lib/jux.js as it is no longer the primary artifact with v2 components
|
|
20
19
|
const critical = ['index.html', 'main.js'];
|
|
21
20
|
for (const f of critical) {
|
|
22
21
|
if (!fs.existsSync(path.join(distDir, f))) {
|
|
@@ -41,8 +40,6 @@ export function verifyStaticBuild(distDir) {
|
|
|
41
40
|
const fullPath = path.join(distDir, fsPath);
|
|
42
41
|
|
|
43
42
|
if (!fs.existsSync(fullPath)) {
|
|
44
|
-
// Downgrade missing imports to warnings if they look like vendored libs?
|
|
45
|
-
// For now, keep as error to be safe.
|
|
46
43
|
errors.push(`Broken Import Map: "${key}" -> ${url} (File not found)`);
|
|
47
44
|
}
|
|
48
45
|
}
|
|
@@ -68,6 +65,12 @@ export function verifyStaticBuild(distDir) {
|
|
|
68
65
|
return;
|
|
69
66
|
}
|
|
70
67
|
|
|
68
|
+
// ✅ FIX: Check if the file exists locally in dist (e.g. copied assets)
|
|
69
|
+
// If it exists on disk, it's not a ghost dependency from node_modules
|
|
70
|
+
if (fs.existsSync(path.join(distDir, source))) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
71
74
|
if (!importMap[source] && !importMap[source + '/']) {
|
|
72
75
|
errors.push(`Ghost Dependency: '${source}' is imported in main.js but missing from Import Map.`);
|
|
73
76
|
}
|
|
@@ -90,7 +93,6 @@ export function verifyStaticBuild(distDir) {
|
|
|
90
93
|
|
|
91
94
|
export function verifyRuntime(port) {
|
|
92
95
|
return new Promise((resolve) => {
|
|
93
|
-
// console.log('🩺 Performing runtime diagnostics...');
|
|
94
96
|
const errors = [];
|
|
95
97
|
|
|
96
98
|
// Helper to check a single URL
|
|
@@ -118,7 +120,6 @@ export function verifyRuntime(port) {
|
|
|
118
120
|
Promise.all([
|
|
119
121
|
check('/', 'text/html'),
|
|
120
122
|
check('/main.js', 'application/javascript'),
|
|
121
|
-
// check('/lib/jux.js', 'application/javascript') // Removed check
|
|
122
123
|
]).then(() => {
|
|
123
124
|
if (errors.length > 0) {
|
|
124
125
|
console.error(`\n💥 RUNTIME VERIFICATION FAILED (` + errors.length + ` errors):`);
|
|
@@ -126,7 +127,6 @@ export function verifyRuntime(port) {
|
|
|
126
127
|
console.log('');
|
|
127
128
|
resolve(false);
|
|
128
129
|
} else {
|
|
129
|
-
// console.log(' ✓ Runtime health healthy\n');
|
|
130
130
|
resolve(true);
|
|
131
131
|
}
|
|
132
132
|
});
|