MCPcopy Create free account
hub / github.com/callstackincubator/polygen / generateModule

Method generateModule

packages/codegen/src/codegen.ts:184–212  ·  view source on GitHub ↗

* Generates all code for specified WebAssembly module. * * This includes generating the module exports bridge and the JavaScript * * @param module The module configuration to generate code for.

(
    module: ResolvedModule,
    options: PluginDispatchOptions = {}
  )

Source from the content-addressed store, hash-verified

182 * @param module The module configuration to generate code for.
183 */
184 async generateModule(
185 module: ResolvedModule,
186 options: PluginDispatchOptions = {}
187 ): Promise<[W2CGeneratedModule, W2CExternModule[]]> {
188 const [moduleContext, imports] = await this.context.addModule(module);
189 const generator = this.generator.forPath(
190 this.outputPathForModule(module, moduleContext.name)
191 );
192 await generateModuleExportsBridge(generator, moduleContext, {
193 forceGenerate: this.options.forceGenerate,
194 outputConfig: this.project.options.output,
195 moduleConfig: module,
196 });
197
198 const pluginContext: ModuleGeneratedContext = {
199 codegen: this,
200 moduleOutput: generator,
201 context: moduleContext,
202 module,
203 };
204
205 for (const plugin of this.plugins) {
206 await options.beforePluginDispatch?.(plugin);
207 await plugin.moduleGenerated?.(pluginContext);
208 await options.afterPluginDispatch?.(plugin);
209 }
210
211 return [moduleContext, imports];
212 }
213
214 /**
215 * Generates the imported module by creating necessary files and configurations in the specified output directory.

Callers 1

generateModuleFunction · 0.80

Calls 5

outputPathForModuleMethod · 0.95
addModuleMethod · 0.80
forPathMethod · 0.80
moduleGeneratedMethod · 0.65

Tested by

no test coverage detected