ngxs-labs / entity-state

⏱ WIP: Entity adapter
48 stars 12 forks source link

Error: Attempted to get members of a non-class: class Add - NGCC #280

Open marleypowell opened 3 years ago

marleypowell commented 3 years ago

There seems to be an issue with running ngcc postinstall

Angular version: 10.2.3

Ivy compiler enabled in tsconfig.json with:

"angularCompilerOptions": {
    "enableIvy": true
},

Error Reported:

Error: Error on worker #2: Error: Attempted to get members of a non-class: "class Add {
        /**
         * Generates an action that will add the given entities to the state.
         * The entities given by the payload will be added.
         * For certain ID strategies this might fail, if it provides an existing ID.
         * In all other cases it will overwrite the ID value in the entity with the calculated ID.
         * @param target The targeted state class
         * @param payload An entity or an array of entities to be added
         * @see CreateOrReplace#constructor
         */
        constructor(target, payload) {
            return generateActionObject(exports.EntityActionType.Add, target, payload);
        }
    }"
    at UmdReflectionHost.Esm2015ReflectionHost.getMembersOfClass (C:\Users\marley.powell\source\repos\exclaimercloud-ui\src\ExclaimerCloud.UI\ClientApp\node_modules\@angular\compiler-cli\ngcc\src\host\esm2015_host.js:178:23)
    at DelegatingReflectionHost.getMembersOfClass (C:\Users\marley.powell\source\repos\exclaimercloud-ui\src\ExclaimerCloud.UI\ClientApp\node_modules\@angular\compiler-cli\ngcc\src\host\delegating_host.js:103:34)     
    at C:\Users\marley.powell\source\repos\exclaimercloud-ui\src\ExclaimerCloud.UI\ClientApp\node_modules\@angular\compiler-cli\ngcc\src\analysis\module_with_providers_analyzer.js:77:32
    at Map.forEach (<anonymous>)
    at ModuleWithProvidersAnalyzer.getModuleWithProvidersFunctions (C:\Users\marley.powell\source\repos\exclaimercloud-ui\src\ExclaimerCloud.UI\ClientApp\node_modules\@angular\compiler-cli\ngcc\src\analysis\module_with_providers_analyzer.js:72:21)
    at C:\Users\marley.powell\source\repos\exclaimercloud-ui\src\ExclaimerCloud.UI\ClientApp\node_modules\@angular\compiler-cli\ngcc\src\analysis\module_with_providers_analyzer.js:39:33
    at Array.forEach (<anonymous>)
    at ModuleWithProvidersAnalyzer.analyzeProgram (C:\Users\marley.powell\source\repos\exclaimercloud-ui\src\ExclaimerCloud.UI\ClientApp\node_modules\@angular\compiler-cli\ngcc\src\analysis\module_with_providers_analyzer.js:38:23)
    at Transformer.analyzeProgram (C:\Users\marley.powell\source\repos\exclaimercloud-ui\src\ExclaimerCloud.UI\ClientApp\node_modules\@angular\compiler-cli\ngcc\src\packages\transformer.js:133:45)
    at Transformer.transform (C:\Users\marley.powell\source\repos\exclaimercloud-ui\src\ExclaimerCloud.UI\ClientApp\node_modules\@angular\compiler-cli\ngcc\src\packages\transformer.js:76:27)
    at ClusterMaster.onWorkerMessage (C:\Users\marley.powell\source\repos\exclaimercloud-ui\src\ExclaimerCloud.UI\ClientApp\node_modules\@angular\compiler-cli\ngcc\src\execution\cluster\master.js:195:27)
    at C:\Users\marley.powell\source\repos\exclaimercloud-ui\src\ExclaimerCloud.UI\ClientApp\node_modules\@angular\compiler-cli\ngcc\src\execution\cluster\master.js:55:95
    at ClusterMaster.<anonymous> (C:\Users\marley.powell\source\repos\exclaimercloud-ui\src\ExclaimerCloud.UI\ClientApp\node_modules\@angular\compiler-cli\ngcc\src\execution\cluster\master.js:293:57)
    at step (C:\Users\marley.powell\source\repos\exclaimercloud-ui\src\ExclaimerCloud.UI\ClientApp\node_modules\@angular\compiler-cli\node_modules\tslib\tslib.js:140:27)
    at Object.next (C:\Users\marley.powell\source\repos\exclaimercloud-ui\src\ExclaimerCloud.UI\ClientApp\node_modules\@angular\compiler-cli\node_modules\tslib\tslib.js:121:57)
    at C:\Users\marley.powell\source\repos\exclaimercloud-ui\src\ExclaimerCloud.UI\ClientApp\node_modules\@angular\compiler-cli\node_modules\tslib\tslib.js:114:75
    at new Promise (<anonymous>)
    at Object.__awaiter (C:\Users\marley.powell\source\repos\exclaimercloud-ui\src\ExclaimerCloud.UI\ClientApp\node_modules\@angular\compiler-cli\node_modules\tslib\tslib.js:110:16)
    at EventEmitter.<anonymous> (C:\Users\marley.powell\source\repos\exclaimercloud-ui\src\ExclaimerCloud.UI\ClientApp\node_modules\@angular\compiler-cli\ngcc\src\execution\cluster\master.js:287:32)
    at EventEmitter.emit (events.js:315:20)
marleypowell commented 3 years ago

Could this commit https://github.com/ngxs-labs/entity-state/commit/d6eb7d6ebccbf7f298fc3a628ee80ffadf9cc8d1 disabling ivy have caused issues?

JanMalch commented 3 years ago

IIRC disabling ivy for libraries is the recommended, if not required, way to do it. All the tests are fine so I'm not sure what's up with that. There's only one unanswered stackoverflow question with the same error message.

When does this error exactly occur? Simply when you build your application? Any unusual code that might cause this?

marleypowell commented 3 years ago

This only happens after running yarn install:

"postinstall": "ngcc --tsconfig ./tsconfig.app.json"

Other than that error in ngcc everything seems to be working fine...