Open TheNemus opened 4 years ago
Hi there! I have the same issue and would be grateful if you help.
is there any update on this @nitayneeman
Hi,
I have the same issue. I created a ng-add schematics for an NG8 lib and whenever I call addModuleImportToRootModule
, it doesn't change my appModule
I did some digging and found the problem here
export function addModuleImportToModule(host: Tree, modulePath: string, moduleName: string, src: string) {
const moduleSource = getSourceFile(host, modulePath);
if (!moduleSource) {
throw new SchematicsException(`Module not found: ${modulePath}`);
}
//this is fine
const changes = addImportToModule(<any>moduleSource, modulePath, moduleName, src);
const recorder = host.beginUpdate(modulePath);
changes.forEach(change => {
if (change instanceof InsertChange) { // <= this always returns false
recorder.insertLeft(change.pos, change.toAdd);
}
});
host.commitUpdate(recorder);
}
the changes array contains the correct changes (the file import and the import in the ngModule) but this check : if (change instanceof InsertChange)
always returns false. If I remove this check, it works as expected.
Either cast it explicitly or use angular/schematics not from utilities.
Read it here
I made it work using @schematics/angular, but it's still a bug IMO. I cannot cast it myself as the code that is faulty is in the schematics-utilities library.
KO in 2.0.0 and 2.0.1 OK in 1.1.3
Here is my rule factory function
Here is what I got in console
But my app.module.ts is absolutely the same as before.
I could downgrade to 1.1.3 but I need to set configuration for my modules, but then I got this issue:
https://github.com/nitayneeman/schematics-utilities/issues/7
What am I supposed to do?
P.S. Where I can find a comprehensive list of the API your package expoes? Thank you?