@hyperfrontend/builder/bundle/externalsexternals
Externals resolution primitives: package.json scanning and globals validation for IIFE / UMD bundles.
resolveExternals({ packageJsonPath, additional, isWorkspacePackage, bundleWorkspaceDeps }) reads the project's package.json and combines its dependencies, peerDependencies, and the caller-supplied additional list into a sorted, de-duplicated external list — stripping workspace-internal entries when bundleWorkspaceDeps is true. validateExternalsConfig(external, globals) fails fast when an IIFE / UMD bundle declares an external package without a corresponding global variable name.
API Reference
ƒ Functions
Resolves the external package list for a single bundle.
The output combines:
The output combines:
- top-level
dependenciesfrom the project'spackage.json peerDependencies(always external regardless ofbundleWorkspaceDeps)- the caller-supplied
additionallist
bundleWorkspaceDeps is true and a workspace predicate is supplied, packages matching the predicate are stripped from dependencies and additional so they get inlined by the bundler. Peer dependencies are always preserved.Parameters
| Name | Type | Description |
|---|---|---|
§options | ResolveExternalsOptions | Inputs controlling the resolution. |
Returns
string[]Sorted, de-duplicated list of external package names.
Example
Resolving externals while inlining workspace deps
const external = resolveExternals({
packageJsonPath: '/abs/libs/foo/package.json',
isWorkspacePackage: (n) => n.startsWith('@hyperfrontend/'),
bundleWorkspaceDeps: true,
})Verifies that every external dependency declared for an IIFE / UMD bundle has a corresponding entry in the supplied
Throws an aggregated error listing the missing entries when the configuration is incomplete; resolves silently otherwise.
globals map. Throws an aggregated error listing the missing entries when the configuration is incomplete; resolves silently otherwise.
Parameters
Example
Failing fast when a globals mapping is missing
validateExternalsConfig(['react'], { 'react-dom': 'ReactDOM' })
// => throws: Missing globals mapping for external dependencies: react◈ Interfaces
Inputs to
resolveExternals.Properties
§
additional?:string[]— Additional package names to mark external regardless of the package.json contents.
§
bundledDeps?:string[]— Third-party package names being bundled into
_dependencies/. When non-empty, these are removed from the resolved external list so their imports are routed to the bundled copies instead of left external.§
bundleWorkspaceDeps?:boolean— When
true, workspace packages are inlined and stripped from the resolved external list.§
isWorkspacePackage?:IsWorkspacePackagePredicate— Predicate identifying workspace-internal packages. Defaults to "everything is external".
§
workspaceBundledDepNames?:string[]— Workspace package names being bundled into
_dependencies/. When non-empty, these are removed from the resolved external list so their imports are routed to the bundled copies instead of left external.