@jay-framework/compiler-jay-stack 0.11.0 → 0.12.0

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.
Files changed (2) hide show
  1. package/dist/index.js +29 -24
  2. package/package.json +7 -6
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { jayRuntime } from "@jay-framework/vite-plugin";
2
2
  import tsBridge from "@jay-framework/typescript-bridge";
3
3
  import { flattenVariable, isImportModuleVariableRoot, mkTransformer, SourceFileBindingResolver, areFlattenedAccessChainsEqual } from "@jay-framework/compiler";
4
+ import { getLogger } from "@jay-framework/logger";
4
5
  import * as path from "node:path";
5
6
  import { createRequire } from "node:module";
6
7
  import * as fs from "node:fs";
@@ -388,7 +389,7 @@ async function transformActionImports(code, id, resolveActionModule) {
388
389
  for (const imp of actionImports) {
389
390
  const resolved = await resolveActionModule(imp.source, id);
390
391
  if (!resolved) {
391
- console.warn(`[action-transform] Could not resolve action module: ${imp.source}`);
392
+ getLogger().warn(`[action-transform] Could not resolve action module: ${imp.source}`);
392
393
  continue;
393
394
  }
394
395
  const actions = extractActionsFromSource(resolved.code, resolved.path);
@@ -401,7 +402,7 @@ async function transformActionImports(code, id, resolveActionModule) {
401
402
  );
402
403
  needsCreateActionCallerImport = true;
403
404
  } else {
404
- console.warn(
405
+ getLogger().warn(
405
406
  `[action-transform] Export '${importName}' from ${imp.source} is not a recognized action`
406
407
  );
407
408
  }
@@ -505,7 +506,7 @@ function createImportChainTracker(options = {}) {
505
506
  importChain.clear();
506
507
  detectedServerModules.clear();
507
508
  if (verbose) {
508
- console.log("[import-chain-tracker] Build started, tracking imports...");
509
+ getLogger().info("[import-chain-tracker] Build started, tracking imports...");
509
510
  }
510
511
  },
511
512
  resolveId(source, importer, options2) {
@@ -517,7 +518,7 @@ function createImportChainTracker(options = {}) {
517
518
  }
518
519
  if (importer) {
519
520
  if (verbose) {
520
- console.log(
521
+ getLogger().info(
521
522
  `[import-chain-tracker] ${shortenPath(importer)} imports ${source}`
522
523
  );
523
524
  }
@@ -534,14 +535,14 @@ function createImportChainTracker(options = {}) {
534
535
  if (isServerOnlyModule(id)) {
535
536
  detectedServerModules.add(id);
536
537
  const chain = buildImportChain(id);
537
- console.error(
538
+ getLogger().error(
538
539
  `
539
540
  [import-chain-tracker] ⚠️ Server-only module detected in client build!`
540
541
  );
541
- console.error(`Module: ${shortenPath(id)}`);
542
- console.error(`Import chain:`);
543
- console.error(formatChain(chain));
544
- console.error("");
542
+ getLogger().error(`Module: ${shortenPath(id)}`);
543
+ getLogger().error(`Import chain:`);
544
+ getLogger().error(formatChain(chain));
545
+ getLogger().error("");
545
546
  }
546
547
  const importRegex = /import\s+(?:(?:\{[^}]*\}|[^{}\s,]+)\s+from\s+)?['"]([^'"]+)['"]/g;
547
548
  let match;
@@ -551,16 +552,18 @@ function createImportChainTracker(options = {}) {
551
552
  if (isServerOnlyModule(importedModule)) {
552
553
  if (!detectedServerModules.has(importedModule)) {
553
554
  detectedServerModules.add(importedModule);
554
- console.error(
555
+ getLogger().error(
555
556
  `
556
557
  [import-chain-tracker] ⚠️ Server-only import detected in client build!`
557
558
  );
558
- console.error(`Module "${importedModule}" imported by: ${shortenPath(id)}`);
559
+ getLogger().error(
560
+ `Module "${importedModule}" imported by: ${shortenPath(id)}`
561
+ );
559
562
  const chain = buildImportChain(id);
560
563
  chain.push(importedModule);
561
- console.error(`Import chain:`);
562
- console.error(formatChain(chain));
563
- console.error("");
564
+ getLogger().error(`Import chain:`);
565
+ getLogger().error(formatChain(chain));
566
+ getLogger().error("");
564
567
  }
565
568
  }
566
569
  }
@@ -568,21 +571,21 @@ function createImportChainTracker(options = {}) {
568
571
  },
569
572
  buildEnd() {
570
573
  if (detectedServerModules.size > 0) {
571
- console.warn(
574
+ getLogger().warn(
572
575
  `
573
576
  [import-chain-tracker] ⚠️ ${detectedServerModules.size} server-only module(s) detected during transform:`
574
577
  );
575
578
  for (const mod of detectedServerModules) {
576
- console.warn(` - ${mod}`);
579
+ getLogger().warn(` - ${mod}`);
577
580
  }
578
- console.warn(
581
+ getLogger().warn(
579
582
  "\nNote: These may be stripped by the code-split transform if only used in .withServer()."
580
583
  );
581
- console.warn(
584
+ getLogger().warn(
582
585
  'If build fails with "not exported" errors, check the import chains above.\n'
583
586
  );
584
587
  } else if (verbose) {
585
- console.log(
588
+ getLogger().info(
586
589
  "[import-chain-tracker] ✅ No server-only modules detected in client build"
587
590
  );
588
591
  }
@@ -649,7 +652,7 @@ function transformImports(options) {
649
652
  hasChanges = true;
650
653
  const newSource = `${packageName}/client`;
651
654
  if (verbose) {
652
- console.log(
655
+ getLogger().info(
653
656
  `[plugin-client-import] Rewriting import ${source} -> ${newSource} (in ${path.basename(filePath)})`
654
657
  );
655
658
  }
@@ -666,7 +669,7 @@ function transformImports(options) {
666
669
  hasChanges = true;
667
670
  const newSource = `${packageName}/client`;
668
671
  if (verbose) {
669
- console.log(
672
+ getLogger().info(
670
673
  `[plugin-client-import] Rewriting export ${source} -> ${newSource} (in ${path.basename(filePath)})`
671
674
  );
672
675
  }
@@ -742,7 +745,7 @@ function jayStackCompiler(options = {}) {
742
745
  try {
743
746
  return transformJayStackBuilder(code, id, environment);
744
747
  } catch (error) {
745
- console.error(`[jay-stack:code-split] Error transforming ${id}:`, error);
748
+ getLogger().error(`[jay-stack:code-split] Error transforming ${id}: ${error}`);
746
749
  return null;
747
750
  }
748
751
  }
@@ -802,12 +805,14 @@ function jayStackCompiler(options = {}) {
802
805
  try {
803
806
  code = await fs.promises.readFile(actualPath, "utf-8");
804
807
  } catch (err) {
805
- console.error(`[action-transform] Could not read ${actualPath}:`, err);
808
+ getLogger().error(
809
+ `[action-transform] Could not read ${actualPath}: ${err}`
810
+ );
806
811
  return null;
807
812
  }
808
813
  const actions = extractActionsFromSource(code, actualPath);
809
814
  if (actions.length === 0) {
810
- console.warn(`[action-transform] No actions found in ${actualPath}`);
815
+ getLogger().warn(`[action-transform] No actions found in ${actualPath}`);
811
816
  return null;
812
817
  }
813
818
  const lines = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/compiler-jay-stack",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",
@@ -27,15 +27,16 @@
27
27
  "test:watch": "vitest"
28
28
  },
29
29
  "dependencies": {
30
- "@jay-framework/compiler": "^0.11.0",
31
- "@jay-framework/compiler-shared": "^0.11.0",
32
- "@jay-framework/typescript-bridge": "^0.6.0",
33
- "@jay-framework/vite-plugin": "^0.11.0",
30
+ "@jay-framework/compiler": "^0.12.0",
31
+ "@jay-framework/compiler-shared": "^0.12.0",
32
+ "@jay-framework/logger": "^0.12.0",
33
+ "@jay-framework/typescript-bridge": "^0.7.0",
34
+ "@jay-framework/vite-plugin": "^0.12.0",
34
35
  "typescript": "^5.3.3",
35
36
  "vite": "^5.0.11"
36
37
  },
37
38
  "devDependencies": {
38
- "@jay-framework/dev-environment": "^0.11.0",
39
+ "@jay-framework/dev-environment": "^0.12.0",
39
40
  "rimraf": "^5.0.5",
40
41
  "tsup": "^8.0.1",
41
42
  "vitest": "^1.2.1"