@jay-framework/dev-server 0.16.5 → 0.17.1

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 +83 -12
  2. package/package.json +14 -14
package/dist/index.js CHANGED
@@ -569,7 +569,7 @@ class SourceFileBindingResolver {
569
569
  return new GlobalResolvedType(globalVariableRoot.name);
570
570
  }
571
571
  }
572
- const { isStringLiteral: isStringLiteral$1 } = c;
572
+ const { isStringLiteral: isStringLiteral$2 } = c;
573
573
  function areFlattenedAccessChainsEqual(chain1, chain2) {
574
574
  if (chain1.path.length !== chain2.path.length) {
575
575
  return false;
@@ -593,8 +593,8 @@ function areVariableRootsEqual(root1, root2) {
593
593
  switch (root1.kind) {
594
594
  case VariableRootType.ImportModule:
595
595
  if (isImportModuleVariableRoot(root1) && isImportModuleVariableRoot(root2)) {
596
- const module1 = isStringLiteral$1(root1.module) ? root1.module.text : String(root1.module);
597
- const module2 = isStringLiteral$1(root2.module) ? root2.module.text : String(root2.module);
596
+ const module1 = isStringLiteral$2(root1.module) ? root1.module.text : String(root1.module);
597
+ const module2 = isStringLiteral$2(root2.module) ? root2.module.text : String(root2.module);
598
598
  return module1 === module2 && root1.importType === root2.importType;
599
599
  }
600
600
  return false;
@@ -630,7 +630,7 @@ function shouldRemoveMethod(methodName, environment) {
630
630
  return true;
631
631
  return false;
632
632
  }
633
- const { isCallExpression: isCallExpression$1, isPropertyAccessExpression: isPropertyAccessExpression$1, isIdentifier: isIdentifier$2, isStringLiteral } = c$1;
633
+ const { isCallExpression: isCallExpression$1, isPropertyAccessExpression: isPropertyAccessExpression$1, isIdentifier: isIdentifier$2, isStringLiteral: isStringLiteral$1 } = c$1;
634
634
  function findBuilderMethodsToRemove(sourceFile, bindingResolver, environment) {
635
635
  const callsToRemove = [];
636
636
  const removedVariables = /* @__PURE__ */ new Set();
@@ -659,7 +659,7 @@ function isPartOfJayStackChain(callExpr, bindingResolver) {
659
659
  if (isIdentifier$2(current.expression)) {
660
660
  const variable = bindingResolver.explain(current.expression);
661
661
  const flattened = flattenVariable(variable);
662
- if (flattened.path.length === 1 && JAY_BUILDER_FUNCTIONS.has(flattened.path[0]) && isImportModuleVariableRoot(flattened.root) && isStringLiteral(flattened.root.module) && flattened.root.module.text === "@jay-framework/fullstack-component")
662
+ if (flattened.path.length === 1 && JAY_BUILDER_FUNCTIONS.has(flattened.path[0]) && isImportModuleVariableRoot(flattened.root) && isStringLiteral$1(flattened.root.module) && flattened.root.module.text === "@jay-framework/fullstack-component")
663
663
  return true;
664
664
  }
665
665
  if (isPropertyAccessExpression$1(current.expression)) {
@@ -790,11 +790,14 @@ const {
790
790
  isPropertyAccessExpression,
791
791
  isImportDeclaration,
792
792
  isNamedImports,
793
- isIdentifier
793
+ isIdentifier,
794
+ isStringLiteral
794
795
  } = c$1;
795
- function transformJayStackBuilder(code, filePath, environment) {
796
+ function transformJayStackBuilder(code, filePath, environment, stripBuilders) {
796
797
  const sourceFile = createSourceFile(filePath, code, ScriptTarget.Latest, true);
797
- const transformers = [mkTransformer(mkJayStackCodeSplitTransformer, { environment })];
798
+ const transformers = [
799
+ mkTransformer(mkJayStackCodeSplitTransformer, { environment, stripBuilders })
800
+ ];
798
801
  const printer = createPrinter();
799
802
  const result = c$1.transform(sourceFile, transformers);
800
803
  const transformedFile = result.transformed[0];
@@ -811,10 +814,25 @@ function mkJayStackCodeSplitTransformer({
811
814
  factory,
812
815
  sourceFile,
813
816
  context,
814
- environment
817
+ environment,
818
+ stripBuilders
815
819
  }) {
816
820
  const bindingResolver = new SourceFileBindingResolver(sourceFile);
817
- const { callsToRemove } = findBuilderMethodsToRemove(sourceFile, bindingResolver, environment);
821
+ let workingSourceFile = sourceFile;
822
+ if (stripBuilders && stripBuilders.size > 0) {
823
+ const filtered = sourceFile.statements.filter((statement) => {
824
+ const rootName = findChainRootBuilderName(statement, bindingResolver);
825
+ return !rootName || !stripBuilders.has(rootName);
826
+ });
827
+ if (filtered.length !== sourceFile.statements.length) {
828
+ workingSourceFile = factory.updateSourceFile(sourceFile, filtered);
829
+ }
830
+ }
831
+ const { callsToRemove } = findBuilderMethodsToRemove(
832
+ workingSourceFile,
833
+ bindingResolver,
834
+ environment
835
+ );
818
836
  const transformVisitor = (node) => {
819
837
  if (isCallExpression(node) && isPropertyAccessExpression(node.expression)) {
820
838
  const variable = bindingResolver.explain(node.expression);
@@ -827,7 +845,7 @@ function mkJayStackCodeSplitTransformer({
827
845
  return visitEachChild(node, transformVisitor, context);
828
846
  };
829
847
  let transformedSourceFile = visitEachChild(
830
- sourceFile,
848
+ workingSourceFile,
831
849
  transformVisitor,
832
850
  context
833
851
  );
@@ -867,6 +885,36 @@ function filterImportDeclaration(statement, unusedImports, factory) {
867
885
  statement.assertClause
868
886
  );
869
887
  }
888
+ function findChainRootBuilderName(statement, bindingResolver) {
889
+ let expr;
890
+ if (c$1.isVariableStatement(statement)) {
891
+ for (const decl of statement.declarationList.declarations) {
892
+ if (decl.initializer && isCallExpression(decl.initializer)) {
893
+ expr = decl.initializer;
894
+ }
895
+ }
896
+ }
897
+ if (c$1.isExpressionStatement(statement) && isCallExpression(statement.expression)) {
898
+ expr = statement.expression;
899
+ }
900
+ if (!expr)
901
+ return void 0;
902
+ let current = expr;
903
+ while (true) {
904
+ if (isCallExpression(current) && isPropertyAccessExpression(current.expression)) {
905
+ current = current.expression.expression;
906
+ } else if (isCallExpression(current) && isIdentifier(current.expression)) {
907
+ const variable = bindingResolver.explain(current.expression);
908
+ const flattened = flattenVariable(variable);
909
+ if (flattened.path.length === 1 && isImportModuleVariableRoot(flattened.root) && isStringLiteral(flattened.root.module) && flattened.root.module.text === "@jay-framework/fullstack-component") {
910
+ return flattened.path[0];
911
+ }
912
+ return void 0;
913
+ } else {
914
+ return void 0;
915
+ }
916
+ }
917
+ }
870
918
  const actionMetadataCache = /* @__PURE__ */ new Map();
871
919
  function clearActionMetadataCache() {
872
920
  actionMetadataCache.clear();
@@ -1275,6 +1323,9 @@ function jayStackCompiler(options = {}) {
1275
1323
  if (!id.endsWith(".ts") && !id.includes(".ts?")) {
1276
1324
  return null;
1277
1325
  }
1326
+ if (id.includes(".jay-html")) {
1327
+ return null;
1328
+ }
1278
1329
  const hasComponent = code.includes("makeJayStackComponent");
1279
1330
  const hasInit = code.includes("makeJayInit");
1280
1331
  if (!hasComponent && !hasInit) {
@@ -1384,6 +1435,23 @@ function jayStackCompiler(options = {}) {
1384
1435
  }
1385
1436
  const result = lines.join("\n");
1386
1437
  return result;
1438
+ },
1439
+ // Strip inline makeJayAction/makeJayQuery/makeJayStream statements
1440
+ // from component files in client builds. These are server-only
1441
+ // constructs that shouldn't appear in client bundles.
1442
+ transform(code, id, options2) {
1443
+ if (options2?.ssr || isSSRBuild)
1444
+ return null;
1445
+ if (!id.endsWith(".ts") && !id.includes(".ts?"))
1446
+ return null;
1447
+ if (id.includes(".jay-html"))
1448
+ return null;
1449
+ if (isActionImport(id))
1450
+ return null;
1451
+ const ACTION_BUILDERS = ["makeJayAction", "makeJayQuery", "makeJayStream"];
1452
+ if (!ACTION_BUILDERS.some((b) => code.includes(b)))
1453
+ return null;
1454
+ return stripInlineActionBuilders(code, ACTION_BUILDERS);
1387
1455
  }
1388
1456
  };
1389
1457
  })(),
@@ -1392,6 +1460,9 @@ function jayStackCompiler(options = {}) {
1392
1460
  );
1393
1461
  return plugins;
1394
1462
  }
1463
+ function stripInlineActionBuilders(code, builderNames) {
1464
+ return transformJayStackBuilder(code, "action-strip.ts", "client", new Set(builderNames));
1465
+ }
1395
1466
  async function createViteServer(options) {
1396
1467
  const {
1397
1468
  projectRoot,
@@ -2294,7 +2365,7 @@ function defaults(options) {
2294
2365
  projectRootFolder,
2295
2366
  options.pagesRootFolder || "./src/pages"
2296
2367
  );
2297
- const buildFolder = options.buildFolder || path__default.resolve(projectRootFolder, "./build");
2368
+ const buildFolder = options.buildFolder || path__default.resolve(projectRootFolder, "./build/dev");
2298
2369
  const tsConfigFilePath = options.jayRollupConfig.tsConfigFilePath || path__default.resolve(projectRootFolder, "./tsconfig.json");
2299
2370
  return {
2300
2371
  publicBaseUrlPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/dev-server",
3
- "version": "0.16.5",
3
+ "version": "0.17.1",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",
@@ -23,23 +23,23 @@
23
23
  "test:watch": "vitest"
24
24
  },
25
25
  "dependencies": {
26
- "@jay-framework/compiler-jay-stack": "^0.16.5",
27
- "@jay-framework/compiler-shared": "^0.16.5",
28
- "@jay-framework/component": "^0.16.5",
29
- "@jay-framework/fullstack-component": "^0.16.5",
30
- "@jay-framework/logger": "^0.16.5",
31
- "@jay-framework/runtime": "^0.16.5",
32
- "@jay-framework/stack-client-runtime": "^0.16.5",
33
- "@jay-framework/stack-route-scanner": "^0.16.5",
34
- "@jay-framework/stack-server-runtime": "^0.16.5",
35
- "@jay-framework/view-state-merge": "^0.16.5",
26
+ "@jay-framework/compiler-jay-stack": "^0.17.1",
27
+ "@jay-framework/compiler-shared": "^0.17.1",
28
+ "@jay-framework/component": "^0.17.1",
29
+ "@jay-framework/fullstack-component": "^0.17.1",
30
+ "@jay-framework/logger": "^0.17.1",
31
+ "@jay-framework/runtime": "^0.17.1",
32
+ "@jay-framework/stack-client-runtime": "^0.17.1",
33
+ "@jay-framework/stack-route-scanner": "^0.17.1",
34
+ "@jay-framework/stack-server-runtime": "^0.17.1",
35
+ "@jay-framework/view-state-merge": "^0.17.1",
36
36
  "busboy": "^1.6.0",
37
37
  "vite": "^5.0.11"
38
38
  },
39
39
  "devDependencies": {
40
- "@jay-framework/dev-environment": "^0.16.5",
41
- "@jay-framework/jay-cli": "^0.16.5",
42
- "@jay-framework/stack-client-runtime": "^0.16.5",
40
+ "@jay-framework/dev-environment": "^0.17.1",
41
+ "@jay-framework/jay-cli": "^0.17.1",
42
+ "@jay-framework/stack-client-runtime": "^0.17.1",
43
43
  "@playwright/test": "^1.58.2",
44
44
  "@types/busboy": "^1.5.4",
45
45
  "@types/express": "^5.0.2",