I have created a typescript library for angular 2 which facilitates the to access my backend service.
So far it's a private repo, but I want to upload it as an open source library to github and register it on npm.
I'm not really sure what to do now, since documentation on this subject is not easy to find.
the folder structure looks like this:
src
|--sdk.ts // entry point
|--services
|--auth.ts
|--database.ts
|--5 more ts files
|--utils
|--utils.ts
|--interfaces.ts
|--tests (8 ..spec.ts files)
my entry point (sdk.ts) looks like this
import { NgModule, ModuleWithProviders } from '@angular/core';
import { Injectable } from '@angular/core';
import { SelfbitsDatabase } from './services/database';
import { SelfbitsAuth } from './services/auth';
import { SelfbitsAppConfig } from './utils/interfaces';
import { SelfbitsFile } from './services/file';
import { SelfbitsUser } from './services/user';
import { SelfbitsDevice } from './services/device';
import { SelfbitsPush } from './services/push';
import { HttpModule } from '@angular/http';
@Injectable()
export class SelfbitsAngular {
constructor(
public auth : SelfbitsAuth,
public database : SelfbitsDatabase,
public file : SelfbitsFile,
public user : SelfbitsUser,
public device: SelfbitsDevice,
public push : SelfbitsPush
){}
}
export const SELFBITS_PROVIDERS:any[] = [
SelfbitsAngular,
SelfbitsAuth,
SelfbitsDatabase,
SelfbitsFile,
SelfbitsUser,
SelfbitsDevice,
SelfbitsPush
];
@NgModule({
providers:SELFBITS_PROVIDERS,
imports:[ HttpModule ]
})
export class SelfbitsAngularModule{
static initializeApp(config:SelfbitsAppConfig):ModuleWithProviders{
return {
ngModule:SelfbitsAngularModule,
providers:[
{ provide: 'SelfbitsConfig', useValue: config }
]
}
}
}
and here's the webpack.config.js which doesn't really do what I want...
module.exports = {
entry:'./src/sdk.ts',
output:{
path: helpers.root('dist'),
filename:'selfbitsangular2sdk.js'
},
resolve: {
extensions: ['', '.js', '.ts']
},
module: {
loaders: [
{
test: /\.ts$/,
exclude:'/test/',
loaders: ['ts-loader']
}
]
}
};
I'm not sure if webpack is even the right choice..or wether is should be bundled and minified or not. Any hints and tipps are welcome!
Cheers