Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(core): use ngDevMode to tree-shake error messages #38612

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion goldens/size-tracking/integration-payloads.json
Expand Up @@ -21,7 +21,7 @@
"master": {
"uncompressed": {
"runtime-es2015": 1485,
"main-es2015": 147573,
"main-es2015": 146989,
"polyfills-es2015": 36571
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/di/r3_injector.ts
Expand Up @@ -384,7 +384,7 @@ export class R3Injector {
let multiRecord = this.records.get(token);
if (multiRecord) {
// It has. Throw a nice error if
if (multiRecord.multi === undefined) {
if (ngDevMode && multiRecord.multi === undefined) {
throwMixedMultiProviderError();
}
} else {
Expand All @@ -396,15 +396,15 @@ export class R3Injector {
multiRecord.multi!.push(provider);
} else {
const existing = this.records.get(token);
if (existing && existing.multi !== undefined) {
if (ngDevMode && existing && existing.multi !== undefined) {
throwMixedMultiProviderError();
}
}
this.records.set(token, record);
}

private hydrate<T>(token: Type<T>|InjectionToken<T>, record: Record<T>): T {
if (record.value === CIRCULAR) {
if (ngDevMode && record.value === CIRCULAR) {
throwCyclicDependencyError(stringify(token));
} else if (record.value === NOT_YET) {
record.value = CIRCULAR;
Expand Down Expand Up @@ -511,7 +511,7 @@ export function providerToFactory(
const classRef = resolveForwardRef(
provider &&
((provider as StaticClassProvider | ClassProvider).useClass || provider.provide));
if (!classRef) {
if (ngDevMode && !classRef) {
throwInvalidProviderError(ngModuleType, providers, provider);
}
if (hasDeps(provider)) {
Expand Down
16 changes: 9 additions & 7 deletions packages/core/src/render3/instructions/shared.ts
Expand Up @@ -1375,6 +1375,7 @@ function findDirectiveDefMatches(
ngDevMode &&
assertNodeOfPossibleTypes(
tNode, [TNodeType.Element, TNodeType.ElementContainer, TNodeType.Container]);

const registry = tView.directiveRegistry;
let matches: any[]|null = null;
if (registry) {
Expand All @@ -1385,13 +1386,14 @@ function findDirectiveDefMatches(
diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, viewData), tView, def.type);

if (isComponentDef(def)) {
ngDevMode &&
assertNodeOfPossibleTypes(
tNode, [TNodeType.Element],
`"${tNode.tagName}" tags cannot be used as component hosts. ` +
`Please use a different tag to activate the ${
stringify(def.type)} component.`);
if (tNode.flags & TNodeFlags.isComponentHost) throwMultipleComponentError(tNode);
if (ngDevMode) {
assertNodeOfPossibleTypes(
tNode, [TNodeType.Element],
`"${tNode.tagName}" tags cannot be used as component hosts. ` +
`Please use a different tag to activate the ${stringify(def.type)} component.`);

if (tNode.flags & TNodeFlags.isComponentHost) throwMultipleComponentError(tNode);
}
markAsComponentHost(tView, tNode);
// The component is always stored first with directives after.
matches.unshift(def);
Expand Down
Expand Up @@ -350,9 +350,6 @@
{
"name": "setUpAttributes"
},
{
"name": "throwMultipleComponentError"
},
{
"name": "unwrapRNode"
},
Expand Down
6 changes: 0 additions & 6 deletions packages/core/test/bundling/forms/bundle.golden_symbols.json
Expand Up @@ -1586,12 +1586,6 @@
{
"name": "syncPendingControls"
},
{
"name": "throwMixedMultiProviderError"
},
{
"name": "throwMultipleComponentError"
},
{
"name": "toObservable"
},
Expand Down
Expand Up @@ -128,9 +128,6 @@
{
"name": "stringify"
},
{
"name": "throwMixedMultiProviderError"
},
{
"name": "ɵɵdefineInjectable"
},
Expand Down
3 changes: 0 additions & 3 deletions packages/core/test/bundling/todo/bundle.golden_symbols.json
Expand Up @@ -713,9 +713,6 @@
{
"name": "stringifyForError"
},
{
"name": "throwMultipleComponentError"
},
{
"name": "toTStylingRange"
},
Expand Down