Skip to content

Commit 38c25fa

Browse files
Skyler BrownSkyler Brown
authored andcommitted
added declarations and finalizing library export
1 parent 251856d commit 38c25fa

File tree

9 files changed

+76
-483
lines changed

9 files changed

+76
-483
lines changed

angular-2-webpack-library/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"author": "",
77
"homepage": "",
88
"license": "",
9+
"main": "dist/src/index.js",
10+
"typings": "dist/src/index.d.ts",
911
"scripts": {
1012
"build": "webpack --config webpack.config.js --progress --profile --bail",
1113
"clean:dist": "npm run rimraf -- dist",
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
import {Component} from '@angular/core';
1+
import {Component, OnInit} from '@angular/core';
22

33
@Component({
4-
selector: 'sample',
4+
selector: 'sample-component',
55
styles: [``],
66
template: `
77
<h1>Sample Component</h1>
88
`
99
})
10-
export class SampleComponent {
10+
export class SampleComponent implements OnInit{
11+
12+
public foo:string = 'foo';
13+
1114
constructor() {
1215
}
16+
17+
ngOnInit() {
18+
console.log('hello from SampleComponent');
19+
}
1320
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './components/sample.component';
1+
export {SampleComponent} from './components/sample.component';

angular-2-webpack-library/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"sourceMap": true,
1010
"noEmitHelpers": true,
1111
"strictNullChecks": false,
12+
"declaration": true,
1213
"baseUrl": "./src",
1314
"paths": [
1415
],

angular-2-webpack-library/webpack.config.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,24 @@ module.exports = {
2626

2727
// cache: false, // Cache generated modules and chunks to improve performance for multiple incremental builds. This is enabled by default in watch mode. You can pass false to disable it.
2828
// debug: true, // Switch loaders to debug mode.
29-
// devtool: 'cheap-module-source-map',
29+
devtool: 'cheap-module-source-map',
3030

3131
entry: './src/index.ts',
3232

3333
output: {
3434
path: helpers.root('dist'),
35-
filename: 'myLibrary.js',
35+
filename: 'src/index.js',
3636
// sourceMapFilename: '[name].map',
3737
// chunkFilename: '[id].chunk.js',
38-
library: 'myLibrary',
38+
library: 'angular-2-webpack-library',
3939
libraryTarget: 'umd',
40-
// umdNamedDefine: true
40+
41+
42+
/* define("angular-2-webpack-library", ["@angular/core"], factory)
43+
* vs
44+
* define(["@angular/core"], factory)
45+
*/
46+
umdNamedDefine: true
4147
},
4248

4349
externals: [

0 commit comments

Comments
 (0)