houdini 1.2.31 → 1.2.33

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.
@@ -60862,6 +60862,55 @@ async function generatePluginIndex({
60862
60862
  ]);
60863
60863
  }
60864
60864
 
60865
+ // src/codegen/generators/runtime/pluginRuntime.ts
60866
+ async function generatePluginRuntimes({
60867
+ config,
60868
+ docs
60869
+ }) {
60870
+ if (houdini_mode.is_testing) {
60871
+ return;
60872
+ }
60873
+ const { importStatement, exportDefaultStatement, exportStarStatement } = moduleStatments(config);
60874
+ await Promise.all(
60875
+ config.plugins.filter((plugin2) => plugin2.includeRuntime).map(async (plugin2) => {
60876
+ const runtime_path = config.pluginRuntimeSource(plugin2);
60877
+ if (!runtime_path) {
60878
+ return;
60879
+ }
60880
+ try {
60881
+ await fs_exports.stat(runtime_path);
60882
+ } catch {
60883
+ throw new HoudiniError({
60884
+ message: "Cannot find runtime to generate for " + plugin2.name,
60885
+ description: "Maybe it was bundled?"
60886
+ });
60887
+ }
60888
+ const pluginDir = config.pluginRuntimeDirectory(plugin2.name);
60889
+ let transformMap = plugin2.transformRuntime ?? {};
60890
+ if (transformMap && typeof transformMap === "function") {
60891
+ transformMap = transformMap(docs, { config });
60892
+ }
60893
+ await fs_exports.mkdirp(pluginDir);
60894
+ await fs_exports.recursiveCopy(
60895
+ runtime_path,
60896
+ pluginDir,
60897
+ Object.fromEntries(
60898
+ Object.entries(transformMap).map(([key, value]) => [
60899
+ path_exports.join(runtime_path, key),
60900
+ (content) => value({
60901
+ config,
60902
+ content,
60903
+ importStatement,
60904
+ exportDefaultStatement,
60905
+ exportStarStatement
60906
+ })
60907
+ ])
60908
+ )
60909
+ );
60910
+ })
60911
+ );
60912
+ }
60913
+
60865
60914
  // src/codegen/generators/runtime/runtimeConfig.ts
60866
60915
  async function injectConfig({
60867
60916
  config,
@@ -60888,9 +60937,11 @@ ${exportStatement("plugins")}
60888
60937
 
60889
60938
  // src/codegen/generators/runtime/index.ts
60890
60939
  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}'`;
60940
+ const {
60941
+ importStatement,
60942
+ exportDefaultStatement: exportStatement,
60943
+ exportStarStatement: exportStar
60944
+ } = moduleStatments(config);
60894
60945
  await Promise.all([
60895
60946
  fs_exports.recursiveCopy(config.runtimeSource, config.runtimeDirectory, {
60896
60947
  [path_exports.join(config.runtimeSource, "lib", "constants.js")]: (content) => {
@@ -60908,65 +60959,23 @@ ${exportStatement("config")}
60908
60959
  },
60909
60960
  [path_exports.join(config.runtimeSource, "client", "plugins", "injectedPlugins.js")]: (content) => injectPlugins({ config, content, importStatement, exportStatement })
60910
60961
  }),
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
- ),
60962
+ generatePluginRuntimes({
60963
+ config,
60964
+ docs
60965
+ }),
60921
60966
  generatePluginIndex({ config, exportStatement: exportStar })
60922
60967
  ]);
60923
60968
  await generateGraphqlReturnTypes(config, docs);
60924
60969
  }
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]
60939
- );
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({
60961
- config,
60962
- content,
60963
- importStatement,
60964
- exportDefaultStatement,
60965
- exportStarStatement
60966
- })
60967
- ])
60968
- )
60969
- );
60970
+ function moduleStatments(config) {
60971
+ const importStatement = config.module === "commonjs" ? importDefaultFrom : (where, as) => `import ${as} from '${where}'`;
60972
+ const exportDefaultStatement = config.module === "commonjs" ? exportDefault : (as) => `export default ${as}`;
60973
+ const exportStarStatement = config.module === "commonjs" ? exportStarFrom : (where) => `export * from '${where}'`;
60974
+ return {
60975
+ importStatement,
60976
+ exportDefaultStatement,
60977
+ exportStarStatement
60978
+ };
60970
60979
  }
60971
60980
 
60972
60981
  // src/codegen/generators/typescript/documentTypes.ts
@@ -53,6 +53,7 @@ export declare class Config {
53
53
  getEnv(): Promise<Record<string, string | undefined>>;
54
54
  processEnvValues(env: Record<string, string | undefined>, value: string | ((env: any) => string)): string | undefined;
55
55
  pullHeaders(): Promise<any>;
56
+ pluginRuntimeSource(plugin: PluginMeta): string | null;
56
57
  sourceFiles(): Promise<string[]>;
57
58
  get componentScalar(): string;
58
59
  schemaString: string;
@@ -98,6 +98,15 @@ export type PluginHooks = {
98
98
  esm: string;
99
99
  commonjs: string;
100
100
  };
101
+ /**
102
+ * A relative path from the file exporting your plugin to a runtime that can be
103
+ * added to the project before generating artifacts. This is useful for plugins
104
+ * that want to add third-party documents to the user's application.
105
+ */
106
+ staticRuntime?: string | {
107
+ esm: string;
108
+ commonjs: string;
109
+ };
101
110
  /**
102
111
  * Transform the plugin's runtime while houdini is copying it .
103
112
  * You must have passed a value to includeRuntime for this hook to matter.
@@ -67169,7 +67169,16 @@ var Config = class {
67169
67169
  const extensions = [".graphql", ".gql", ".ts", ".js"].concat(
67170
67170
  this.plugins.flatMap((plugin2) => plugin2.extensions ?? [])
67171
67171
  );
67172
- return [`src/**/*{${extensions.join(",")}}`];
67172
+ const include = [`src/**/*{${extensions.join(",")}}`];
67173
+ for (const plugin2 of this.plugins) {
67174
+ const runtimeDir = this.pluginRuntimeSource(plugin2);
67175
+ if (!runtimeDir) {
67176
+ continue;
67177
+ }
67178
+ const includePath = relative(this.projectRoot, runtimeDir);
67179
+ include.push(`${includePath}/**/*{${extensions.join(",")}}`);
67180
+ }
67181
+ return include;
67173
67182
  }
67174
67183
  pluginConfig(name) {
67175
67184
  return this.configFile.plugins?.[name] ?? {};
@@ -67212,6 +67221,15 @@ var Config = class {
67212
67221
  );
67213
67222
  return headers;
67214
67223
  }
67224
+ pluginRuntimeSource(plugin2) {
67225
+ if (!plugin2.includeRuntime) {
67226
+ return null;
67227
+ }
67228
+ return join2(
67229
+ dirname(plugin2.filepath),
67230
+ typeof plugin2.includeRuntime === "string" ? plugin2.includeRuntime : plugin2.includeRuntime?.[this.module]
67231
+ );
67232
+ }
67215
67233
  async sourceFiles() {
67216
67234
  return [
67217
67235
  ...new Set(
@@ -67090,7 +67090,16 @@ var Config = class {
67090
67090
  const extensions = [".graphql", ".gql", ".ts", ".js"].concat(
67091
67091
  this.plugins.flatMap((plugin2) => plugin2.extensions ?? [])
67092
67092
  );
67093
- return [`src/**/*{${extensions.join(",")}}`];
67093
+ const include = [`src/**/*{${extensions.join(",")}}`];
67094
+ for (const plugin2 of this.plugins) {
67095
+ const runtimeDir = this.pluginRuntimeSource(plugin2);
67096
+ if (!runtimeDir) {
67097
+ continue;
67098
+ }
67099
+ const includePath = relative(this.projectRoot, runtimeDir);
67100
+ include.push(`${includePath}/**/*{${extensions.join(",")}}`);
67101
+ }
67102
+ return include;
67094
67103
  }
67095
67104
  pluginConfig(name) {
67096
67105
  return this.configFile.plugins?.[name] ?? {};
@@ -67133,6 +67142,15 @@ var Config = class {
67133
67142
  );
67134
67143
  return headers;
67135
67144
  }
67145
+ pluginRuntimeSource(plugin2) {
67146
+ if (!plugin2.includeRuntime) {
67147
+ return null;
67148
+ }
67149
+ return join2(
67150
+ dirname(plugin2.filepath),
67151
+ typeof plugin2.includeRuntime === "string" ? plugin2.includeRuntime : plugin2.includeRuntime?.[this.module]
67152
+ );
67153
+ }
67136
67154
  async sourceFiles() {
67137
67155
  return [
67138
67156
  ...new Set(
@@ -57397,7 +57397,16 @@ var Config = class {
57397
57397
  const extensions = [".graphql", ".gql", ".ts", ".js"].concat(
57398
57398
  this.plugins.flatMap((plugin2) => plugin2.extensions ?? [])
57399
57399
  );
57400
- return [`src/**/*{${extensions.join(",")}}`];
57400
+ const include = [`src/**/*{${extensions.join(",")}}`];
57401
+ for (const plugin2 of this.plugins) {
57402
+ const runtimeDir = this.pluginRuntimeSource(plugin2);
57403
+ if (!runtimeDir) {
57404
+ continue;
57405
+ }
57406
+ const includePath = relative(this.projectRoot, runtimeDir);
57407
+ include.push(`${includePath}/**/*{${extensions.join(",")}}`);
57408
+ }
57409
+ return include;
57401
57410
  }
57402
57411
  pluginConfig(name) {
57403
57412
  return this.configFile.plugins?.[name] ?? {};
@@ -57440,6 +57449,15 @@ var Config = class {
57440
57449
  );
57441
57450
  return headers;
57442
57451
  }
57452
+ pluginRuntimeSource(plugin2) {
57453
+ if (!plugin2.includeRuntime) {
57454
+ return null;
57455
+ }
57456
+ return join(
57457
+ dirname(plugin2.filepath),
57458
+ typeof plugin2.includeRuntime === "string" ? plugin2.includeRuntime : plugin2.includeRuntime?.[this.module]
57459
+ );
57460
+ }
57443
57461
  async sourceFiles() {
57444
57462
  return [
57445
57463
  ...new Set(
@@ -61199,6 +61217,55 @@ async function generatePluginIndex({
61199
61217
  ]);
61200
61218
  }
61201
61219
 
61220
+ // src/codegen/generators/runtime/pluginRuntime.ts
61221
+ async function generatePluginRuntimes({
61222
+ config,
61223
+ docs
61224
+ }) {
61225
+ if (houdini_mode.is_testing) {
61226
+ return;
61227
+ }
61228
+ const { importStatement, exportDefaultStatement, exportStarStatement } = moduleStatments(config);
61229
+ await Promise.all(
61230
+ config.plugins.filter((plugin2) => plugin2.includeRuntime).map(async (plugin2) => {
61231
+ const runtime_path = config.pluginRuntimeSource(plugin2);
61232
+ if (!runtime_path) {
61233
+ return;
61234
+ }
61235
+ try {
61236
+ await fs_exports.stat(runtime_path);
61237
+ } catch {
61238
+ throw new HoudiniError({
61239
+ message: "Cannot find runtime to generate for " + plugin2.name,
61240
+ description: "Maybe it was bundled?"
61241
+ });
61242
+ }
61243
+ const pluginDir = config.pluginRuntimeDirectory(plugin2.name);
61244
+ let transformMap = plugin2.transformRuntime ?? {};
61245
+ if (transformMap && typeof transformMap === "function") {
61246
+ transformMap = transformMap(docs, { config });
61247
+ }
61248
+ await fs_exports.mkdirp(pluginDir);
61249
+ await fs_exports.recursiveCopy(
61250
+ runtime_path,
61251
+ pluginDir,
61252
+ Object.fromEntries(
61253
+ Object.entries(transformMap).map(([key, value]) => [
61254
+ path_exports.join(runtime_path, key),
61255
+ (content) => value({
61256
+ config,
61257
+ content,
61258
+ importStatement,
61259
+ exportDefaultStatement,
61260
+ exportStarStatement
61261
+ })
61262
+ ])
61263
+ )
61264
+ );
61265
+ })
61266
+ );
61267
+ }
61268
+
61202
61269
  // src/codegen/generators/runtime/runtimeConfig.ts
61203
61270
  async function injectConfig({
61204
61271
  config,
@@ -61225,9 +61292,11 @@ ${exportStatement("plugins")}
61225
61292
 
61226
61293
  // src/codegen/generators/runtime/index.ts
61227
61294
  async function runtimeGenerator(config, docs) {
61228
- const importStatement = config.module === "commonjs" ? importDefaultFrom : (where, as) => `import ${as} from '${where}'`;
61229
- const exportStatement = config.module === "commonjs" ? exportDefault : (as) => `export default ${as}`;
61230
- const exportStar = config.module === "commonjs" ? exportStarFrom : (where) => `export * from '${where}'`;
61295
+ const {
61296
+ importStatement,
61297
+ exportDefaultStatement: exportStatement,
61298
+ exportStarStatement: exportStar
61299
+ } = moduleStatments(config);
61231
61300
  await Promise.all([
61232
61301
  fs_exports.recursiveCopy(config.runtimeSource, config.runtimeDirectory, {
61233
61302
  [path_exports.join(config.runtimeSource, "lib", "constants.js")]: (content) => {
@@ -61245,65 +61314,23 @@ ${exportStatement("config")}
61245
61314
  },
61246
61315
  [path_exports.join(config.runtimeSource, "client", "plugins", "injectedPlugins.js")]: (content) => injectPlugins({ config, content, importStatement, exportStatement })
61247
61316
  }),
61248
- ...config.plugins.filter((plugin2) => plugin2.includeRuntime).map(
61249
- (plugin2) => generatePluginRuntime({
61250
- config,
61251
- docs,
61252
- plugin: plugin2,
61253
- importStatement,
61254
- exportDefaultStatement: exportStatement,
61255
- exportStarStatement: exportStar
61256
- })
61257
- ),
61317
+ generatePluginRuntimes({
61318
+ config,
61319
+ docs
61320
+ }),
61258
61321
  generatePluginIndex({ config, exportStatement: exportStar })
61259
61322
  ]);
61260
61323
  await generateGraphqlReturnTypes(config, docs);
61261
61324
  }
61262
- async function generatePluginRuntime({
61263
- config,
61264
- docs,
61265
- plugin: plugin2,
61266
- importStatement,
61267
- exportDefaultStatement,
61268
- exportStarStatement
61269
- }) {
61270
- if (houdini_mode.is_testing || !plugin2.includeRuntime) {
61271
- return;
61272
- }
61273
- const runtime_path = path_exports.join(
61274
- path_exports.dirname(plugin2.filepath),
61275
- typeof plugin2.includeRuntime === "string" ? plugin2.includeRuntime : plugin2.includeRuntime[config.module]
61276
- );
61277
- try {
61278
- await fs_exports.stat(runtime_path);
61279
- } catch {
61280
- throw new HoudiniError({
61281
- message: "Cannot find runtime to generate for " + plugin2.name,
61282
- description: "Maybe it was bundled?"
61283
- });
61284
- }
61285
- const pluginDir = config.pluginRuntimeDirectory(plugin2.name);
61286
- let transformMap = plugin2.transformRuntime ?? {};
61287
- if (transformMap && typeof transformMap === "function") {
61288
- transformMap = transformMap(docs, { config });
61289
- }
61290
- await fs_exports.mkdirp(pluginDir);
61291
- await fs_exports.recursiveCopy(
61292
- runtime_path,
61293
- pluginDir,
61294
- Object.fromEntries(
61295
- Object.entries(transformMap).map(([key, value]) => [
61296
- path_exports.join(runtime_path, key),
61297
- (content) => value({
61298
- config,
61299
- content,
61300
- importStatement,
61301
- exportDefaultStatement,
61302
- exportStarStatement
61303
- })
61304
- ])
61305
- )
61306
- );
61325
+ function moduleStatments(config) {
61326
+ const importStatement = config.module === "commonjs" ? importDefaultFrom : (where, as) => `import ${as} from '${where}'`;
61327
+ const exportDefaultStatement = config.module === "commonjs" ? exportDefault : (as) => `export default ${as}`;
61328
+ const exportStarStatement = config.module === "commonjs" ? exportStarFrom : (where) => `export * from '${where}'`;
61329
+ return {
61330
+ importStatement,
61331
+ exportDefaultStatement,
61332
+ exportStarStatement
61333
+ };
61307
61334
  }
61308
61335
 
61309
61336
  // src/codegen/generators/typescript/documentTypes.ts
@@ -57393,7 +57393,16 @@ var Config = class {
57393
57393
  const extensions = [".graphql", ".gql", ".ts", ".js"].concat(
57394
57394
  this.plugins.flatMap((plugin2) => plugin2.extensions ?? [])
57395
57395
  );
57396
- return [`src/**/*{${extensions.join(",")}}`];
57396
+ const include = [`src/**/*{${extensions.join(",")}}`];
57397
+ for (const plugin2 of this.plugins) {
57398
+ const runtimeDir = this.pluginRuntimeSource(plugin2);
57399
+ if (!runtimeDir) {
57400
+ continue;
57401
+ }
57402
+ const includePath = relative(this.projectRoot, runtimeDir);
57403
+ include.push(`${includePath}/**/*{${extensions.join(",")}}`);
57404
+ }
57405
+ return include;
57397
57406
  }
57398
57407
  pluginConfig(name) {
57399
57408
  return this.configFile.plugins?.[name] ?? {};
@@ -57436,6 +57445,15 @@ var Config = class {
57436
57445
  );
57437
57446
  return headers;
57438
57447
  }
57448
+ pluginRuntimeSource(plugin2) {
57449
+ if (!plugin2.includeRuntime) {
57450
+ return null;
57451
+ }
57452
+ return join(
57453
+ dirname(plugin2.filepath),
57454
+ typeof plugin2.includeRuntime === "string" ? plugin2.includeRuntime : plugin2.includeRuntime?.[this.module]
57455
+ );
57456
+ }
57439
57457
  async sourceFiles() {
57440
57458
  return [
57441
57459
  ...new Set(
@@ -61195,6 +61213,55 @@ async function generatePluginIndex({
61195
61213
  ]);
61196
61214
  }
61197
61215
 
61216
+ // src/codegen/generators/runtime/pluginRuntime.ts
61217
+ async function generatePluginRuntimes({
61218
+ config,
61219
+ docs
61220
+ }) {
61221
+ if (houdini_mode.is_testing) {
61222
+ return;
61223
+ }
61224
+ const { importStatement, exportDefaultStatement, exportStarStatement } = moduleStatments(config);
61225
+ await Promise.all(
61226
+ config.plugins.filter((plugin2) => plugin2.includeRuntime).map(async (plugin2) => {
61227
+ const runtime_path = config.pluginRuntimeSource(plugin2);
61228
+ if (!runtime_path) {
61229
+ return;
61230
+ }
61231
+ try {
61232
+ await fs_exports.stat(runtime_path);
61233
+ } catch {
61234
+ throw new HoudiniError({
61235
+ message: "Cannot find runtime to generate for " + plugin2.name,
61236
+ description: "Maybe it was bundled?"
61237
+ });
61238
+ }
61239
+ const pluginDir = config.pluginRuntimeDirectory(plugin2.name);
61240
+ let transformMap = plugin2.transformRuntime ?? {};
61241
+ if (transformMap && typeof transformMap === "function") {
61242
+ transformMap = transformMap(docs, { config });
61243
+ }
61244
+ await fs_exports.mkdirp(pluginDir);
61245
+ await fs_exports.recursiveCopy(
61246
+ runtime_path,
61247
+ pluginDir,
61248
+ Object.fromEntries(
61249
+ Object.entries(transformMap).map(([key, value]) => [
61250
+ path_exports.join(runtime_path, key),
61251
+ (content) => value({
61252
+ config,
61253
+ content,
61254
+ importStatement,
61255
+ exportDefaultStatement,
61256
+ exportStarStatement
61257
+ })
61258
+ ])
61259
+ )
61260
+ );
61261
+ })
61262
+ );
61263
+ }
61264
+
61198
61265
  // src/codegen/generators/runtime/runtimeConfig.ts
61199
61266
  async function injectConfig({
61200
61267
  config,
@@ -61221,9 +61288,11 @@ ${exportStatement("plugins")}
61221
61288
 
61222
61289
  // src/codegen/generators/runtime/index.ts
61223
61290
  async function runtimeGenerator(config, docs) {
61224
- const importStatement = config.module === "commonjs" ? importDefaultFrom : (where, as) => `import ${as} from '${where}'`;
61225
- const exportStatement = config.module === "commonjs" ? exportDefault : (as) => `export default ${as}`;
61226
- const exportStar = config.module === "commonjs" ? exportStarFrom : (where) => `export * from '${where}'`;
61291
+ const {
61292
+ importStatement,
61293
+ exportDefaultStatement: exportStatement,
61294
+ exportStarStatement: exportStar
61295
+ } = moduleStatments(config);
61227
61296
  await Promise.all([
61228
61297
  fs_exports.recursiveCopy(config.runtimeSource, config.runtimeDirectory, {
61229
61298
  [path_exports.join(config.runtimeSource, "lib", "constants.js")]: (content) => {
@@ -61241,65 +61310,23 @@ ${exportStatement("config")}
61241
61310
  },
61242
61311
  [path_exports.join(config.runtimeSource, "client", "plugins", "injectedPlugins.js")]: (content) => injectPlugins({ config, content, importStatement, exportStatement })
61243
61312
  }),
61244
- ...config.plugins.filter((plugin2) => plugin2.includeRuntime).map(
61245
- (plugin2) => generatePluginRuntime({
61246
- config,
61247
- docs,
61248
- plugin: plugin2,
61249
- importStatement,
61250
- exportDefaultStatement: exportStatement,
61251
- exportStarStatement: exportStar
61252
- })
61253
- ),
61313
+ generatePluginRuntimes({
61314
+ config,
61315
+ docs
61316
+ }),
61254
61317
  generatePluginIndex({ config, exportStatement: exportStar })
61255
61318
  ]);
61256
61319
  await generateGraphqlReturnTypes(config, docs);
61257
61320
  }
61258
- async function generatePluginRuntime({
61259
- config,
61260
- docs,
61261
- plugin: plugin2,
61262
- importStatement,
61263
- exportDefaultStatement,
61264
- exportStarStatement
61265
- }) {
61266
- if (houdini_mode.is_testing || !plugin2.includeRuntime) {
61267
- return;
61268
- }
61269
- const runtime_path = path_exports.join(
61270
- path_exports.dirname(plugin2.filepath),
61271
- typeof plugin2.includeRuntime === "string" ? plugin2.includeRuntime : plugin2.includeRuntime[config.module]
61272
- );
61273
- try {
61274
- await fs_exports.stat(runtime_path);
61275
- } catch {
61276
- throw new HoudiniError({
61277
- message: "Cannot find runtime to generate for " + plugin2.name,
61278
- description: "Maybe it was bundled?"
61279
- });
61280
- }
61281
- const pluginDir = config.pluginRuntimeDirectory(plugin2.name);
61282
- let transformMap = plugin2.transformRuntime ?? {};
61283
- if (transformMap && typeof transformMap === "function") {
61284
- transformMap = transformMap(docs, { config });
61285
- }
61286
- await fs_exports.mkdirp(pluginDir);
61287
- await fs_exports.recursiveCopy(
61288
- runtime_path,
61289
- pluginDir,
61290
- Object.fromEntries(
61291
- Object.entries(transformMap).map(([key, value]) => [
61292
- path_exports.join(runtime_path, key),
61293
- (content) => value({
61294
- config,
61295
- content,
61296
- importStatement,
61297
- exportDefaultStatement,
61298
- exportStarStatement
61299
- })
61300
- ])
61301
- )
61302
- );
61321
+ function moduleStatments(config) {
61322
+ const importStatement = config.module === "commonjs" ? importDefaultFrom : (where, as) => `import ${as} from '${where}'`;
61323
+ const exportDefaultStatement = config.module === "commonjs" ? exportDefault : (as) => `export default ${as}`;
61324
+ const exportStarStatement = config.module === "commonjs" ? exportStarFrom : (where) => `export * from '${where}'`;
61325
+ return {
61326
+ importStatement,
61327
+ exportDefaultStatement,
61328
+ exportStarStatement
61329
+ };
61303
61330
  }
61304
61331
 
61305
61332
  // src/codegen/generators/typescript/documentTypes.ts