From cef15f244a4dfa2f35349a75782cbd7feb24df00 Mon Sep 17 00:00:00 2001 From: Oleksandr Danchuk Date: Thu, 3 Oct 2024 12:08:01 -0400 Subject: [PATCH 1/2] fix(compiler): multipe decorators selection issue happen when more than one decorator present in the class (order matters) for example when @Component({}) @Auto class MyComponent {} --- src/modules/compiler/src/compiler.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/compiler/src/compiler.ts b/src/modules/compiler/src/compiler.ts index 35ad531..f6c894b 100644 --- a/src/modules/compiler/src/compiler.ts +++ b/src/modules/compiler/src/compiler.ts @@ -99,7 +99,14 @@ export class Compiler { let visitNode = (visitedNode, index) => { let name = this.getSymboleName(node); let deps: Dependencies = {}; - let metadata = decorators[decorators.length - 1]; + // could be more than one decorator. let's filter to one we need + let metadata; + if (decorators.length === 1) { + metadata = decorators[0] + } else { + const filteredDecorators = decorators.filter(d => /(NgModule|Component)/.test(node.expression?.expression?.text)); + metadata = filteredDecorators[filteredDecorators.length - 1]; + } let props = this.findProps(visitedNode); if (this.isModule(metadata)) { From 767c3b14dd6965579371d03baf0fd76ad128fc31 Mon Sep 17 00:00:00 2001 From: Oleksandr Danchuk Date: Thu, 3 Oct 2024 12:10:02 -0400 Subject: [PATCH 2/2] fix(all): fix npm run tests run fails because other modules doesn't have xtest script command --- src/modules/compiler/package.json | 3 ++- src/modules/core/package.json | 1 + src/modules/transformer/package.json | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/compiler/package.json b/src/modules/compiler/package.json index effe445..ffe9fc7 100644 --- a/src/modules/compiler/package.json +++ b/src/modules/compiler/package.json @@ -6,7 +6,8 @@ "scripts": { "compile:src": "tsc --newLine LF", "prexpublish": "npm run compile:src", - "deploy": "npm run compile:src && npm xpublish" + "deploy": "npm run compile:src && npm xpublish", + "xtest": "echo 'no xtests'" }, "homepage": "https://github.com/compodoc/ngd-compiler", "bugs": "https://github.com/compodoc/ngd-compiler/issues", diff --git a/src/modules/core/package.json b/src/modules/core/package.json index a24dadb..e458c5e 100644 --- a/src/modules/core/package.json +++ b/src/modules/core/package.json @@ -6,6 +6,7 @@ "scripts": { "compile:src": "tsc --newLine LF", "prexpublish": "npm run compile:src", + "xtest": "echo 'no xtests'", "deploy": "npm run compile:src && npm xpublish" }, "homepage": "https://github.com/compodoc/ngd", diff --git a/src/modules/transformer/package.json b/src/modules/transformer/package.json index f8e1380..97c91a4 100644 --- a/src/modules/transformer/package.json +++ b/src/modules/transformer/package.json @@ -6,6 +6,7 @@ "scripts": { "compile:src": "tsc --newLine LF", "prexpublish": "npm run compile:src", + "xtest": "echo 'no xtests'", "deploy": "npm run compile:src && npm xpublish" }, "homepage": "https://github.com/compodoc/ngd",