MCPcopy
hub / github.com/vuejs/core / load

Function load

packages/runtime-core/src/apiAsyncComponent.ts:76–118  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

74 }
75
76 const load = (): Promise<ConcreteComponent> => {
77 let thisRequest: Promise<ConcreteComponent>
78 return (
79 pendingRequest ||
80 (thisRequest = pendingRequest =
81 loader()
82 .catch(err => {
83 err = err instanceof Error ? err : new Error(String(err))
84 if (userOnError) {
85 return new Promise((resolve, reject) => {
86 const userRetry = () => resolve(retry())
87 const userFail = () => reject(err)
88 userOnError(err, userRetry, userFail, retries + 1)
89 })
90 } else {
91 throw err
92 }
93 })
94 .then((comp: any) => {
95 if (thisRequest !== pendingRequest && pendingRequest) {
96 return pendingRequest
97 }
98 if (__DEV__ && !comp) {
99 warn(
100 `Async component loader resolved to undefined. ` +
101 `If you are using retry(), make sure to return its return value.`,
102 )
103 }
104 // interop module default
105 if (
106 comp &&
107 (comp.__esModule || comp[Symbol.toStringTag] === 'Module')
108 ) {
109 comp = comp.default
110 }
111 if (__DEV__ && comp && !isObject(comp) && !isFunction(comp)) {
112 throw new Error(`Invalid async component load result: ${comp}`)
113 }
114 resolvedComp = comp
115 return comp
116 }))
117 )
118 }
119
120 return defineComponent({
121 name: 'AsyncComponentWrapper',

Callers 6

retryFunction · 0.70
__asyncHydrateFunction · 0.70
setupFunction · 0.70
scssFunction · 0.50
lessFunction · 0.50
stylFunction · 0.50

Calls 4

warnFunction · 0.90
isObjectFunction · 0.90
isFunctionFunction · 0.90
StringInterface · 0.85

Tested by

no test coverage detected