8000 refactor(compiler-cli): implement transform to determine debugName fr… · angular/angular@05a8db2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 05a8db2

Browse files
refactor(compiler-cli): implement transform to determine debugName from signal functions
Implements a compiler transform that attempts to statically analyze variable names and apply them to usages of signal functions like signal, computed, effect, etc.
1 parent e62fb35 commit 05a8db2

File tree

12 files changed

+2500
-47
lines changed

12 files changed

+2500
-47
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"@babel/generator": "7.27.0",
6363
"@bazel/concatjs": "5.8.1",
6464
"@bazel/esbuild": "5.8.1",
65+
"esbuild": "0.21.4",
6566
"@bazel/jasmine": "5.8.1",
6667
"@bazel/protractor": "5.8.1",
6768
"@bazel/rollup": "5.8.1",

packages/compiler-cli/src/ngtsc/core/src/compiler.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ import {
107107
DtsTransformRegistry,
108108
ivyTransformFactory,
109109
TraitCompiler,
110+
signalMetadataTransform,
110111
} from '../../transform';
111112
import {TemplateTypeCheckerImpl} from '../../typecheck';
112113
import {OptimizeFor, TemplateTypeChecker, TypeCheckingConfig} from '../../typecheck/api';
@@ -819,7 +820,7 @@ export class NgCompiler {
819820

820821
const defaultImportTracker = new DefaultImportTracker();
821822

822-
const before = [
823+
const before: ts.TransformerFactory<ts.SourceFile>[] = [
823824
ivyTransformFactory(
824825
compilation.traitCompiler,
825826
compilation.reflector,
@@ -859,7 +860,7 @@ export class NgCompiler {
859860
},
860861
)(ctx);
861862

862-
return (sourceFile) => {
863+
return (sourceFile: ts.SourceFile) => {
863864
if (!sourceFilesWithJit.has(sourceFile.fileName)) {
864865
return sourceFile;
865866
}
@@ -868,6 +869,9 @@ export class NgCompiler {
868869
});
869870
}
870871

872+
// Typescript transformer to add debugName metadata to signal functions.
873+
before.push(signalMetadataTransform(this.inputProgram));
874+
871875
const afterDeclarations: ts.TransformerFactory<ts.SourceFile>[] = [];
872876

873877
// In local compilation mode we don't make use of .d.ts files for Angular compilation, so their

packages/compiler-cli/src/ngtsc/transform/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ export {
2323
TraitState,
2424
} from './src/trait';
2525
export {ivyTransformFactory} from './src/transform';
26+
export {signalMetadataTransform} from './src/implicit_signal_debug_name_transform';

0 commit comments

Comments
 (0)
0