(config, customProps)
| 26 | } |
| 27 | |
| 28 | export 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 = { |
nothing calls this directly
no test coverage detected
searching dependent graphs…