Skip to main content

BundleHelper

The BundleHelper offers functionality to work with the manifest content generated by the react-loadable-ssr-addon plugin.

Internal API

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

NameTypeDescription
manifestManifest | nullThe manifest content generated by the react-loadable-ssr-addon plugin.
namestringThe file name to search for.

createNonceAttribute

This method generates a decorator for usage with scrip tags.

const bundle = BundleHelper.createNonceAttribute(PARAMETERS);

Parameters

NameTypeDescription
cspNoncestring | undefinedThe nonce to use.

getModules

This method gets bundled files from the manifest content for one chunk.

const bundle = BundleHelper.getModules(PARAMETERS);

Parameters

NameTypeOptionalDescription
entrystringThe manifest content generated by the react-loadable-ssr-addon plugin.
modulesSet<string&#62; &#124; undefined>The file name to search for.
entriesstring[]✔️The file name to search for.

filterOutExcludedFiles

This method returns filtered array of files.

const bundles = BundleHelper.filterOutExcludedFiles(PARAMETERS);

Parameters

NameTypeDescriptionDefault
bundleDefaultBundlebundle configurations.
excludedExcludedFiles | DefaultBundlestype 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

NameTypeDescriptionDefault
manifestManifestThe manifest content generated by the react-loadable-ssr-addon plugin.
additionalAdditionalContext✔️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

NameTypeOptionalDescriptionDefault
manifestManifest | nullThe manifest content generated by the react-loadable-ssr-addon plugin.
chunksstring[] | nullAn array with the chunk names to search for.
excludestring[]✔️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

NameTypeDescription
manifestManifest | nullThe 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

NameTypeDescription
manifestManifest | nullThe asset manifest.
coveredSet<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

NameTypeDescription
manifestManifestThe asset manifest.
chunkstringBase chunk name to resolve variants for.