From 524d976e24a9408e46a51e7f079a42def90afd89 Mon Sep 17 00:00:00 2001 From: kuuurt13 Date: Fri, 24 Feb 2017 23:12:15 -0500 Subject: [PATCH] feat(lib): Added support for AOT compilation --- .gitignore | 7 ++++- lib/components/block-ui.component.style.ts | 3 +- ...nt.html => block-ui.component.template.ts} | 2 ++ lib/components/block-ui.component.ts | 5 ++-- .../block-ui-default-name.constant.ts | 2 +- lib/services/block-ui.service.spec.ts | 16 ----------- package.json | 22 +++++++++++---- tsconfig.json | 28 +++++++++++++++---- 8 files changed, 53 insertions(+), 32 deletions(-) rename lib/components/{block-ui.component.html => block-ui.component.template.ts} (88%) delete mode 100644 lib/services/block-ui.service.spec.ts diff --git a/.gitignore b/.gitignore index 4cee272..632240c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ node_modules npm-debug.log -*.tgz \ No newline at end of file +settings.json +*.tgz +*.metadata.json +/dist +/**/*.js +/**/*.js.map \ No newline at end of file diff --git a/lib/components/block-ui.component.style.ts b/lib/components/block-ui.component.style.ts index e00bb21..7f22b74 100644 --- a/lib/components/block-ui.component.style.ts +++ b/lib/components/block-ui.component.style.ts @@ -1,5 +1,4 @@ -export default -` +export const styles = ` .block-ui-wrapper { position: absolute; height: 100%; diff --git a/lib/components/block-ui.component.html b/lib/components/block-ui.component.template.ts similarity index 88% rename from lib/components/block-ui.component.html rename to lib/components/block-ui.component.template.ts index 6b2ed35..aa08488 100644 --- a/lib/components/block-ui.component.html +++ b/lib/components/block-ui.component.template.ts @@ -1,6 +1,8 @@ +export const template = `
{{ message }}
+`; diff --git a/lib/components/block-ui.component.ts b/lib/components/block-ui.component.ts index 5aa83ce..61034e0 100644 --- a/lib/components/block-ui.component.ts +++ b/lib/components/block-ui.component.ts @@ -9,11 +9,12 @@ import { Observable, Subscription } from 'rxjs'; import { BlockUIService } from '../services/block-ui.service'; import { BlockUIEvent } from '../models'; import { BlockUIActions, BlockUIDefaultName } from '../constants'; -import styles from './block-ui.component.style'; +import { styles } from './block-ui.component.style'; +import { template } from './block-ui.component.template'; @Component({ selector: 'block-ui', - templateUrl: './block-ui.component.html', + template: template, styles: [styles], // TODO: Find how to bundle styles for npm encapsulation: ViewEncapsulation.None }) diff --git a/lib/constants/block-ui-default-name.constant.ts b/lib/constants/block-ui-default-name.constant.ts index 4d57e8a..dbeacb0 100644 --- a/lib/constants/block-ui-default-name.constant.ts +++ b/lib/constants/block-ui-default-name.constant.ts @@ -1 +1 @@ -export const BlockUIDefaultName = 'block-ui-main' \ No newline at end of file +export const BlockUIDefaultName: string = `block-ui-main`; diff --git a/lib/services/block-ui.service.spec.ts b/lib/services/block-ui.service.spec.ts deleted file mode 100644 index a7381e3..0000000 --- a/lib/services/block-ui.service.spec.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* tslint:disable:no-unused-variable */ - -import { TestBed, async, inject } from '@angular/core/testing'; -import { BlockUIService } from './block-ui.service'; - -describe('BlockUIService', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - providers: [BlockUIService] - }); - }); - - it('should ...', inject([BlockUIService], (service: BlockUIService) => { - expect(service).toBeTruthy(); - })); -}); diff --git a/package.json b/package.json index dde9e4a..5ad6c61 100644 --- a/package.json +++ b/package.json @@ -2,9 +2,10 @@ "name": "ng-block-ui", "version": "0.1.1", "description": "Angular (2 & up) Block UI", - "main": "index.ts", + "main": "dist/index.js", + "typings": "dist/index.d.ts", "scripts": { - "start": "webpack-dev-server --inline --progress --port 8080", + "build": "node_modules/.bin/ngc -p tsconfig.json", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { @@ -23,6 +24,11 @@ "url": "https://github.com/kuuurt13/ng-block-ui/issues" }, "homepage": "https://github.com/kuuurt13/ng-block-ui#readme", + "peerDependencies": { + "@angular/common": "^2.2.4", + "@angular/core": "^2.2.4", + "@angular/platform-browser": "^2.2.4" + }, "dependencies": { "@angular/common": "^2.4.8", "@angular/compiler": "^2.4.8", @@ -36,8 +42,11 @@ "zone.js": "^0.7.7" }, "devDependencies": { - "@types/node": "^6.0.45", + "@angular/compiler": "^2.4.8", + "@angular/compiler-cli": "^2.4.8", + "@angular/platform-server": "^2.4.8", "@types/jasmine": "2.5.35", + "@types/node": "^6.0.45", "angular2-template-loader": "^0.6.0", "awesome-typescript-loader": "^3.0.0-beta.18", "css-loader": "^0.26.1", @@ -56,9 +65,12 @@ "raw-loader": "^0.5.1", "rimraf": "^2.5.2", "style-loader": "^0.13.1", - "typescript": "~2.0.10", + "typescript": "^2.2.1", "webpack": "2.2.0", "webpack-dev-server": "2.2.0-rc.0", "webpack-merge": "^2.4.0" - } + }, + "files": [ + "dist" + ] } diff --git a/tsconfig.json b/tsconfig.json index d14cf43..a322ebc 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,13 +1,31 @@ { "compilerOptions": { + "outDir": "dist", "target": "es5", - "module": "commonjs", + "module": "es2015", "moduleResolution": "node", - "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, - "lib": ["es2015", "dom"], + "sourceMap": false, + "noEmitHelpers": false, "noImplicitAny": false, - "suppressImplicitAnyIndexErrors": true + "declaration": true, + "skipLibCheck": true, + "stripInternal": true, + "lib": [ + "es2015", + "dom" + ] + }, + "exclude": [ + "node_modules", + "demo" + ], + "files": [ + "./index.ts" + ], + "angularCompilerOptions": { + "genDir": "dist", + "skipTemplateCodegen": true } -} \ No newline at end of file +}