How to create a library inside another library in Angular?
This should be a very trivial thing, because I don't find any reference about this or I don't know where and how to look for it. Let's say I have a scoped library core
@myscope/core
Now in this library I have a folder auth
for authentication workflow.
When I want to use library in my App
I import it using this:
import {AuthService} from @myscope/core
What I want to achieve, is to create a sub-library
so I can use like that:
import {AuthService} from @myscope/core/auth
I know this is possible by creating a new path in the tsconfig
, but I don't see that as a good resolution, because once I create a package out of this library, this path won't be delivered.
What is the best way to go?
angular nrwl
add a comment |
This should be a very trivial thing, because I don't find any reference about this or I don't know where and how to look for it. Let's say I have a scoped library core
@myscope/core
Now in this library I have a folder auth
for authentication workflow.
When I want to use library in my App
I import it using this:
import {AuthService} from @myscope/core
What I want to achieve, is to create a sub-library
so I can use like that:
import {AuthService} from @myscope/core/auth
I know this is possible by creating a new path in the tsconfig
, but I don't see that as a good resolution, because once I create a package out of this library, this path won't be delivered.
What is the best way to go?
angular nrwl
if@myscope/core
is the main entry point for the public api of your lib, is there any reason that you are looking to expose secondary entry points?
– Jota.Toledo
Nov 22 '18 at 22:07
btw, how was your library created? nrwl workspace? angular-cli lib?
– Jota.Toledo
Nov 22 '18 at 22:07
the reason is that I'm exposing the state (ngrx reducers) of my auth library which belongs to core. for example:@angular/http
and@angular/http/common
. the library is in a nrwl workspace.
– DAG
Nov 22 '18 at 22:13
add a comment |
This should be a very trivial thing, because I don't find any reference about this or I don't know where and how to look for it. Let's say I have a scoped library core
@myscope/core
Now in this library I have a folder auth
for authentication workflow.
When I want to use library in my App
I import it using this:
import {AuthService} from @myscope/core
What I want to achieve, is to create a sub-library
so I can use like that:
import {AuthService} from @myscope/core/auth
I know this is possible by creating a new path in the tsconfig
, but I don't see that as a good resolution, because once I create a package out of this library, this path won't be delivered.
What is the best way to go?
angular nrwl
This should be a very trivial thing, because I don't find any reference about this or I don't know where and how to look for it. Let's say I have a scoped library core
@myscope/core
Now in this library I have a folder auth
for authentication workflow.
When I want to use library in my App
I import it using this:
import {AuthService} from @myscope/core
What I want to achieve, is to create a sub-library
so I can use like that:
import {AuthService} from @myscope/core/auth
I know this is possible by creating a new path in the tsconfig
, but I don't see that as a good resolution, because once I create a package out of this library, this path won't be delivered.
What is the best way to go?
angular nrwl
angular nrwl
asked Nov 22 '18 at 20:58
DAGDAG
94211335
94211335
if@myscope/core
is the main entry point for the public api of your lib, is there any reason that you are looking to expose secondary entry points?
– Jota.Toledo
Nov 22 '18 at 22:07
btw, how was your library created? nrwl workspace? angular-cli lib?
– Jota.Toledo
Nov 22 '18 at 22:07
the reason is that I'm exposing the state (ngrx reducers) of my auth library which belongs to core. for example:@angular/http
and@angular/http/common
. the library is in a nrwl workspace.
– DAG
Nov 22 '18 at 22:13
add a comment |
if@myscope/core
is the main entry point for the public api of your lib, is there any reason that you are looking to expose secondary entry points?
– Jota.Toledo
Nov 22 '18 at 22:07
btw, how was your library created? nrwl workspace? angular-cli lib?
– Jota.Toledo
Nov 22 '18 at 22:07
the reason is that I'm exposing the state (ngrx reducers) of my auth library which belongs to core. for example:@angular/http
and@angular/http/common
. the library is in a nrwl workspace.
– DAG
Nov 22 '18 at 22:13
if
@myscope/core
is the main entry point for the public api of your lib, is there any reason that you are looking to expose secondary entry points?– Jota.Toledo
Nov 22 '18 at 22:07
if
@myscope/core
is the main entry point for the public api of your lib, is there any reason that you are looking to expose secondary entry points?– Jota.Toledo
Nov 22 '18 at 22:07
btw, how was your library created? nrwl workspace? angular-cli lib?
– Jota.Toledo
Nov 22 '18 at 22:07
btw, how was your library created? nrwl workspace? angular-cli lib?
– Jota.Toledo
Nov 22 '18 at 22:07
the reason is that I'm exposing the state (ngrx reducers) of my auth library which belongs to core. for example:
@angular/http
and @angular/http/common
. the library is in a nrwl workspace.– DAG
Nov 22 '18 at 22:13
the reason is that I'm exposing the state (ngrx reducers) of my auth library which belongs to core. for example:
@angular/http
and @angular/http/common
. the library is in a nrwl workspace.– DAG
Nov 22 '18 at 22:13
add a comment |
1 Answer
1
active
oldest
votes
Good question. With Angular 6, I tried these commands:
ng new sublibs
cd sublibs
ng generate library @myscope/core
ng generate library @myscope/core/auth
Project name "@myscope/core/auth" is invalid.
As you can see, it didn't work. But I didn't give up. I opened VS Code and copied sublibs/projects/myscope/core and pasted it inside itself then renamed sublibs/projects/myscope/core/core to sublibs/projects/myscope/core/auth. Then I went through all of the files in sublibs/projects/myscope/core/auth and modified the paths and names everywhere. This was mostly adding /auth or another ../ where appropriate. Then I renamed all of the files in sublibs/projects/myscope/core/auth/src/lib and changed the class names that start with Core so that they start with Auth. I didn't forget to change the package.json in sublibs/projects/myscope/core/auth and to add core/auth in angular.json by copying and pasting core and modifying it. After I was satisfied everything was renamed and changed appropriately, I entered the command:
ng build @myscope/auth
Here is the output:
Robert@ROBERT-PC MINGW64 /d/Users/Robert/robertbrower.technologies/customers/robertbrower.technologies/sublibs
$ ng build @myscope/core
Building Angular Package
Building entry point '@myscope/core'
Compiling TypeScript sources through ngc
Bundling to FESM2015
Bundling to FESM5
Bundling to UMD
Minifying UMD bundle
Copying declaration files
Writing package metadata
Removing scripts section in package.json as it's considered a potential security vulnerability.
Built @myscope/core
Building entry point '@myscope/core/auth'
Compiling TypeScript sources through ngc
Bundling to FESM2015
Bundling to FESM5
Bundling to UMD
Minifying UMD bundle
Copying declaration files
Writing package metadata
Removing scripts section in package.json as it's considered a potential security vulnerability.
Built @myscope/core/auth
Built Angular Package!
- from: D:UsersRobertrobertbrower.technologiescustomersrobertbrower.technologiessublibsprojectsmyscopecore
- to: D:UsersRobertrobertbrower.technologiescustomersrobertbrower.technologiessublibsdistmyscopecore
Robert@ROBERT-PC MINGW64 /d/Users/Robert/robertbrower.technologies/customers/robertbrower.technologies/sublibs
$
Then I was able to enter this command:
ng generate application my-app
After that I was able to modify my-app's app.module like this:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { CoreModule } from '@myscope/core';
import { AuthModule } from '@myscope/core/auth';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
CoreModule,
AuthModule
],
providers: ,
bootstrap: [AppComponent]
})
export class AppModule { }
Then I built my-app:
ng build my-app
And I received this output:
Robert@ROBERT-PC MINGW64 /d/Users/Robert/robertbrower.technologies/customers/robertbrower.technologies/sublibs
$ ng build my-app
Date: 2018-11-22T22:43:33.834Z
Hash: b686631b6cb537b9519c
Time: 10255ms
chunk {main} main.js, main.js.map (main) 20.2 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 249 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.22 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 16.7 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 3.01 MB [initial] [rendered]
Robert@ROBERT-PC MINGW64 /d/Users/Robert/robertbrower.technologies/customers/robertbrower.technologies/sublibs
$
So while I do not know how to use the Angular CLI to achieve this, I was able to do it manually.
See the repo: https://github.com/robertbrower-technologies/sublibs
I think the main problem here you always gonna have problems if the cli changes and you'll have to update everytime things by hand. this is a workaround more than a real solution.I wonder how angular team does this.
– DAG
Nov 23 '18 at 8:59
I upvoted it anyway as this my be helpful for others as well...
– DAG
Nov 23 '18 at 9:00
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437912%2fhow-to-create-a-library-inside-another-library-in-angular%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Good question. With Angular 6, I tried these commands:
ng new sublibs
cd sublibs
ng generate library @myscope/core
ng generate library @myscope/core/auth
Project name "@myscope/core/auth" is invalid.
As you can see, it didn't work. But I didn't give up. I opened VS Code and copied sublibs/projects/myscope/core and pasted it inside itself then renamed sublibs/projects/myscope/core/core to sublibs/projects/myscope/core/auth. Then I went through all of the files in sublibs/projects/myscope/core/auth and modified the paths and names everywhere. This was mostly adding /auth or another ../ where appropriate. Then I renamed all of the files in sublibs/projects/myscope/core/auth/src/lib and changed the class names that start with Core so that they start with Auth. I didn't forget to change the package.json in sublibs/projects/myscope/core/auth and to add core/auth in angular.json by copying and pasting core and modifying it. After I was satisfied everything was renamed and changed appropriately, I entered the command:
ng build @myscope/auth
Here is the output:
Robert@ROBERT-PC MINGW64 /d/Users/Robert/robertbrower.technologies/customers/robertbrower.technologies/sublibs
$ ng build @myscope/core
Building Angular Package
Building entry point '@myscope/core'
Compiling TypeScript sources through ngc
Bundling to FESM2015
Bundling to FESM5
Bundling to UMD
Minifying UMD bundle
Copying declaration files
Writing package metadata
Removing scripts section in package.json as it's considered a potential security vulnerability.
Built @myscope/core
Building entry point '@myscope/core/auth'
Compiling TypeScript sources through ngc
Bundling to FESM2015
Bundling to FESM5
Bundling to UMD
Minifying UMD bundle
Copying declaration files
Writing package metadata
Removing scripts section in package.json as it's considered a potential security vulnerability.
Built @myscope/core/auth
Built Angular Package!
- from: D:UsersRobertrobertbrower.technologiescustomersrobertbrower.technologiessublibsprojectsmyscopecore
- to: D:UsersRobertrobertbrower.technologiescustomersrobertbrower.technologiessublibsdistmyscopecore
Robert@ROBERT-PC MINGW64 /d/Users/Robert/robertbrower.technologies/customers/robertbrower.technologies/sublibs
$
Then I was able to enter this command:
ng generate application my-app
After that I was able to modify my-app's app.module like this:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { CoreModule } from '@myscope/core';
import { AuthModule } from '@myscope/core/auth';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
CoreModule,
AuthModule
],
providers: ,
bootstrap: [AppComponent]
})
export class AppModule { }
Then I built my-app:
ng build my-app
And I received this output:
Robert@ROBERT-PC MINGW64 /d/Users/Robert/robertbrower.technologies/customers/robertbrower.technologies/sublibs
$ ng build my-app
Date: 2018-11-22T22:43:33.834Z
Hash: b686631b6cb537b9519c
Time: 10255ms
chunk {main} main.js, main.js.map (main) 20.2 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 249 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.22 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 16.7 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 3.01 MB [initial] [rendered]
Robert@ROBERT-PC MINGW64 /d/Users/Robert/robertbrower.technologies/customers/robertbrower.technologies/sublibs
$
So while I do not know how to use the Angular CLI to achieve this, I was able to do it manually.
See the repo: https://github.com/robertbrower-technologies/sublibs
I think the main problem here you always gonna have problems if the cli changes and you'll have to update everytime things by hand. this is a workaround more than a real solution.I wonder how angular team does this.
– DAG
Nov 23 '18 at 8:59
I upvoted it anyway as this my be helpful for others as well...
– DAG
Nov 23 '18 at 9:00
add a comment |
Good question. With Angular 6, I tried these commands:
ng new sublibs
cd sublibs
ng generate library @myscope/core
ng generate library @myscope/core/auth
Project name "@myscope/core/auth" is invalid.
As you can see, it didn't work. But I didn't give up. I opened VS Code and copied sublibs/projects/myscope/core and pasted it inside itself then renamed sublibs/projects/myscope/core/core to sublibs/projects/myscope/core/auth. Then I went through all of the files in sublibs/projects/myscope/core/auth and modified the paths and names everywhere. This was mostly adding /auth or another ../ where appropriate. Then I renamed all of the files in sublibs/projects/myscope/core/auth/src/lib and changed the class names that start with Core so that they start with Auth. I didn't forget to change the package.json in sublibs/projects/myscope/core/auth and to add core/auth in angular.json by copying and pasting core and modifying it. After I was satisfied everything was renamed and changed appropriately, I entered the command:
ng build @myscope/auth
Here is the output:
Robert@ROBERT-PC MINGW64 /d/Users/Robert/robertbrower.technologies/customers/robertbrower.technologies/sublibs
$ ng build @myscope/core
Building Angular Package
Building entry point '@myscope/core'
Compiling TypeScript sources through ngc
Bundling to FESM2015
Bundling to FESM5
Bundling to UMD
Minifying UMD bundle
Copying declaration files
Writing package metadata
Removing scripts section in package.json as it's considered a potential security vulnerability.
Built @myscope/core
Building entry point '@myscope/core/auth'
Compiling TypeScript sources through ngc
Bundling to FESM2015
Bundling to FESM5
Bundling to UMD
Minifying UMD bundle
Copying declaration files
Writing package metadata
Removing scripts section in package.json as it's considered a potential security vulnerability.
Built @myscope/core/auth
Built Angular Package!
- from: D:UsersRobertrobertbrower.technologiescustomersrobertbrower.technologiessublibsprojectsmyscopecore
- to: D:UsersRobertrobertbrower.technologiescustomersrobertbrower.technologiessublibsdistmyscopecore
Robert@ROBERT-PC MINGW64 /d/Users/Robert/robertbrower.technologies/customers/robertbrower.technologies/sublibs
$
Then I was able to enter this command:
ng generate application my-app
After that I was able to modify my-app's app.module like this:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { CoreModule } from '@myscope/core';
import { AuthModule } from '@myscope/core/auth';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
CoreModule,
AuthModule
],
providers: ,
bootstrap: [AppComponent]
})
export class AppModule { }
Then I built my-app:
ng build my-app
And I received this output:
Robert@ROBERT-PC MINGW64 /d/Users/Robert/robertbrower.technologies/customers/robertbrower.technologies/sublibs
$ ng build my-app
Date: 2018-11-22T22:43:33.834Z
Hash: b686631b6cb537b9519c
Time: 10255ms
chunk {main} main.js, main.js.map (main) 20.2 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 249 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.22 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 16.7 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 3.01 MB [initial] [rendered]
Robert@ROBERT-PC MINGW64 /d/Users/Robert/robertbrower.technologies/customers/robertbrower.technologies/sublibs
$
So while I do not know how to use the Angular CLI to achieve this, I was able to do it manually.
See the repo: https://github.com/robertbrower-technologies/sublibs
I think the main problem here you always gonna have problems if the cli changes and you'll have to update everytime things by hand. this is a workaround more than a real solution.I wonder how angular team does this.
– DAG
Nov 23 '18 at 8:59
I upvoted it anyway as this my be helpful for others as well...
– DAG
Nov 23 '18 at 9:00
add a comment |
Good question. With Angular 6, I tried these commands:
ng new sublibs
cd sublibs
ng generate library @myscope/core
ng generate library @myscope/core/auth
Project name "@myscope/core/auth" is invalid.
As you can see, it didn't work. But I didn't give up. I opened VS Code and copied sublibs/projects/myscope/core and pasted it inside itself then renamed sublibs/projects/myscope/core/core to sublibs/projects/myscope/core/auth. Then I went through all of the files in sublibs/projects/myscope/core/auth and modified the paths and names everywhere. This was mostly adding /auth or another ../ where appropriate. Then I renamed all of the files in sublibs/projects/myscope/core/auth/src/lib and changed the class names that start with Core so that they start with Auth. I didn't forget to change the package.json in sublibs/projects/myscope/core/auth and to add core/auth in angular.json by copying and pasting core and modifying it. After I was satisfied everything was renamed and changed appropriately, I entered the command:
ng build @myscope/auth
Here is the output:
Robert@ROBERT-PC MINGW64 /d/Users/Robert/robertbrower.technologies/customers/robertbrower.technologies/sublibs
$ ng build @myscope/core
Building Angular Package
Building entry point '@myscope/core'
Compiling TypeScript sources through ngc
Bundling to FESM2015
Bundling to FESM5
Bundling to UMD
Minifying UMD bundle
Copying declaration files
Writing package metadata
Removing scripts section in package.json as it's considered a potential security vulnerability.
Built @myscope/core
Building entry point '@myscope/core/auth'
Compiling TypeScript sources through ngc
Bundling to FESM2015
Bundling to FESM5
Bundling to UMD
Minifying UMD bundle
Copying declaration files
Writing package metadata
Removing scripts section in package.json as it's considered a potential security vulnerability.
Built @myscope/core/auth
Built Angular Package!
- from: D:UsersRobertrobertbrower.technologiescustomersrobertbrower.technologiessublibsprojectsmyscopecore
- to: D:UsersRobertrobertbrower.technologiescustomersrobertbrower.technologiessublibsdistmyscopecore
Robert@ROBERT-PC MINGW64 /d/Users/Robert/robertbrower.technologies/customers/robertbrower.technologies/sublibs
$
Then I was able to enter this command:
ng generate application my-app
After that I was able to modify my-app's app.module like this:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { CoreModule } from '@myscope/core';
import { AuthModule } from '@myscope/core/auth';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
CoreModule,
AuthModule
],
providers: ,
bootstrap: [AppComponent]
})
export class AppModule { }
Then I built my-app:
ng build my-app
And I received this output:
Robert@ROBERT-PC MINGW64 /d/Users/Robert/robertbrower.technologies/customers/robertbrower.technologies/sublibs
$ ng build my-app
Date: 2018-11-22T22:43:33.834Z
Hash: b686631b6cb537b9519c
Time: 10255ms
chunk {main} main.js, main.js.map (main) 20.2 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 249 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.22 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 16.7 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 3.01 MB [initial] [rendered]
Robert@ROBERT-PC MINGW64 /d/Users/Robert/robertbrower.technologies/customers/robertbrower.technologies/sublibs
$
So while I do not know how to use the Angular CLI to achieve this, I was able to do it manually.
See the repo: https://github.com/robertbrower-technologies/sublibs
Good question. With Angular 6, I tried these commands:
ng new sublibs
cd sublibs
ng generate library @myscope/core
ng generate library @myscope/core/auth
Project name "@myscope/core/auth" is invalid.
As you can see, it didn't work. But I didn't give up. I opened VS Code and copied sublibs/projects/myscope/core and pasted it inside itself then renamed sublibs/projects/myscope/core/core to sublibs/projects/myscope/core/auth. Then I went through all of the files in sublibs/projects/myscope/core/auth and modified the paths and names everywhere. This was mostly adding /auth or another ../ where appropriate. Then I renamed all of the files in sublibs/projects/myscope/core/auth/src/lib and changed the class names that start with Core so that they start with Auth. I didn't forget to change the package.json in sublibs/projects/myscope/core/auth and to add core/auth in angular.json by copying and pasting core and modifying it. After I was satisfied everything was renamed and changed appropriately, I entered the command:
ng build @myscope/auth
Here is the output:
Robert@ROBERT-PC MINGW64 /d/Users/Robert/robertbrower.technologies/customers/robertbrower.technologies/sublibs
$ ng build @myscope/core
Building Angular Package
Building entry point '@myscope/core'
Compiling TypeScript sources through ngc
Bundling to FESM2015
Bundling to FESM5
Bundling to UMD
Minifying UMD bundle
Copying declaration files
Writing package metadata
Removing scripts section in package.json as it's considered a potential security vulnerability.
Built @myscope/core
Building entry point '@myscope/core/auth'
Compiling TypeScript sources through ngc
Bundling to FESM2015
Bundling to FESM5
Bundling to UMD
Minifying UMD bundle
Copying declaration files
Writing package metadata
Removing scripts section in package.json as it's considered a potential security vulnerability.
Built @myscope/core/auth
Built Angular Package!
- from: D:UsersRobertrobertbrower.technologiescustomersrobertbrower.technologiessublibsprojectsmyscopecore
- to: D:UsersRobertrobertbrower.technologiescustomersrobertbrower.technologiessublibsdistmyscopecore
Robert@ROBERT-PC MINGW64 /d/Users/Robert/robertbrower.technologies/customers/robertbrower.technologies/sublibs
$
Then I was able to enter this command:
ng generate application my-app
After that I was able to modify my-app's app.module like this:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { CoreModule } from '@myscope/core';
import { AuthModule } from '@myscope/core/auth';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
CoreModule,
AuthModule
],
providers: ,
bootstrap: [AppComponent]
})
export class AppModule { }
Then I built my-app:
ng build my-app
And I received this output:
Robert@ROBERT-PC MINGW64 /d/Users/Robert/robertbrower.technologies/customers/robertbrower.technologies/sublibs
$ ng build my-app
Date: 2018-11-22T22:43:33.834Z
Hash: b686631b6cb537b9519c
Time: 10255ms
chunk {main} main.js, main.js.map (main) 20.2 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 249 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.22 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 16.7 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 3.01 MB [initial] [rendered]
Robert@ROBERT-PC MINGW64 /d/Users/Robert/robertbrower.technologies/customers/robertbrower.technologies/sublibs
$
So while I do not know how to use the Angular CLI to achieve this, I was able to do it manually.
See the repo: https://github.com/robertbrower-technologies/sublibs
edited Nov 22 '18 at 22:57
answered Nov 22 '18 at 22:48
Robert BrowerRobert Brower
312
312
I think the main problem here you always gonna have problems if the cli changes and you'll have to update everytime things by hand. this is a workaround more than a real solution.I wonder how angular team does this.
– DAG
Nov 23 '18 at 8:59
I upvoted it anyway as this my be helpful for others as well...
– DAG
Nov 23 '18 at 9:00
add a comment |
I think the main problem here you always gonna have problems if the cli changes and you'll have to update everytime things by hand. this is a workaround more than a real solution.I wonder how angular team does this.
– DAG
Nov 23 '18 at 8:59
I upvoted it anyway as this my be helpful for others as well...
– DAG
Nov 23 '18 at 9:00
I think the main problem here you always gonna have problems if the cli changes and you'll have to update everytime things by hand. this is a workaround more than a real solution.I wonder how angular team does this.
– DAG
Nov 23 '18 at 8:59
I think the main problem here you always gonna have problems if the cli changes and you'll have to update everytime things by hand. this is a workaround more than a real solution.I wonder how angular team does this.
– DAG
Nov 23 '18 at 8:59
I upvoted it anyway as this my be helpful for others as well...
– DAG
Nov 23 '18 at 9:00
I upvoted it anyway as this my be helpful for others as well...
– DAG
Nov 23 '18 at 9:00
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437912%2fhow-to-create-a-library-inside-another-library-in-angular%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
if
@myscope/core
is the main entry point for the public api of your lib, is there any reason that you are looking to expose secondary entry points?– Jota.Toledo
Nov 22 '18 at 22:07
btw, how was your library created? nrwl workspace? angular-cli lib?
– Jota.Toledo
Nov 22 '18 at 22:07
the reason is that I'm exposing the state (ngrx reducers) of my auth library which belongs to core. for example:
@angular/http
and@angular/http/common
. the library is in a nrwl workspace.– DAG
Nov 22 '18 at 22:13