@soda-gql/builder 0.13.0 → 0.13.2

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.
@@ -972,7 +972,7 @@ const buildNestedObject = (definition) => {
972
972
  * Render import statements for the intermediate module using ModuleSummary.
973
973
  * Only includes imports from modules that have gql exports.
974
974
  */
975
- const renderImportStatements = ({ filePath, analysis, analyses, graphqlSystemPath }) => {
975
+ const renderImportStatements = ({ filePath, analysis, analyses, graphqlSystemPath, aliasResolver }) => {
976
976
  const importLines = [];
977
977
  const importedRootNames = new Set();
978
978
  const namespaceImports = new Set();
@@ -982,6 +982,12 @@ const renderImportStatements = ({ filePath, analysis, analyses, graphqlSystemPat
982
982
  return;
983
983
  }
984
984
  if (!imp.source.startsWith(".")) {
985
+ if (!aliasResolver) return;
986
+ const aliasResolved = aliasResolver.resolve(imp.source);
987
+ if (!aliasResolved || !analyses.has(aliasResolved) || aliasResolved === graphqlSystemPath) return;
988
+ const imports$1 = importsByFile.get(aliasResolved) ?? [];
989
+ imports$1.push(imp);
990
+ importsByFile.set(aliasResolved, imports$1);
985
991
  return;
986
992
  }
987
993
  const resolvedPath = resolveRelativeImportWithReferences({
@@ -1025,12 +1031,13 @@ const renderImportStatements = ({ filePath, analysis, analyses, graphqlSystemPat
1025
1031
  namespaceImports
1026
1032
  };
1027
1033
  };
1028
- const renderRegistryBlock = ({ filePath, analysis, analyses, graphqlSystemPath }) => {
1034
+ const renderRegistryBlock = ({ filePath, analysis, analyses, graphqlSystemPath, aliasResolver }) => {
1029
1035
  const { imports } = renderImportStatements({
1030
1036
  filePath,
1031
1037
  analysis,
1032
1038
  analyses,
1033
- graphqlSystemPath
1039
+ graphqlSystemPath,
1040
+ aliasResolver
1034
1041
  });
1035
1042
  return [
1036
1043
  `registry.setModule("${filePath}", function*() {`,
@@ -1355,7 +1362,7 @@ function executeGraphqlSystemModule(modulePath) {
1355
1362
  * Build intermediate modules from dependency graph.
1356
1363
  * Each intermediate module corresponds to one source file.
1357
1364
  */
1358
- const generateIntermediateModules = function* ({ analyses, targetFiles, graphqlSystemPath }) {
1365
+ const generateIntermediateModules = function* ({ analyses, targetFiles, graphqlSystemPath, aliasResolver }) {
1359
1366
  for (const filePath of targetFiles) {
1360
1367
  const analysis = analyses.get(filePath);
1361
1368
  if (!analysis) {
@@ -1365,7 +1372,8 @@ const generateIntermediateModules = function* ({ analyses, targetFiles, graphqlS
1365
1372
  filePath,
1366
1373
  analysis,
1367
1374
  analyses,
1368
- graphqlSystemPath
1375
+ graphqlSystemPath,
1376
+ aliasResolver
1369
1377
  });
1370
1378
  if (process.env.DEBUG_INTERMEDIATE_MODULE) {
1371
1379
  console.log("=== Intermediate module source ===");
@@ -5802,7 +5810,7 @@ const isEmptyDiff = (diff) => {
5802
5810
 
5803
5811
  //#endregion
5804
5812
  //#region packages/builder/src/session/dependency-validation.ts
5805
- const validateModuleDependencies = ({ analyses, graphqlSystemHelper }) => {
5813
+ const validateModuleDependencies = ({ analyses, graphqlSystemHelper, aliasResolver }) => {
5806
5814
  for (const analysis of analyses.values()) {
5807
5815
  for (const { source, isTypeOnly } of analysis.imports) {
5808
5816
  if (isTypeOnly) {
@@ -5826,6 +5834,14 @@ const validateModuleDependencies = ({ analyses, graphqlSystemHelper }) => {
5826
5834
  chain: [analysis.filePath, source]
5827
5835
  });
5828
5836
  }
5837
+ } else if (aliasResolver) {
5838
+ const aliasResolved = aliasResolver.resolve(source);
5839
+ if (aliasResolved && !analyses.has(aliasResolved)) {
5840
+ return err({
5841
+ code: "MISSING_IMPORT",
5842
+ chain: [analysis.filePath, source]
5843
+ });
5844
+ }
5829
5845
  }
5830
5846
  }
5831
5847
  }
@@ -6178,7 +6194,8 @@ function* buildGen(input) {
6178
6194
  const analyses = new Map(discoveryResult.snapshots.map((snapshot) => [snapshot.normalizedFilePath, snapshot.analysis]));
6179
6195
  const dependenciesValidationResult = validateModuleDependencies({
6180
6196
  analyses,
6181
- graphqlSystemHelper: graphqlHelper
6197
+ graphqlSystemHelper: graphqlHelper,
6198
+ aliasResolver
6182
6199
  });
6183
6200
  if (dependenciesValidationResult.isErr()) {
6184
6201
  const error = dependenciesValidationResult.error;
@@ -6208,7 +6225,8 @@ function* buildGen(input) {
6208
6225
  for (const intermediateModule of generateIntermediateModules({
6209
6226
  analyses,
6210
6227
  targetFiles,
6211
- graphqlSystemPath
6228
+ graphqlSystemPath,
6229
+ aliasResolver
6212
6230
  })) {
6213
6231
  intermediateModules.set(intermediateModule.filePath, intermediateModule);
6214
6232
  }
@@ -6271,4 +6289,4 @@ const createBuilderService = ({ config, entrypointsOverride }) => {
6271
6289
 
6272
6290
  //#endregion
6273
6291
  export { getSeverity as _, createGraphqlSystemIdentifyHelper as a, BuilderArtifactSchema as b, BuilderEffects as c, formatBuilderErrorForCLI as d, formatBuilderErrorStructured as f, diagnosticMessages as g, createStandardDiagnostic as h, extractModuleAdjacency as i, FileReadEffect as l, createDiagnostic as m, createBuilderSession as n, __clearGqlCache as o, builderErrors as p, collectAffectedFiles as r, executeSandbox as s, createBuilderService as t, FileStatEffect as u, loadArtifact as v, loadArtifactSync as y };
6274
- //# sourceMappingURL=service-iCPQhpXW.mjs.map
6292
+ //# sourceMappingURL=service-Dp3ZaxVG.mjs.map