Skip to content
This repository was archived by the owner on Feb 17, 2024. It is now read-only.

Commit 5acd2a2

Browse files
committed
💣 init
0 parents  commit 5acd2a2

17 files changed

+3503
-0
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
node_modules
2+
*.log
3+
*.tmp
4+
DS*
5+
typings
6+
dist
7+
.vscode
8+
*.pid
9+
*.seed
10+
build/Release

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Angular Lib starter
2+
> Universal, AOT, Web Workers, ready lib starter. Use for your Angular libs
3+
4+
5+
## Getting started
6+
* fork this
7+
* clear the git history `git init .`
8+
* add your source code in `src`.
9+
* change the entry in `webpack.config.js`
10+
* change the output filnames in `package.json` to match your src files and webpack
11+
* `"main", "jsnext:main", "module", "types"`
12+
* build your project `yarn release` or `npm run release`
13+
14+
## Builds
15+
This starter prepares 2 different versions for builds of your lib
16+
* **esm** or ES2015 Modules
17+
* this build is a transpilation of your Typescript code to ES5 and ES2015 modules. Its' not bundled. This is needed for treeshaking when users use your lib
18+
* **UMD**
19+
* this is a bundle of ES5 code. What you would typically get from webpack or rollup.
20+
21+
The build system generates AOT metadata too, so you're good.
22+
23+
24+
## Scripts
25+
* `"test"`: runs the test in mocha on node
26+
* `"build:esm"`: builds the esm versions
27+
* `"build:bundle"`: builds the UMD version
28+
* `"build:aot"`: makes it work for aot
29+
* `"build"`: does all the above
30+
* `"copy"`: copies over file to dist
31+
* `"release"`: does all the above

custom.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module '*'

mocha.opts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
--webpack-config ./webpack.testing.js
2+
--require ./test-shim.js
3+
--ui bdd
4+
--glob *.spec.ts
5+
--recursive
6+
src

package.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"name": "angular-lib-starter",
3+
"version": "0.0.1",
4+
"description": "Starter to make Angular libs",
5+
"main": "bundle.js",
6+
"jsnext:main": "lib.module.js",
7+
"module": "lib.module.js",
8+
"types": "index.d.ts",
9+
"scripts": {
10+
"test": "rimraf ./tmp/mocha-webpack && mocha-webpack --opts 'mocha.opts'",
11+
"build:esm": "ntsc -p tsconfig.esm.json",
12+
"build:bundle": "webpack --progress --colors",
13+
"build:aot": "ngc",
14+
"build": "rimraf build && npm run build:esm && npm run build:bundle && npm run build:aot",
15+
"copy": "cp package.json dist && cp README.md dist",
16+
"release": "npm run build && npm run copy"
17+
},
18+
"license": "MIT",
19+
"devDependencies": {
20+
"@angular/common": "^4.1.3",
21+
"@angular/compiler": "^4.1.3",
22+
"@angular/compiler-cli": "^4.1.3",
23+
"@angular/core": "^4.1.3",
24+
"@angular/platform-browser": "^4.1.3",
25+
"@angular/platform-browser-dynamic": "^4.1.3",
26+
"@angular/platform-server": "^4.1.3",
27+
"@types/chai": "^3.5.2",
28+
"@types/mocha": "^2.2.41",
29+
"@types/node": "^7.0.18",
30+
"@types/sinon": "^2.2.2",
31+
"angular2-template-loader": "^0.6.2",
32+
"awesome-typescript-loader": "^3.1.3",
33+
"core-js": "^2.4.1",
34+
"jsdom": "^10.1.0",
35+
"mocha": "^3.4.1",
36+
"mocha-webpack": "^0.7.0",
37+
"ntypescript": "latest",
38+
"raw-loader": "^0.5.1",
39+
"rimraf": "^2.6.1",
40+
"rxjs": "^5.4.0",
41+
"source-map-support": "^0.4.15",
42+
"typescript": "^2.3.2",
43+
"webpack": "^2.5.1",
44+
"webpack-node-externals": "^1.6.0",
45+
"zone.js": "^0.8.10"
46+
},
47+
"dependencies": {
48+
"css-loader": "^0.28.1",
49+
"postcss-loader": "^2.0.5",
50+
"sass-loader": "^6.0.5",
51+
"to-string-loader": "^1.1.5"
52+
}
53+
}

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './lib.module'

src/lib.component.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div class="lib">
2+
hello
3+
</div>

src/lib.component.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Component } from '@angular/core'
2+
3+
@Component({
4+
selector: 'lib',
5+
template: require('./lib.component.html')
6+
})
7+
export class LibComponent {}

src/lib.module.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {NgModule} from '@angular/core'
2+
import {CommonModule} from '@angular/common'
3+
import { LibComponent } from './lib.component'
4+
5+
6+
@NgModule({
7+
imports: [CommonModule],
8+
declarations: [LibComponent],
9+
exports: [LibComponent]
10+
})
11+
export class LibModule {}

src/lib.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
describe('test', () => {
2+
it('should be dope', () => {
3+
console.log('hello')
4+
})
5+
})

0 commit comments

Comments
 (0)