# Generation

A container can either be `explicitly` or `implicitly` generated.

The only way to `explicitly` generate a container is to use the `create-container` command. On the other hand, a container will be `implicitly` generated whenever running some `cauldron` sub-commands such as `regen-container` or `add miniapps` *(and many other ones)*.

To be generated, what the container mostly need is a non empty set of miniapp(s) that may come from different locations *(local directory, npm, git repository)*.

Container generation goes through multiple steps in sequence, starting with composite generation, as illustrated below

![](/files/-MfJPBZ-9n9YgFJXMVPj)

## Composite Generation

The first step of container generation is actually to generate a composite project. Composite and composite generation is covered in a dedicated section of the documentation, but in a nutshell, the composite is a just a JavaScript project with miniapps as dependencies, and a single top level entry point that is just importing each of the miniapps. Electrode Native runs metro bundler on this composite project to create the final JS bundle.

## Compatibility Checks

After generating the composite project, Electrode Native will identify all native depencies *(APIs and native modules)* packages present in the composite and will perform compatibility checks to make sure that there is only one clear identified unique version of each native dependency. For example, if MiniApp A and B both use react-native-maps native module but with a different version, this step would fail.

## Setting up container template

This step is actually relatively straightforward. It just takes care of copying the container project template to the directory where the container will be generated *(output directory)*.

## Injecting native dependencies

This step is responsible for injecting all the native code into the container. The process is a bit different for Android compared to iOS. For Android, all the APIs, APIs native implementations and native modules code are injected into the container. This is because all of these components are not published to Maven, so can't be retrieved as regular maven dependencies in the build.gradle of the container. This is also the reason why a plugin configuration is needed in manifest for native modules, to let Electrode Native where the code of the nativem module is in, and what exactly to inject in the container. For iOS, thanks to CocoaPods injection *(starting with RN 61)*, we don't have to manually inject the code of native modules in the iOS container, but rather rely on CocoaPods, very similar to the auto linking mechanism used by React Native. This is also why iOS plugin configuration in manifest is relatively minimal, as the podspec of the native module takes the role of the plugin configuration.

## JS Bundling

Finally, Electrode Native will run Facebook Metro Bundler on the composite project, to generate the final JS bundle. The bundle output location passed to metro will be the correct target location in the container. The assets output path will also point to the right directory in the container, so that assets are properly injected in the container.

Once this process is completed, the generated container project will be accessible in the output directory. It can then be imported as-is in the client application, or can be further processed using container `transformers` and/or published using container `publishers`.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://native.electrode.io/reference/container/container-generation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
