BundleHelper
The BundleHelper offers functionality to work with the manifest content generated by the react-loadable-ssr-addon plugin.
BundleHelper is internal to @archibald/server and is not exported from any package entry point — it cannot be imported in project code. This page serves as an internal reference for framework development.
getFile
This method gets bundled files from the manifest content for one chunk.
const bundle = BundleHelper.getFile(PARAMETERS);
Parameters
| Name | Type | Description |
|---|---|---|
| manifest | Manifest | null | The manifest content generated by the react-loadable-ssr-addon plugin. |
| name | string | The file name to search for. |
createNonceAttribute
This method generates a decorator for usage with scrip tags.
const bundle = BundleHelper.createNonceAttribute(PARAMETERS);
Parameters
| Name | Type | Description |
|---|---|---|
| cspNonce | string | undefined | The nonce to use. |
getModules
This method gets bundled files from the manifest content for one chunk.
const bundle = BundleHelper.getModules(PARAMETERS);
Parameters
| Name | Type | Optional | Description |
|---|---|---|---|
| entry | string | The manifest content generated by the react-loadable-ssr-addon plugin. | |
| modules | Set<string> | undefined> | The file name to search for. | |
| entries | string[] | ✔️ | The file name to search for. |
filterOutExcludedFiles
This method returns filtered array of files.
const bundles = BundleHelper.filterOutExcludedFiles(PARAMETERS);
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| bundle | DefaultBundle | bundle configurations. | |
| excluded | ExcludedFiles | DefaultBundles | type of excluded files (js, css). |
getAdditionalBundles
This method receives a configuration file with all runtime/bundles names and any additional configurations/including any excluded files and returns the generated bundles if any excluded files are available or the additional initial object.
const bundles = BundleHelper.getAdditionalBundles(PARAMETERS);
Parameters
| Name | Type | Description | Default | |
|---|---|---|---|---|
| manifest | Manifest | The manifest content generated by the react-loadable-ssr-addon plugin. | ||
| additional | AdditionalContext | ✔️ | An array with the chunk names to search for. |
getBundles
This method gets bundled files from the manifest content for multiple chunks.
const bundles = BundleHelper.getBundles(PARAMETERS);
Parameters
| Name | Type | Optional | Description | Default |
|---|---|---|---|---|
| manifest | Manifest | null | The manifest content generated by the react-loadable-ssr-addon plugin. | ||
| chunks | string[] | null | An array with the chunk names to search for. | ||
| exclude | string[] | ✔️ | An array with the asset names that should be excluded from the result. | An empty array. |
buildFileChunkIndex
This method builds a reverse lookup from an emitted asset file name to the manifest chunk key (assets entry) that produced it, so a bundle can be resolved back to its chunk independently of the bundler's naming scheme.
const fileToChunk = BundleHelper.buildFileChunkIndex(PARAMETERS);
Parameters
| Name | Type | Description |
|---|---|---|
| manifest | Manifest | null | The asset manifest. |
buildCssChunkIndex
This method builds a lookup from an emitted CSS file name to every manifest chunk key that ships it. A chunk is only indexed when every stylesheet it ships is part of covered (the CSS whose content is inlined into the document).
const fileToChunks = BundleHelper.buildCssChunkIndex(PARAMETERS);
Parameters
| Name | Type | Description |
|---|---|---|
| manifest | Manifest | null | The asset manifest. |
| covered | Set<string> | CSS file names whose content is inlined into the document. |
getSplitOrigins
This method returns the origin arrays of every ${name}~N variant chunk that SplitChunks emitted for a named async chunk, so the caller can recover the assets (including CSS) that an exact-key lookup misses.
const origins = BundleHelper.getSplitOrigins(PARAMETERS);
Parameters
| Name | Type | Description |
|---|---|---|
| manifest | Manifest | The asset manifest. |
| chunk | string | Base chunk name to resolve variants for. |