{"record":{"id":"b5c15b171807dfbc","repo":"bettercap/bettercap","slug":"component-stringify-type-is-not-resolved","errorCode":null,"errorMessage":"Component '${stringify(type)}' is not resolved:\n - templateUrl: ${templateUrl}\n - styleUrls: ${styleUrls}\nDid you run and wait for 'resolveComponentResources()'?","messagePattern":"Component '(.+?)' is not resolved:\n - templateUrl: (.+?)\n - styleUrls: (.+?)\nDid you run and wait for 'resolveComponentResources\\(\\)'\\?","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"modules/ui/ui/vendor.js","lineNumber":55331,"sourceCode":" */\nfunction compileComponent(type, metadata) {\n    var ngComponentDef = null;\n    // Metadata may have resources which need to be resolved.\n    maybeQueueResolutionOfComponentResources(metadata);\n    Object.defineProperty(type, NG_COMPONENT_DEF, {\n        get: function () {\n            var compiler = getCompilerFacade();\n            if (ngComponentDef === null) {\n                if (componentNeedsResolution(metadata)) {\n                    var error = [\"Component '\" + stringify(type) + \"' is not resolved:\"];\n                    if (metadata.templateUrl) {\n                        error.push(\" - templateUrl: \" + stringify(metadata.templateUrl));\n                    }\n                    if (metadata.styleUrls && metadata.styleUrls.length) {\n                        error.push(\" - styleUrls: \" + JSON.stringify(metadata.styleUrls));\n                    }\n                    error.push(\"Did you run and wait for 'resolveComponentResources()'?\");\n                    throw new Error(error.join('\\n'));\n                }\n                var meta = Object(tslib__WEBPACK_IMPORTED_MODULE_0__[\"__assign\"])({}, directiveMetadata(type, metadata), { template: metadata.template || '', preserveWhitespaces: metadata.preserveWhitespaces || false, styles: metadata.styles || EMPTY_ARRAY, animations: metadata.animations, viewQueries: extractQueriesMetadata(getReflect().propMetadata(type), isViewQuery), directives: new Map(), pipes: new Map(), encapsulation: metadata.encapsulation || ViewEncapsulation.Emulated, viewProviders: metadata.viewProviders || null });\n                ngComponentDef = compiler.compileComponent(angularCoreEnv, \"ng://\" + stringify(type) + \"/template.html\", meta);\n                // If component compilation is async, then the @NgModule annotation which declares the\n                // component may execute and set an ngSelectorScope property on the component type. This\n                // allows the component to patch itself with directiveDefs from the module after it\n                // finishes compiling.\n                if (hasSelectorScope(type)) {\n                    var scopes = transitiveScopesFor(type.ngSelectorScope);\n                    patchComponentDefWithScope(ngComponentDef, scopes);\n                }\n            }\n            return ngComponentDef;\n        },\n        // Make the property configurable in dev mode to allow overriding in tests\n        configurable: !!ngDevMode,\n    });\n}","sourceCodeStart":55313,"sourceCodeEnd":55349,"githubUrl":"https://github.com/bettercap/bettercap/blob/8eca2820f3c41d2004434ed5a291d87462caeeb7/modules/ui/ui/vendor.js#L55313-L55349","documentation":"Thrown when a component's `ngComponentDef` is compiled (JIT) but its metadata still contains unresolved external resources: a `templateUrl` or `styleUrls` that were never fetched. Angular defers resource loading to `resolveComponentResources()`, which must be called and awaited before compiling components that reference external template/style files.","triggerScenarios":"Using @Component with `templateUrl` or `styleUrls` in a JIT environment without awaiting the promise returned by `resolveComponentResources()` (typically from '@angular/compiler' or a custom JIT bootstrap); triggering ngComponentDef access before resource resolution finished.","commonSituations":"JIT bootstrap in tests or JIT-compiled apps (no AOT), custom loaders (e.g. dynamic component compilation in plugins) that skip resource resolution, TestBed setups, upgrading Angular where bootstrap helpers previously handled this implicitly.","solutions":["Call and await `resolveComponentResources(urlResolver)` before bootstrapping/compiling components that use templateUrl/styleUrls.","Prefer inline `template`/`styles` in JIT/dynamic-compilation scenarios to avoid resource loading entirely.","In tests, ensure TestBed initialization completes (await TestBed.compileComponents()) before creating components.","Ensure components are only rendered after the bootstrap promise resolves, not before."],"exampleFix":"// before\nconst cmp = createComponent(MyCmp);\n// after\nimport { resolveComponentResources } from '@angular/compiler';\nawait resolveComponentResources(async url => (await fetch(url)).text());\nconst cmp = createComponent(MyCmp);","handlingStrategy":"validation","validationCode":"if (cmp.decorators?.some(d => d.type === Component) &&\n    (meta.templateUrl || meta.styleUrls?.length) &&\n    !resourcesResolved) {\n  throw new Error('Call and await resolveComponentResources() first');\n}","typeGuard":"function isResolvedComponentMeta(m: { template?: string; templateUrl?: string }): m is { template: string; templateUrl?: undefined } {\n  return typeof m.template === 'string' || m.templateUrl === undefined;\n}","tryCatchPattern":"try {\n  const def = type.ngComponentDef;\n} catch (e) {\n  if (e.message.includes(\"resolveComponentResources()\")) {\n    await resolveComponentResources(url => fetch(url).then(r => r.text()));\n    // retry access after resolution\n  } else { throw e; }\n}","preventionTips":["Await resolveComponentResources() before any JIT component compilation.","Await TestBed.compileComponents() in JIT tests.","Prefer inline template/styles for dynamically compiled components."],"tags":["angular","jit","component","templateurl","async"],"backgroundTag":"component-resources-not-resolved","analyzedSha":"8eca2820f3c41d2004434ed5a291d87462caeeb7","analyzedAt":"2026-09-02T12:49:00.712Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T16:17:10.729Z"}