MCPcopy
hub / github.com/single-spa/single-spa / mountParcel

Function mountParcel

src/parcels/mount-parcel.js:28–276  ·  view source on GitHub ↗
(config, customProps)

Source from the content-addressed store, hash-verified

26}
27
28export function mountParcel(config, customProps) {
29 const owningAppOrParcel = this;
30
31 // Validate inputs
32 if (!config || (typeof config !== "object" && typeof config !== "function")) {
33 throw Error(
34 formatErrorMessage(
35 2,
36 __DEV__ &&
37 "Cannot mount parcel without a config object or config loading function"
38 )
39 );
40 }
41
42 if (config.name && typeof config.name !== "string") {
43 throw Error(
44 formatErrorMessage(
45 3,
46 __DEV__ &&
47 `Parcel name must be a string, if provided. Was given ${typeof config.name}`,
48 typeof config.name
49 )
50 );
51 }
52
53 const id = parcelCount++;
54 let name = config.name || `parcel-${id}`;
55
56 if (typeof customProps !== "object") {
57 throw Error(
58 formatErrorMessage(
59 4,
60 __DEV__ &&
61 `Parcel ${name} has invalid customProps -- must be an object but was given ${typeof customProps}`,
62 name,
63 typeof customProps
64 )
65 );
66 }
67
68 if (!customProps.domElement) {
69 throw Error(
70 formatErrorMessage(
71 5,
72 __DEV__ &&
73 `Parcel ${name} cannot be mounted without a domElement provided as a prop`,
74 name
75 )
76 );
77 }
78
79 const passedConfigLoadingFunction = typeof config === "function";
80 const configLoadingFunction = passedConfigLoadingFunction
81 ? config
82 : () => Promise.resolve(config);
83
84 // Internal representation
85 const parcel = {

Callers

nothing calls this directly

Calls 10

formatErrorMessageFunction · 0.90
toNameFunction · 0.90
validLifecycleFnFunction · 0.90
flattenFnArrayFunction · 0.90
ensureValidAppTimeoutsFunction · 0.90
toUpdatePromiseFunction · 0.90
toBootstrapPromiseFunction · 0.90
toMountPromiseFunction · 0.90
configLoadingFunctionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…