houdini 1.2.30 → 1.2.32

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.
@@ -68013,7 +68013,15 @@ var Config = class {
68013
68013
  const extensions = [".graphql", ".gql", ".ts", ".js"].concat(
68014
68014
  this.plugins.flatMap((plugin2) => plugin2.extensions ?? [])
68015
68015
  );
68016
- return [`src/**/*{${extensions.join(",")}}`];
68016
+ const include = [`src/**/*{${extensions.join(",")}}`];
68017
+ for (const plugin2 of this.plugins) {
68018
+ if (!plugin2.includeRuntime) {
68019
+ continue;
68020
+ }
68021
+ const includePath = relative(this.projectRoot, this.pluginDirectory(plugin2.name));
68022
+ include.push(`${includePath}/**/*{${extensions.join(",")}}`);
68023
+ }
68024
+ return include;
68017
68025
  }
68018
68026
  pluginConfig(name) {
68019
68027
  return this.configFile.plugins?.[name] ?? {};
@@ -72482,9 +72490,11 @@ ${exportStatement("plugins")}
72482
72490
 
72483
72491
  // src/codegen/generators/runtime/index.ts
72484
72492
  async function runtimeGenerator(config, docs) {
72485
- const importStatement = config.module === "commonjs" ? importDefaultFrom : (where, as) => `import ${as} from '${where}'`;
72486
- const exportStatement = config.module === "commonjs" ? exportDefault : (as) => `export default ${as}`;
72487
- const exportStar = config.module === "commonjs" ? exportStarFrom : (where) => `export * from '${where}'`;
72493
+ const {
72494
+ importStatement,
72495
+ exportDefaultStatement: exportStatement,
72496
+ exportStarStatement: exportStar
72497
+ } = moduleStatments(config);
72488
72498
  await Promise.all([
72489
72499
  fs_exports.recursiveCopy(config.runtimeSource, config.runtimeDirectory, {
72490
72500
  [path_exports.join(config.runtimeSource, "lib", "constants.js")]: (content) => {
@@ -72502,66 +72512,71 @@ ${exportStatement("config")}
72502
72512
  },
72503
72513
  [path_exports.join(config.runtimeSource, "client", "plugins", "injectedPlugins.js")]: (content) => injectPlugins({ config, content, importStatement, exportStatement })
72504
72514
  }),
72505
- ...config.plugins.filter((plugin2) => plugin2.includeRuntime).map(
72506
- (plugin2) => generatePluginRuntime({
72507
- config,
72508
- docs,
72509
- plugin: plugin2,
72510
- importStatement,
72511
- exportDefaultStatement: exportStatement,
72512
- exportStarStatement: exportStar
72513
- })
72514
- ),
72515
+ transformPluginRuntimes({ config, docs }),
72515
72516
  generatePluginIndex({ config, exportStatement: exportStar })
72516
72517
  ]);
72517
72518
  await generateGraphqlReturnTypes(config, docs);
72518
72519
  }
72519
- async function generatePluginRuntime({
72520
- config,
72521
- docs,
72522
- plugin: plugin2,
72523
- importStatement,
72524
- exportDefaultStatement,
72525
- exportStarStatement
72526
- }) {
72527
- if (houdini_mode.is_testing || !plugin2.includeRuntime) {
72528
- return;
72529
- }
72530
- const runtime_path = path_exports.join(
72531
- path_exports.dirname(plugin2.filepath),
72532
- typeof plugin2.includeRuntime === "string" ? plugin2.includeRuntime : plugin2.includeRuntime[config.module]
72520
+ async function generatePluginRuntimes({ config }) {
72521
+ await Promise.all(
72522
+ config.plugins.filter((plugin2) => plugin2.includeRuntime).map(async (plugin2) => {
72523
+ if (houdini_mode.is_testing || !plugin2.includeRuntime) {
72524
+ return;
72525
+ }
72526
+ const runtime_path = path_exports.join(
72527
+ path_exports.dirname(plugin2.filepath),
72528
+ typeof plugin2.includeRuntime === "string" ? plugin2.includeRuntime : plugin2.includeRuntime[config.module]
72529
+ );
72530
+ try {
72531
+ await fs_exports.stat(runtime_path);
72532
+ } catch {
72533
+ throw new HoudiniError({
72534
+ message: "Cannot find runtime to generate for " + plugin2.name,
72535
+ description: "Maybe it was bundled?"
72536
+ });
72537
+ }
72538
+ const pluginDir = config.pluginRuntimeDirectory(plugin2.name);
72539
+ await fs_exports.mkdirp(pluginDir);
72540
+ await fs_exports.recursiveCopy(runtime_path, pluginDir);
72541
+ })
72533
72542
  );
72534
- try {
72535
- await fs_exports.stat(runtime_path);
72536
- } catch {
72537
- throw new HoudiniError({
72538
- message: "Cannot find runtime to generate for " + plugin2.name,
72539
- description: "Maybe it was bundled?"
72540
- });
72541
- }
72542
- const pluginDir = config.pluginRuntimeDirectory(plugin2.name);
72543
- let transformMap = plugin2.transformRuntime ?? {};
72544
- if (transformMap && typeof transformMap === "function") {
72545
- transformMap = transformMap(docs, { config });
72546
- }
72547
- await fs_exports.mkdirp(pluginDir);
72548
- await fs_exports.recursiveCopy(
72549
- runtime_path,
72550
- pluginDir,
72551
- Object.fromEntries(
72552
- Object.entries(transformMap).map(([key, value]) => [
72553
- path_exports.join(runtime_path, key),
72554
- (content) => value({
72543
+ }
72544
+ async function transformPluginRuntimes({ config, docs }) {
72545
+ const { importStatement, exportDefaultStatement, exportStarStatement } = moduleStatments(config);
72546
+ await Promise.all(
72547
+ config.plugins.filter((plugin2) => plugin2.includeRuntime).map(async (plugin2) => {
72548
+ let transformMap = plugin2.transformRuntime ?? {};
72549
+ if (transformMap && typeof transformMap === "function") {
72550
+ transformMap = transformMap(docs, { config });
72551
+ }
72552
+ for (const [target, transform] of Object.entries(transformMap)) {
72553
+ const targetPath = path_exports.join(config.pluginRuntimeDirectory(plugin2.name), target);
72554
+ const content = await fs_exports.readFile(targetPath);
72555
+ if (!content) {
72556
+ return;
72557
+ }
72558
+ const transformed = transform({
72555
72559
  config,
72556
72560
  content,
72557
72561
  importStatement,
72558
72562
  exportDefaultStatement,
72559
72563
  exportStarStatement
72560
- })
72561
- ])
72562
- )
72564
+ });
72565
+ await fs_exports.writeFile(targetPath, transformed);
72566
+ }
72567
+ })
72563
72568
  );
72564
72569
  }
72570
+ function moduleStatments(config) {
72571
+ const importStatement = config.module === "commonjs" ? importDefaultFrom : (where, as) => `import ${as} from '${where}'`;
72572
+ const exportDefaultStatement = config.module === "commonjs" ? exportDefault : (as) => `export default ${as}`;
72573
+ const exportStarStatement = config.module === "commonjs" ? exportStarFrom : (where) => `export * from '${where}'`;
72574
+ return {
72575
+ importStatement,
72576
+ exportDefaultStatement,
72577
+ exportStarStatement
72578
+ };
72579
+ }
72565
72580
 
72566
72581
  // src/codegen/generators/typescript/documentTypes.ts
72567
72582
  var recast12 = __toESM(require_main2(), 1);
@@ -77181,6 +77196,7 @@ async function componentFields2(config, docs) {
77181
77196
 
77182
77197
  // src/codegen/index.ts
77183
77198
  async function compile(config) {
77199
+ await generatePluginRuntimes({ config });
77184
77200
  const documents = await collectDocuments(config);
77185
77201
  await runPipeline2(config, documents);
77186
77202
  }
@@ -78491,12 +78507,12 @@ async function packageJSON(targetPath, frameworkInfo) {
78491
78507
  }
78492
78508
  packageJSON2.devDependencies = {
78493
78509
  ...packageJSON2.devDependencies,
78494
- houdini: "^1.2.30"
78510
+ houdini: "^1.2.32"
78495
78511
  };
78496
78512
  if (frameworkInfo.framework === "svelte" || frameworkInfo.framework === "kit") {
78497
78513
  packageJSON2.devDependencies = {
78498
78514
  ...packageJSON2.devDependencies,
78499
- "houdini-svelte": "^1.2.30"
78515
+ "houdini-svelte": "^1.2.32"
78500
78516
  };
78501
78517
  } else {
78502
78518
  throw new Error(`Unmanaged framework: "${JSON.stringify(frameworkInfo)}"`);
@@ -68018,7 +68018,15 @@ var Config = class {
68018
68018
  const extensions = [".graphql", ".gql", ".ts", ".js"].concat(
68019
68019
  this.plugins.flatMap((plugin2) => plugin2.extensions ?? [])
68020
68020
  );
68021
- return [`src/**/*{${extensions.join(",")}}`];
68021
+ const include = [`src/**/*{${extensions.join(",")}}`];
68022
+ for (const plugin2 of this.plugins) {
68023
+ if (!plugin2.includeRuntime) {
68024
+ continue;
68025
+ }
68026
+ const includePath = relative(this.projectRoot, this.pluginDirectory(plugin2.name));
68027
+ include.push(`${includePath}/**/*{${extensions.join(",")}}`);
68028
+ }
68029
+ return include;
68022
68030
  }
68023
68031
  pluginConfig(name) {
68024
68032
  return this.configFile.plugins?.[name] ?? {};
@@ -72487,9 +72495,11 @@ ${exportStatement("plugins")}
72487
72495
 
72488
72496
  // src/codegen/generators/runtime/index.ts
72489
72497
  async function runtimeGenerator(config, docs) {
72490
- const importStatement = config.module === "commonjs" ? importDefaultFrom : (where, as) => `import ${as} from '${where}'`;
72491
- const exportStatement = config.module === "commonjs" ? exportDefault : (as) => `export default ${as}`;
72492
- const exportStar = config.module === "commonjs" ? exportStarFrom : (where) => `export * from '${where}'`;
72498
+ const {
72499
+ importStatement,
72500
+ exportDefaultStatement: exportStatement,
72501
+ exportStarStatement: exportStar
72502
+ } = moduleStatments(config);
72493
72503
  await Promise.all([
72494
72504
  fs_exports.recursiveCopy(config.runtimeSource, config.runtimeDirectory, {
72495
72505
  [path_exports.join(config.runtimeSource, "lib", "constants.js")]: (content) => {
@@ -72507,66 +72517,71 @@ ${exportStatement("config")}
72507
72517
  },
72508
72518
  [path_exports.join(config.runtimeSource, "client", "plugins", "injectedPlugins.js")]: (content) => injectPlugins({ config, content, importStatement, exportStatement })
72509
72519
  }),
72510
- ...config.plugins.filter((plugin2) => plugin2.includeRuntime).map(
72511
- (plugin2) => generatePluginRuntime({
72512
- config,
72513
- docs,
72514
- plugin: plugin2,
72515
- importStatement,
72516
- exportDefaultStatement: exportStatement,
72517
- exportStarStatement: exportStar
72518
- })
72519
- ),
72520
+ transformPluginRuntimes({ config, docs }),
72520
72521
  generatePluginIndex({ config, exportStatement: exportStar })
72521
72522
  ]);
72522
72523
  await generateGraphqlReturnTypes(config, docs);
72523
72524
  }
72524
- async function generatePluginRuntime({
72525
- config,
72526
- docs,
72527
- plugin: plugin2,
72528
- importStatement,
72529
- exportDefaultStatement,
72530
- exportStarStatement
72531
- }) {
72532
- if (houdini_mode.is_testing || !plugin2.includeRuntime) {
72533
- return;
72534
- }
72535
- const runtime_path = path_exports.join(
72536
- path_exports.dirname(plugin2.filepath),
72537
- typeof plugin2.includeRuntime === "string" ? plugin2.includeRuntime : plugin2.includeRuntime[config.module]
72525
+ async function generatePluginRuntimes({ config }) {
72526
+ await Promise.all(
72527
+ config.plugins.filter((plugin2) => plugin2.includeRuntime).map(async (plugin2) => {
72528
+ if (houdini_mode.is_testing || !plugin2.includeRuntime) {
72529
+ return;
72530
+ }
72531
+ const runtime_path = path_exports.join(
72532
+ path_exports.dirname(plugin2.filepath),
72533
+ typeof plugin2.includeRuntime === "string" ? plugin2.includeRuntime : plugin2.includeRuntime[config.module]
72534
+ );
72535
+ try {
72536
+ await fs_exports.stat(runtime_path);
72537
+ } catch {
72538
+ throw new HoudiniError({
72539
+ message: "Cannot find runtime to generate for " + plugin2.name,
72540
+ description: "Maybe it was bundled?"
72541
+ });
72542
+ }
72543
+ const pluginDir = config.pluginRuntimeDirectory(plugin2.name);
72544
+ await fs_exports.mkdirp(pluginDir);
72545
+ await fs_exports.recursiveCopy(runtime_path, pluginDir);
72546
+ })
72538
72547
  );
72539
- try {
72540
- await fs_exports.stat(runtime_path);
72541
- } catch {
72542
- throw new HoudiniError({
72543
- message: "Cannot find runtime to generate for " + plugin2.name,
72544
- description: "Maybe it was bundled?"
72545
- });
72546
- }
72547
- const pluginDir = config.pluginRuntimeDirectory(plugin2.name);
72548
- let transformMap = plugin2.transformRuntime ?? {};
72549
- if (transformMap && typeof transformMap === "function") {
72550
- transformMap = transformMap(docs, { config });
72551
- }
72552
- await fs_exports.mkdirp(pluginDir);
72553
- await fs_exports.recursiveCopy(
72554
- runtime_path,
72555
- pluginDir,
72556
- Object.fromEntries(
72557
- Object.entries(transformMap).map(([key, value]) => [
72558
- path_exports.join(runtime_path, key),
72559
- (content) => value({
72548
+ }
72549
+ async function transformPluginRuntimes({ config, docs }) {
72550
+ const { importStatement, exportDefaultStatement, exportStarStatement } = moduleStatments(config);
72551
+ await Promise.all(
72552
+ config.plugins.filter((plugin2) => plugin2.includeRuntime).map(async (plugin2) => {
72553
+ let transformMap = plugin2.transformRuntime ?? {};
72554
+ if (transformMap && typeof transformMap === "function") {
72555
+ transformMap = transformMap(docs, { config });
72556
+ }
72557
+ for (const [target, transform] of Object.entries(transformMap)) {
72558
+ const targetPath = path_exports.join(config.pluginRuntimeDirectory(plugin2.name), target);
72559
+ const content = await fs_exports.readFile(targetPath);
72560
+ if (!content) {
72561
+ return;
72562
+ }
72563
+ const transformed = transform({
72560
72564
  config,
72561
72565
  content,
72562
72566
  importStatement,
72563
72567
  exportDefaultStatement,
72564
72568
  exportStarStatement
72565
- })
72566
- ])
72567
- )
72569
+ });
72570
+ await fs_exports.writeFile(targetPath, transformed);
72571
+ }
72572
+ })
72568
72573
  );
72569
72574
  }
72575
+ function moduleStatments(config) {
72576
+ const importStatement = config.module === "commonjs" ? importDefaultFrom : (where, as) => `import ${as} from '${where}'`;
72577
+ const exportDefaultStatement = config.module === "commonjs" ? exportDefault : (as) => `export default ${as}`;
72578
+ const exportStarStatement = config.module === "commonjs" ? exportStarFrom : (where) => `export * from '${where}'`;
72579
+ return {
72580
+ importStatement,
72581
+ exportDefaultStatement,
72582
+ exportStarStatement
72583
+ };
72584
+ }
72570
72585
 
72571
72586
  // src/codegen/generators/typescript/documentTypes.ts
72572
72587
  var recast12 = __toESM(require_main2(), 1);
@@ -77186,6 +77201,7 @@ async function componentFields2(config, docs) {
77186
77201
 
77187
77202
  // src/codegen/index.ts
77188
77203
  async function compile(config) {
77204
+ await generatePluginRuntimes({ config });
77189
77205
  const documents = await collectDocuments(config);
77190
77206
  await runPipeline2(config, documents);
77191
77207
  }
@@ -78496,12 +78512,12 @@ async function packageJSON(targetPath, frameworkInfo) {
78496
78512
  }
78497
78513
  packageJSON2.devDependencies = {
78498
78514
  ...packageJSON2.devDependencies,
78499
- houdini: "^1.2.30"
78515
+ houdini: "^1.2.32"
78500
78516
  };
78501
78517
  if (frameworkInfo.framework === "svelte" || frameworkInfo.framework === "kit") {
78502
78518
  packageJSON2.devDependencies = {
78503
78519
  ...packageJSON2.devDependencies,
78504
- "houdini-svelte": "^1.2.30"
78520
+ "houdini-svelte": "^1.2.32"
78505
78521
  };
78506
78522
  } else {
78507
78523
  throw new Error(`Unmanaged framework: "${JSON.stringify(frameworkInfo)}"`);
@@ -1,2 +1,5 @@
1
1
  import type { Config, Document } from '../../../lib';
2
2
  export default function runtimeGenerator(config: Config, docs: Document[]): Promise<void>;
3
+ export declare function generatePluginRuntimes({ config }: {
4
+ config: Config;
5
+ }): Promise<void>;
@@ -60889,9 +60889,11 @@ ${exportStatement("plugins")}
60889
60889
 
60890
60890
  // src/codegen/generators/runtime/index.ts
60891
60891
  async function runtimeGenerator(config, docs) {
60892
- const importStatement = config.module === "commonjs" ? importDefaultFrom : (where, as) => `import ${as} from '${where}'`;
60893
- const exportStatement = config.module === "commonjs" ? exportDefault : (as) => `export default ${as}`;
60894
- const exportStar = config.module === "commonjs" ? exportStarFrom : (where) => `export * from '${where}'`;
60892
+ const {
60893
+ importStatement,
60894
+ exportDefaultStatement: exportStatement,
60895
+ exportStarStatement: exportStar
60896
+ } = moduleStatments(config);
60895
60897
  await Promise.all([
60896
60898
  fs_exports.recursiveCopy(config.runtimeSource, config.runtimeDirectory, {
60897
60899
  [path_exports.join(config.runtimeSource, "lib", "constants.js")]: (content) => {
@@ -60909,66 +60911,71 @@ ${exportStatement("config")}
60909
60911
  },
60910
60912
  [path_exports.join(config.runtimeSource, "client", "plugins", "injectedPlugins.js")]: (content) => injectPlugins({ config, content, importStatement, exportStatement })
60911
60913
  }),
60912
- ...config.plugins.filter((plugin2) => plugin2.includeRuntime).map(
60913
- (plugin2) => generatePluginRuntime({
60914
- config,
60915
- docs,
60916
- plugin: plugin2,
60917
- importStatement,
60918
- exportDefaultStatement: exportStatement,
60919
- exportStarStatement: exportStar
60920
- })
60921
- ),
60914
+ transformPluginRuntimes({ config, docs }),
60922
60915
  generatePluginIndex({ config, exportStatement: exportStar })
60923
60916
  ]);
60924
60917
  await generateGraphqlReturnTypes(config, docs);
60925
60918
  }
60926
- async function generatePluginRuntime({
60927
- config,
60928
- docs,
60929
- plugin: plugin2,
60930
- importStatement,
60931
- exportDefaultStatement,
60932
- exportStarStatement
60933
- }) {
60934
- if (houdini_mode.is_testing || !plugin2.includeRuntime) {
60935
- return;
60936
- }
60937
- const runtime_path = path_exports.join(
60938
- path_exports.dirname(plugin2.filepath),
60939
- typeof plugin2.includeRuntime === "string" ? plugin2.includeRuntime : plugin2.includeRuntime[config.module]
60919
+ async function generatePluginRuntimes({ config }) {
60920
+ await Promise.all(
60921
+ config.plugins.filter((plugin2) => plugin2.includeRuntime).map(async (plugin2) => {
60922
+ if (houdini_mode.is_testing || !plugin2.includeRuntime) {
60923
+ return;
60924
+ }
60925
+ const runtime_path = path_exports.join(
60926
+ path_exports.dirname(plugin2.filepath),
60927
+ typeof plugin2.includeRuntime === "string" ? plugin2.includeRuntime : plugin2.includeRuntime[config.module]
60928
+ );
60929
+ try {
60930
+ await fs_exports.stat(runtime_path);
60931
+ } catch {
60932
+ throw new HoudiniError({
60933
+ message: "Cannot find runtime to generate for " + plugin2.name,
60934
+ description: "Maybe it was bundled?"
60935
+ });
60936
+ }
60937
+ const pluginDir = config.pluginRuntimeDirectory(plugin2.name);
60938
+ await fs_exports.mkdirp(pluginDir);
60939
+ await fs_exports.recursiveCopy(runtime_path, pluginDir);
60940
+ })
60940
60941
  );
60941
- try {
60942
- await fs_exports.stat(runtime_path);
60943
- } catch {
60944
- throw new HoudiniError({
60945
- message: "Cannot find runtime to generate for " + plugin2.name,
60946
- description: "Maybe it was bundled?"
60947
- });
60948
- }
60949
- const pluginDir = config.pluginRuntimeDirectory(plugin2.name);
60950
- let transformMap = plugin2.transformRuntime ?? {};
60951
- if (transformMap && typeof transformMap === "function") {
60952
- transformMap = transformMap(docs, { config });
60953
- }
60954
- await fs_exports.mkdirp(pluginDir);
60955
- await fs_exports.recursiveCopy(
60956
- runtime_path,
60957
- pluginDir,
60958
- Object.fromEntries(
60959
- Object.entries(transformMap).map(([key, value]) => [
60960
- path_exports.join(runtime_path, key),
60961
- (content) => value({
60942
+ }
60943
+ async function transformPluginRuntimes({ config, docs }) {
60944
+ const { importStatement, exportDefaultStatement, exportStarStatement } = moduleStatments(config);
60945
+ await Promise.all(
60946
+ config.plugins.filter((plugin2) => plugin2.includeRuntime).map(async (plugin2) => {
60947
+ let transformMap = plugin2.transformRuntime ?? {};
60948
+ if (transformMap && typeof transformMap === "function") {
60949
+ transformMap = transformMap(docs, { config });
60950
+ }
60951
+ for (const [target, transform] of Object.entries(transformMap)) {
60952
+ const targetPath = path_exports.join(config.pluginRuntimeDirectory(plugin2.name), target);
60953
+ const content = await fs_exports.readFile(targetPath);
60954
+ if (!content) {
60955
+ return;
60956
+ }
60957
+ const transformed = transform({
60962
60958
  config,
60963
60959
  content,
60964
60960
  importStatement,
60965
60961
  exportDefaultStatement,
60966
60962
  exportStarStatement
60967
- })
60968
- ])
60969
- )
60963
+ });
60964
+ await fs_exports.writeFile(targetPath, transformed);
60965
+ }
60966
+ })
60970
60967
  );
60971
60968
  }
60969
+ function moduleStatments(config) {
60970
+ const importStatement = config.module === "commonjs" ? importDefaultFrom : (where, as) => `import ${as} from '${where}'`;
60971
+ const exportDefaultStatement = config.module === "commonjs" ? exportDefault : (as) => `export default ${as}`;
60972
+ const exportStarStatement = config.module === "commonjs" ? exportStarFrom : (where) => `export * from '${where}'`;
60973
+ return {
60974
+ importStatement,
60975
+ exportDefaultStatement,
60976
+ exportStarStatement
60977
+ };
60978
+ }
60972
60979
 
60973
60980
  // src/codegen/generators/typescript/documentTypes.ts
60974
60981
  var recast12 = __toESM(require_main2(), 1);
@@ -65588,6 +65595,7 @@ async function componentFields2(config, docs) {
65588
65595
 
65589
65596
  // src/codegen/index.ts
65590
65597
  async function compile(config) {
65598
+ await generatePluginRuntimes({ config });
65591
65599
  const documents = await collectDocuments(config);
65592
65600
  await runPipeline2(config, documents);
65593
65601
  }
@@ -60888,9 +60888,11 @@ ${exportStatement("plugins")}
60888
60888
 
60889
60889
  // src/codegen/generators/runtime/index.ts
60890
60890
  async function runtimeGenerator(config, docs) {
60891
- const importStatement = config.module === "commonjs" ? importDefaultFrom : (where, as) => `import ${as} from '${where}'`;
60892
- const exportStatement = config.module === "commonjs" ? exportDefault : (as) => `export default ${as}`;
60893
- const exportStar = config.module === "commonjs" ? exportStarFrom : (where) => `export * from '${where}'`;
60891
+ const {
60892
+ importStatement,
60893
+ exportDefaultStatement: exportStatement,
60894
+ exportStarStatement: exportStar
60895
+ } = moduleStatments(config);
60894
60896
  await Promise.all([
60895
60897
  fs_exports.recursiveCopy(config.runtimeSource, config.runtimeDirectory, {
60896
60898
  [path_exports.join(config.runtimeSource, "lib", "constants.js")]: (content) => {
@@ -60908,66 +60910,71 @@ ${exportStatement("config")}
60908
60910
  },
60909
60911
  [path_exports.join(config.runtimeSource, "client", "plugins", "injectedPlugins.js")]: (content) => injectPlugins({ config, content, importStatement, exportStatement })
60910
60912
  }),
60911
- ...config.plugins.filter((plugin2) => plugin2.includeRuntime).map(
60912
- (plugin2) => generatePluginRuntime({
60913
- config,
60914
- docs,
60915
- plugin: plugin2,
60916
- importStatement,
60917
- exportDefaultStatement: exportStatement,
60918
- exportStarStatement: exportStar
60919
- })
60920
- ),
60913
+ transformPluginRuntimes({ config, docs }),
60921
60914
  generatePluginIndex({ config, exportStatement: exportStar })
60922
60915
  ]);
60923
60916
  await generateGraphqlReturnTypes(config, docs);
60924
60917
  }
60925
- async function generatePluginRuntime({
60926
- config,
60927
- docs,
60928
- plugin: plugin2,
60929
- importStatement,
60930
- exportDefaultStatement,
60931
- exportStarStatement
60932
- }) {
60933
- if (houdini_mode.is_testing || !plugin2.includeRuntime) {
60934
- return;
60935
- }
60936
- const runtime_path = path_exports.join(
60937
- path_exports.dirname(plugin2.filepath),
60938
- typeof plugin2.includeRuntime === "string" ? plugin2.includeRuntime : plugin2.includeRuntime[config.module]
60918
+ async function generatePluginRuntimes({ config }) {
60919
+ await Promise.all(
60920
+ config.plugins.filter((plugin2) => plugin2.includeRuntime).map(async (plugin2) => {
60921
+ if (houdini_mode.is_testing || !plugin2.includeRuntime) {
60922
+ return;
60923
+ }
60924
+ const runtime_path = path_exports.join(
60925
+ path_exports.dirname(plugin2.filepath),
60926
+ typeof plugin2.includeRuntime === "string" ? plugin2.includeRuntime : plugin2.includeRuntime[config.module]
60927
+ );
60928
+ try {
60929
+ await fs_exports.stat(runtime_path);
60930
+ } catch {
60931
+ throw new HoudiniError({
60932
+ message: "Cannot find runtime to generate for " + plugin2.name,
60933
+ description: "Maybe it was bundled?"
60934
+ });
60935
+ }
60936
+ const pluginDir = config.pluginRuntimeDirectory(plugin2.name);
60937
+ await fs_exports.mkdirp(pluginDir);
60938
+ await fs_exports.recursiveCopy(runtime_path, pluginDir);
60939
+ })
60939
60940
  );
60940
- try {
60941
- await fs_exports.stat(runtime_path);
60942
- } catch {
60943
- throw new HoudiniError({
60944
- message: "Cannot find runtime to generate for " + plugin2.name,
60945
- description: "Maybe it was bundled?"
60946
- });
60947
- }
60948
- const pluginDir = config.pluginRuntimeDirectory(plugin2.name);
60949
- let transformMap = plugin2.transformRuntime ?? {};
60950
- if (transformMap && typeof transformMap === "function") {
60951
- transformMap = transformMap(docs, { config });
60952
- }
60953
- await fs_exports.mkdirp(pluginDir);
60954
- await fs_exports.recursiveCopy(
60955
- runtime_path,
60956
- pluginDir,
60957
- Object.fromEntries(
60958
- Object.entries(transformMap).map(([key, value]) => [
60959
- path_exports.join(runtime_path, key),
60960
- (content) => value({
60941
+ }
60942
+ async function transformPluginRuntimes({ config, docs }) {
60943
+ const { importStatement, exportDefaultStatement, exportStarStatement } = moduleStatments(config);
60944
+ await Promise.all(
60945
+ config.plugins.filter((plugin2) => plugin2.includeRuntime).map(async (plugin2) => {
60946
+ let transformMap = plugin2.transformRuntime ?? {};
60947
+ if (transformMap && typeof transformMap === "function") {
60948
+ transformMap = transformMap(docs, { config });
60949
+ }
60950
+ for (const [target, transform] of Object.entries(transformMap)) {
60951
+ const targetPath = path_exports.join(config.pluginRuntimeDirectory(plugin2.name), target);
60952
+ const content = await fs_exports.readFile(targetPath);
60953
+ if (!content) {
60954
+ return;
60955
+ }
60956
+ const transformed = transform({
60961
60957
  config,
60962
60958
  content,
60963
60959
  importStatement,
60964
60960
  exportDefaultStatement,
60965
60961
  exportStarStatement
60966
- })
60967
- ])
60968
- )
60962
+ });
60963
+ await fs_exports.writeFile(targetPath, transformed);
60964
+ }
60965
+ })
60969
60966
  );
60970
60967
  }
60968
+ function moduleStatments(config) {
60969
+ const importStatement = config.module === "commonjs" ? importDefaultFrom : (where, as) => `import ${as} from '${where}'`;
60970
+ const exportDefaultStatement = config.module === "commonjs" ? exportDefault : (as) => `export default ${as}`;
60971
+ const exportStarStatement = config.module === "commonjs" ? exportStarFrom : (where) => `export * from '${where}'`;
60972
+ return {
60973
+ importStatement,
60974
+ exportDefaultStatement,
60975
+ exportStarStatement
60976
+ };
60977
+ }
60971
60978
 
60972
60979
  // src/codegen/generators/typescript/documentTypes.ts
60973
60980
  var recast12 = __toESM(require_main2(), 1);
@@ -65587,6 +65594,7 @@ async function componentFields2(config, docs) {
65587
65594
 
65588
65595
  // src/codegen/index.ts
65589
65596
  async function compile(config) {
65597
+ await generatePluginRuntimes({ config });
65590
65598
  const documents = await collectDocuments(config);
65591
65599
  await runPipeline2(config, documents);
65592
65600
  }