-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Closed
Description
Update 1
app/
shared/
api-module/
ui-module/
heroes/
heroes-list.component.ts
// tsconfig.json
{
"compilerOptions": {
"paths": {
"#shared": [
"app/shared"
]
}
}
}// shared/index.ts
export * from './api-module/api.module';
export * from './api-module/api.service';
export * from './api-module/ui.module';
export * from './api-module/ui-notification.service';
export * from './api-module/ui-select.service';// app/heroes/heroes-list.component.ts
import { Component } from '@angular/core';
import { ApiService } from '#api-module';
import {
UINotyficationService,
UISelectService
} from '#ui-module';
import { HeroesService } from './heroes.service.ts';Original Post
TypeScript module resolution
microsoft/TypeScript#5039
Configs
Add baseUrl and, optionaly, paths to tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"*": [ "modules/*" ]
}
}
}
Add modules to angular-cli.json apps
{
"apps": [
{
"modules": [
"src/modules"
]
]
}
Realisation
ValeryVS@c812fe8
Pros
Then we will be able to write
import { MyModule } from 'my';
and it will load module from src/modules/my/index.ts
We aslo can write src/app or src/app/shared to angular-cli.json and get rid of relative paths when we load services in app.
theBulltheBull
Metadata
Metadata
Assignees
Labels
No labels