mgechev / ngrev

Tool for reverse engineering of Angular applications
MIT License
1.58k stars 106 forks source link

Only apps based on Angular CLI supported? #27

Closed mlc-mlapis closed 6 years ago

mlc-mlapis commented 6 years ago

We have apps compiled by only ngc without any problems and then bundled using other tools like SystemJS Builder, Rollup, CC, ... and it looks that it is not possible to open such projects in ngrev ... selecting a correct tsconfig.json file ... the following error message appears:

image

mgechev commented 6 years ago

It's not only Angular CLI apps, if they are compatible with ngc, everything should work.

Would you share minimal project so I can reproduce the issue?

mlc-mlapis commented 6 years ago

OK, I'll prepare a simple demo. Let me 2 hours ...

mlc-mlapis commented 6 years ago

Hi Minko, here is the demo project: https://github.com/mlc-mlapis/demo-angular-modal-gallery

It was used to solve some things with custom libs under AOT mode ... and now I just upgraded it to Angular 5.1.2 and RxJS 5.5.6. I also tested it again, if it runs JIT and AOT without problems. But now a bit different error message appeared when I tried to open the project in ngrev ... see below ... I also chose tsconfig.aot.json (AOT) or tsconfig.json (JIT) but the error was still the same.

All necessary steps to run it are published in README.

image

mgechev commented 6 years ago

Oh, I see. Probably ngast uses your tsconfig.json file. Will experiment a bit later.

mgechev commented 6 years ago

@mlc-mlapis please try version 0.0.14, should be fixed.

Keep in mind that the UX is not great yet, so the window will freeze until your application gets loaded. This may take a while so please do not close the app if it's not responding.

mlc-mlapis commented 6 years ago

@mgechev ... thanks for updated version 0.0.14, I tried it but the problem still pertains ... Cannot find the root module of your project.

mgechev commented 6 years ago

Very interesting...Do you have at least 1 module with at least 1 bootstrap component?

mlc-mlapis commented 6 years ago

... sure, you can see in the repository ... the main module is:

@NgModule({
    declarations: [
        AppComponent
    ],
    imports: [
        BrowserModule,
        ReactiveFormsModule,
        SliderModule,
        ModalGalleryModule.forRoot()
    ],
    providers: [],
    bootstrap: [AppComponent]
})
mgechev commented 6 years ago

@mlc-mlapis oh, sorry. Forgot about the link. Let me try to reproduce it :-).

mgechev commented 6 years ago
screen shot 2017-12-25 at 2 04 26 am

Use this tsconfig.json:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "declaration": false,
    "removeComments": true,
    "noLib": false,
    "lib": ["es2016", "dom"],
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "sourceMap": true,
    "pretty": true,
    "allowUnreachableCode": false,
    "allowUnusedLabels": false,
    "noImplicitAny": true,
    "noImplicitReturns": true,
    "noImplicitUseStrict": false,
    "noFallthroughCasesInSwitch": true,
    "allowSyntheticDefaultImports": true,
    "typeRoots": ["../../node_modules/@types", "../../node_modules"],
    "types": ["node", "jasmine", "systemjs"]
  },
  "compileOnSave": false,
  "exclude": ["app/main-prod.ts"]
}
mlc-mlapis commented 6 years ago

@mgechev ... hmm, tried many combinations ... and there are my final observations:

  1. If tsconfig.json contains property "include": [...] in "compilerOptions" with any content, then opening a project ends with an error message:

image

  1. If tsconfig.json contains property "exclude": [...] in "compilerOptions" with any content, then opening a project ends with an error message (and doesn't contain property "include": [...]):

image

  1. If tsconfig.json contains property "outDir": "...", in "compilerOptions" with any content, then opening a project ends with an error message (and doesn't contain property"exclude": [...] ):

image

The only workable actual setting of tsconfig.json is completely without parts "include": [...] and "exclude": [...] and "outDir": "...",. I don't have any explanations for above combinations and it also seems that there are no reasons for such limitations .. when using of all 3 properties mentioned above is correct.

mgechev commented 6 years ago

Thanks for the observations! I can embed this in the tool. Until then, we can use this issue as reference.

Happy holidays! :-)