Library build (partial compile) produces error meta.deps.map is not a function in consumer-application
Which @angular/* package(s) are the source of the bug?
compiler
Is this a regression?
No
Description
Creating an abstract super-class (used as a super-class in an application which is a consumer of the libary) with a @directive decorator and an interface as a constructor-parameter (without @Inject and injection-Token) creates code, which leads to a compiler-crash with "meta.deps.map is not function", when compiling the library consumer.
I know, that this is a mistake in the library (interfaces as constructor-parameters don't work) but the compiler does not complain when compiling the library and crashes when compiling the consumer of the library.
.
The crash when compiling the library consumer occurrs in @angular/compiler/src/jit_compiler_facade.js at line 187 (angular version 12.2.2):
CompilerFacadeImpl.prototype.compileFactoryDeclaration = function (angularCoreEnv, sourceMapUrl, meta) {
var factoryRes = r3_factory_1.compileFactoryFunction({
name: meta.type.name,
type: util_1.wrapReference(meta.type),
internalType: new output_ast_1.WrappedNodeExpr(meta.type),
typeArgumentCount: 0,
deps: meta.deps && meta.deps.map(convertR3DeclareDependencyMetadata), // <== meta.deps.map is a string "invalid" here
target: meta.target,
});
The generated java-script code looks like this:
dist/scope/test/bundles/scope-test.umd.js:
...
AbstractClass.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: AbstractClass, deps: "invalid", target: i0__namespace.ɵɵFactoryTarget.Directive });
...
dist/scope/test/esm2015/lib/abstract-class.js:
...
AbstractClass.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: AbstractClass, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
...
dist/scope/test/fesm2015/lib/scope-test.js:
...
AbstractClass.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: AbstractClass, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
...
Please provide a link to a minimal reproduction of the bug
See attached zip-file: depsInvalid.zip
Please provide the exception or error you saw
Generating browser application bundles (phase: setup)...An unhandled exception occurred: meta.deps.map is not a function
See "C:\Users\DIETER~1.PRI\AppData\Local\Temp\ng-aokt23\angular-errors.log" for further details.
-------------------------------
Content of angular-errors.log:
-------------------------------
[error] TypeError: meta.deps.map is not a function
at CompilerFacadeImpl.compileFactoryDeclaration (E:\projects\commons\data\git-repos\VGWJERRY\jerry\client\node_modules\@angular\compiler\src\jit_compiler_facade.js:188:46)
at Object.ɵɵngDeclareFactory (E:\projects\commons\data\git-repos\VGWJERRY\jerry\client\node_modules\@angular\core\bundles\core.umd.js:33941:25)
at E:\projects\commons\data\git-repos\VGWJERRY\jerry\client\node_modules\@spike\core\bundles\spike-core.umd.js:33884:51
at E:\projects\commons\data\git-repos\VGWJERRY\jerry\client\node_modules\@spike\core\bundles\spike-core.umd.js:2:68
at Object.<anonymous> (E:\projects\commons\data\git-repos\VGWJERRY\jerry\client\node_modules\@spike\core\bundles\spike-core.umd.js:5:2)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:14)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:92:18)
at E:\projects\commons\data\git-repos\VGWJERRY\jerry\client\node_modules\@jerry\core\bundles\jerry-core.umd.js:2:200
at Object.<anonymous> (E:\projects\commons\data\git-repos\VGWJERRY\jerry\client\node_modules\@jerry\core\bundles\jerry-core.umd.js:5:2)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
Please provide the environment you discovered this bug in
Angular CLI: 12.2.2
Node: 14.17.3
Package Manager: npm 6.14.13
OS: win32 x64
Angular: 12.2.2
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1202.2
@angular-devkit/build-angular 12.2.2
@angular-devkit/core 12.2.2
@angular-devkit/schematics 12.2.2
@schematics/angular 12.2.2
rxjs 6.6.7
typescript 4.3.5
Anything else?
No response