juxscript 1.1.128 ā 1.1.130
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/dom-structure-map.json +1 -1
- package/machinery/compiler3.js +77 -40
- package/package.json +1 -1
package/dom-structure-map.json
CHANGED
package/machinery/compiler3.js
CHANGED
|
@@ -478,57 +478,94 @@ document.addEventListener('click', (e) => {
|
|
|
478
478
|
}
|
|
479
479
|
|
|
480
480
|
async build() {
|
|
481
|
-
console.log('
|
|
481
|
+
console.log('š JUX Build\n');
|
|
482
482
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
483
|
+
const juxscriptPath = this.findJuxscriptPath();
|
|
484
|
+
if (!juxscriptPath) {
|
|
485
|
+
console.error('ā Could not locate juxscript package');
|
|
486
|
+
return { success: false, errors: [{ message: 'juxscript not found' }], warnings: [] };
|
|
487
|
+
}
|
|
488
|
+
console.log(`š¦ Using: ${juxscriptPath}`);
|
|
489
489
|
|
|
490
|
-
|
|
491
|
-
const juxFiles = this.scanJuxFiles(this.config.srcDir);
|
|
492
|
-
console.log(`š Found ${juxFiles.length} .jux files\n`);
|
|
490
|
+
await this.loadJuxscriptExports();
|
|
493
491
|
|
|
494
|
-
|
|
495
|
-
|
|
492
|
+
if (fs.existsSync(this.distDir)) {
|
|
493
|
+
fs.rmSync(this.distDir, { recursive: true, force: true });
|
|
494
|
+
}
|
|
495
|
+
fs.mkdirSync(this.distDir, { recursive: true });
|
|
496
496
|
|
|
497
|
-
|
|
498
|
-
|
|
497
|
+
// ā
Copy public folder if exists
|
|
498
|
+
this.copyPublicFolder();
|
|
499
499
|
|
|
500
|
-
|
|
501
|
-
|
|
500
|
+
const { views, dataModules, sharedModules } = this.scanFiles();
|
|
501
|
+
console.log(`š Found ${views.length} views, ${sharedModules.length} shared, ${dataModules.length} data`);
|
|
502
502
|
|
|
503
|
-
|
|
504
|
-
|
|
503
|
+
// Copy data/shared modules to dist
|
|
504
|
+
const juxDistDir = path.join(this.distDir, 'jux');
|
|
505
|
+
fs.mkdirSync(juxDistDir, { recursive: true });
|
|
506
|
+
[...dataModules, ...sharedModules].forEach(m => {
|
|
507
|
+
fs.writeFileSync(path.join(juxDistDir, m.file), m.content);
|
|
508
|
+
});
|
|
505
509
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
console.log(` ā bundle.js (vendor libraries)`);
|
|
510
|
-
console.log(` ā index.html`);
|
|
511
|
-
console.log(` ā Public assets copied\n`);
|
|
510
|
+
const entryContent = this.generateEntryPoint(views, dataModules, sharedModules);
|
|
511
|
+
const entryPath = path.join(this.distDir, 'entry.js');
|
|
512
|
+
fs.writeFileSync(entryPath, entryContent);
|
|
512
513
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
errors: [],
|
|
517
|
-
warnings: [],
|
|
518
|
-
fileCount: juxFiles.length
|
|
519
|
-
};
|
|
514
|
+
const snapshotPath = path.join(this.distDir, '__jux_sources.json');
|
|
515
|
+
fs.writeFileSync(snapshotPath, JSON.stringify(this._sourceSnapshot, null, 2));
|
|
516
|
+
console.log(`šø Source snapshot written`);
|
|
520
517
|
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
console.
|
|
518
|
+
const validation = this.reportValidationIssues();
|
|
519
|
+
if (!validation.isValid) {
|
|
520
|
+
console.log('š BUILD FAILED\n');
|
|
521
|
+
return { success: false, errors: validation.errors, warnings: validation.warnings };
|
|
522
|
+
}
|
|
524
523
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
524
|
+
try {
|
|
525
|
+
await esbuild.build({
|
|
526
|
+
entryPoints: [entryPath],
|
|
527
|
+
bundle: true,
|
|
528
|
+
outfile: path.join(this.distDir, 'bundle.js'),
|
|
529
|
+
format: 'esm',
|
|
530
|
+
platform: 'browser',
|
|
531
|
+
target: 'esnext',
|
|
532
|
+
sourcemap: true,
|
|
533
|
+
loader: { '.jux': 'js', '.css': 'empty' },
|
|
534
|
+
plugins: [{
|
|
535
|
+
name: 'juxscript-resolver',
|
|
536
|
+
setup: (build) => {
|
|
537
|
+
build.onResolve({ filter: /^juxscript$/ }, () => ({ path: juxscriptPath }));
|
|
538
|
+
}
|
|
539
|
+
}],
|
|
540
|
+
});
|
|
541
|
+
console.log('ā
esbuild complete');
|
|
542
|
+
} catch (err) {
|
|
543
|
+
console.error('ā esbuild failed:', err);
|
|
544
|
+
return { success: false, errors: [{ message: err.message }], warnings: [] };
|
|
531
545
|
}
|
|
546
|
+
|
|
547
|
+
const html = `<!DOCTYPE html>
|
|
548
|
+
<html lang="en">
|
|
549
|
+
<head>
|
|
550
|
+
<meta charset="UTF-8">
|
|
551
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
552
|
+
<title>JUX Application</title>
|
|
553
|
+
<script type="module" src="./bundle.js"></script>
|
|
554
|
+
<script src="./entry.js"></script>
|
|
555
|
+
</head>
|
|
556
|
+
<body>
|
|
557
|
+
<div id="app"></div>
|
|
558
|
+
</body>
|
|
559
|
+
</html>`;
|
|
560
|
+
|
|
561
|
+
fs.writeFileSync(
|
|
562
|
+
path.join(this.config.distDir, 'index.html'),
|
|
563
|
+
html,
|
|
564
|
+
'utf8'
|
|
565
|
+
);
|
|
566
|
+
|
|
567
|
+
console.log(' ā
Generated index.html');
|
|
568
|
+
return { success: true, errors: [], warnings: validation.warnings };
|
|
532
569
|
}
|
|
533
570
|
|
|
534
571
|
/**
|