Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AOT build doesn't work when I compile a module outside of my project #5998

Closed
wKoza opened this issue Apr 18, 2017 · 15 comments
Closed

AOT build doesn't work when I compile a module outside of my project #5998

wKoza opened this issue Apr 18, 2017 · 15 comments
Labels
effort2: medium (days) needs: investigation Requires some digging to determine if action is needed P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity3: broken

Comments

@wKoza
Copy link
Contributor

wKoza commented Apr 18, 2017

Hi, I'm trying to migrate the ng-bootstrap test application to Angular CLI. Unfortunately, the AOT compilation does not work with ng build --aot. Here is my project : https://github.com/wKoza/ng-bootstrap/tree/migration_to_angular_cli/demo

However, when I run the command : ./node_modules/.bin/ngc -p src/tsconfig.app.json, I can compile my code.

Is it possible to do this with the CLI ?

@cenkentimist
Copy link

are you getting the You have to be inside an Angular CLI project in order to use the build command.
error? because that's what it says on the tin. Angular CLI manages a number of things automatically. I would start a new project (ng new) and paste in code instead of trying to convert an old project wholesale. Perhaps someone else has a better idea though.

@wKoza
Copy link
Contributor Author

wKoza commented Apr 18, 2017

Yes, demo is a new project (I have pasted the code inside). This is the start of the log :

10% building modules 6/10 modules 4 active ...ode_modules/style-loader/addStyles.jsTemplate parse warnings:
bootstrap/src/accordion/accordion.ts.NgbAccordion.html@2:4 Hash: c1bdb18bfd1b85b747e9 Time: 45102ms
chunk {0} main.bundle.js, main.bundle.js.map (main) 2.25 MB {3} [initial] [rendered]
chunk {1} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 167 kB {4} [initial] [rendered]
chunk {2} styles.bundle.js, styles.bundle.js.map (styles) 203 kB {4} [initial] [rendered]
chunk {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 1.41 MB [initial] [rendered]
chunk {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]
ERROR` in /Users/william/WebstormProjects/ng-bootstrap/demo/src/$$_gendir/src/accordion/accordion.ngfactory.ts (1,1): Cannot find module './accordion'.
/Users/william/WebstormProjects/ng-bootstrap/demo/src/$$_gendir/src/accordion/accordion.ngfactory.ts (1,1): Cannot find module './accordion-config'.
ERROR in /Users/william/WebstormProjects/ng-bootstrap/demo/src/$$_gendir/src/accordion/accordion.module.ngfactory.ts (1,1): Cannot find module './accordion.module'.

...

@cenkentimist
Copy link

cenkentimist commented Apr 18, 2017

@wKoza ok I see what happened. When you generate a component with npm run ng generate component 'widget' it automatically adds the import to the top of app.module.ts and the class to the declarations list in there. You pasted the classes in though so you need to add that manually.

specifically the import here should be import {NgbdAccordion} from "./components/accordion/accordion.component" and the adding the declaration to

@NgModule({
  declarations: [
    AppComponent,
    DefaultComponent,
    GettingStarted,
    NgbdAccordion
  ],
  imports: [
    BrowserModule,
    routing,
    NgbModule.forRoot(),
    NgbdDemoModule,
    NgbdSharedModule
  ],
  bootstrap: [AppComponent]
})

@wKoza
Copy link
Contributor Author

wKoza commented Apr 19, 2017

@cenkentimist, NgbdAccordion is imported by NgbdDemoModule. Without --aot , the project builds without any problems, ng serveworks also. You can checkout my project if you want to see in more detail.

@cenkentimist
Copy link

cenkentimist commented Apr 19, 2017

@wKoza Actually did try this. It didn't work at all for me(don't remember the exact errors). I don't have a global install of angular and that wasn't the error I got when I installed it in and ran it. The project is also missing the scripts generated by the default angular project. IE npm run -- ng foo and npm start did not work. what do you get from ng --version?

@wKoza
Copy link
Contributor Author

wKoza commented Apr 19, 2017

ng -v

@angular/cli: 1.0.0
node: 6.9.5
os: darwin x64
@angular/common: 4.0.2
@angular/compiler: 4.0.2
@angular/core: 4.0.2
@angular/forms: 4.0.2
@angular/http: 4.0.2
@angular/platform-browser: 4.0.2
@angular/platform-browser-dynamic: 4.0.2
@angular/router: 4.0.2
@angular/cli: 1.0.0
@angular/compiler-cli: 4.0.2

The project is in the demofolder, on the branch migration_to_angular_cliof my repo

@kylecordes
Copy link

Same issue as #5986 ?

@wKoza
Copy link
Contributor Author

wKoza commented Apr 20, 2017

Yes , it's possible @kylecordes .

@elclanrs
Copy link

I think this may be the same issue I reported here #5990.

@sumitarora sumitarora changed the title OAT build doesn't work when I compile a module outside of my project AOT build doesn't work when I compile a module outside of my project Apr 24, 2017
@filipesilva filipesilva added effort2: medium (days) needs: investigation Requires some digging to determine if action is needed P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity3: broken labels May 5, 2017
@valorkin
Copy link
Contributor

valorkin commented Jun 1, 2017

@wKoza works fine for ngx-bootstrap, but I am linking lib src into node_modules

@wKoza
Copy link
Contributor Author

wKoza commented Jun 22, 2017

yes @valorkin , with this strategy, it's work but it's not what I want.

@mgechev
Copy link
Member

mgechev commented Dec 18, 2018

@wKoza can you still reproduce this issue?

@wKoza
Copy link
Contributor Author

wKoza commented Dec 18, 2018

Hi @mgechev, I don't think so. Angular CLI have grown since ;) We can close it.

@wKoza wKoza closed this as completed Dec 18, 2018
@mgechev
Copy link
Member

mgechev commented Dec 21, 2018

Thanks for the response!

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
effort2: medium (days) needs: investigation Requires some digging to determine if action is needed P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity3: broken
Projects
None yet
Development

No branches or pull requests

8 participants