Skip to content

Using angular-cli to generate a components in different source folders. #3715

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

Closed
bfwg opened this issue Dec 23, 2016 · 3 comments
Closed

Using angular-cli to generate a components in different source folders. #3715

bfwg opened this issue Dec 23, 2016 · 3 comments

Comments

@bfwg
Copy link

bfwg commented Dec 23, 2016

MacOS El Capitan
angular-cli: 1.0.0-beta.21
node: 6.9.2
os: darwin x64

I'm building an Angular2 library for my other Angular2 applications. The library project was build using angular2-webpack-starter. I really like how angular cli works, so I removed all the webpack configs and moved the entire project to use angular cli.
This is my project folder structure. roughly...

my-library-project/
 ├──example/                   * the demo application to showcase how to consume the library
 ├──lib/                       * the library folder
 |   ├──my-library.module.ts   * the library entry module
 |   └──...                    * other library component/files
 ├──angular-cli.json           * cli config file
 ├──tslint.json                * typescript lint config
 ├──typedoc.json               * typescript documentation generator
 ├──tsconfig.json              * config that webpack uses for typescript
 └──package.json               * what npm uses to manage it's dependencies

The example folder is an application to showcase how to import/use the library. So it is essentially an angular2 application.
For the migration, I ran ng init --source-dir example in the my project folder so that cli will point the source folder to example instead of src.

Everything seems to work except:

  • I can't generate components outside of example folder, in my case I would like to generate them in the lib folder as well.
  • I would like to run my unit tests in the lib folder, but I get the error mentioned in here Can't set test directory outside of folder where test.ts is located in -beta.19 #3077
  • ng build --aot or ng serve --aot is giving me the following error, but I get no error while running ng serve or ng build. It is like the webpack AOT config doesn't care about any thing outside of project app folder.
ERROR in ./example/app/example.component.ngfactory.ts
Module not found: Error: Can't resolve '../../lib/my-library.component.ngfactory' in '/Users/bfwg/code/my-library/example/app'
 @ ./example/app/example.component.ngfactory.ts 27:0-63
 @ ./example/app/app.module.ngfactory.ts
 @ ./example/main.ts
 @ multi main
@bfwg bfwg changed the title Using angular-cli to generate a components in different source files. Using angular-cli to generate a components in different source folders. Dec 23, 2016
@filipesilva
Copy link
Contributor

We don't really support multiple apps at the moment. #1140 is tracking it.

@wKoza
Copy link
Contributor

wKoza commented Apr 19, 2017

Hi @bfwg, Are you solved your problem ? I think that I have the same problem : here #5998.

@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 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants