diff --git a/.gitignore b/.gitignore index 46fb154..090a202 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ coverage/ typings/ *.d.ts *.log -*.tgz \ No newline at end of file +*.tgz +/samples/node/mongooseStoreSampleProject \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a90d1f..f2dc447 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 1.0.0 + + - Fix UMD lib. Add browser usage sample (breaking changes will go to 2.x) + +## 1.0.0-alpha.1 + + - Prepare for asynchronous storages (api/db). + ## 0.0.7 - Adding nomenclature diff --git a/package.json b/package.json index e6efa24..7a10185 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "billing", - "version": "0.0.7", + "version": "1.0.0", "description": "Billing Module Js", "author": "AlexV", "repository": { @@ -20,10 +20,10 @@ "typings": "typings install", "test": "karma start karma.conf.js", "build": "tsc -d", - "dist": "webpack -p" + "dist": "webpack --progress --profile --bail" }, "devDependencies": { - "@types/jasmine": "^2.2.31", + "awesome-typescript-loader": "^2.2.4", "istanbul": "^0.4.5", "jasmine-core": "^2.4.1", "karma": "^1.2.0", @@ -33,7 +33,6 @@ "karma-phantomjs-launcher": "^1.0.2", "karma-typescript": "^2.0.5", "source-map": "^0.5.6", - "ts-loader": "^0.8.2", "typescript": "^2.0.0", "typings": "^1.3.3", "webpack": "^1.13.2" diff --git a/samples/browser/index.html b/samples/browser/index.html new file mode 100644 index 0000000..65ab332 --- /dev/null +++ b/samples/browser/index.html @@ -0,0 +1,21 @@ + + + + Billing test + + + + + + + + + \ No newline at end of file diff --git a/src/billing/bill.ts b/src/billing/bill.ts index 797056e..29c6ff0 100644 --- a/src/billing/bill.ts +++ b/src/billing/bill.ts @@ -94,7 +94,15 @@ export class Bill extends ValidationModel { } get operator() { - if (this.operatorId) return Operator.find(this.operatorId); + let _operator :Operator; + if (this.operatorId) { + Operator.find(this.operatorId, (operator)=> { + _operator = operator; + }).catch((err)=> { + console.warn(`Bill#operator ${this.operatorId} ${err.message}`); + }); + } + return _operator; } static new(attributes :any = {}) :Bill { diff --git a/src/billing/charge/charge.spec.ts b/src/billing/charge/charge.spec.ts index 93b4b10..ec247f0 100644 --- a/src/billing/charge/charge.spec.ts +++ b/src/billing/charge/charge.spec.ts @@ -203,11 +203,12 @@ describe('Charge', () => { expect(charge.description).toEqual('Fresh'); }); - it('set price', function() { + it('set price', function(done) { let charge = new Charge({ pluId: 1 }); expect(charge.price).toEqual(0); charge.price = 1.26; expect(charge.price).toEqual(1.26); + done(); }); it('set modifier', function() { @@ -310,10 +311,11 @@ describe('Charge', () => { expect(charge.taxRatio).toEqual(0.09); }); - it('missing nomenclature should not throw exteptions', function() { + it('missing nomenclature should not throw exteptions', function(done) { let charge = new Charge({ pluId: 2 }); expect(()=> { charge.taxRatio; }).not.toThrow(); expect(charge.department).toBeUndefined(); + done(); }); it('direct department', function() { @@ -334,11 +336,15 @@ describe('Charge', () => { it('update nomenclature direct', function() { let charge = new Charge({ price: 3 }); - charge.update({ plu: Nomenclature.Plu.find(1) }); + let plu: Nomenclature.Plu, taxGroup :Nomenclature.TaxGroup, department: Nomenclature.Department; + Nomenclature.Plu.find(1, (r)=> plu = r ); + charge.update({ plu: plu }); expect(charge.pluId).toEqual(1); - charge.update({ taxGroup: Nomenclature.TaxGroup.find(1) }); + Nomenclature.TaxGroup.find(1, (r)=> taxGroup = r ); + charge.update({ taxGroup: taxGroup }); expect(charge.taxGroupId).toEqual(1); - charge.update({ department: Nomenclature.Department.find(2) }); + Nomenclature.Department.find(2, (r)=> department = r ); + charge.update({ department: department }); expect(charge.departmentId).toEqual(2); }); }); diff --git a/src/billing/charge/index.ts b/src/billing/charge/index.ts index 26ab7af..64e9c09 100644 --- a/src/billing/charge/index.ts +++ b/src/billing/charge/index.ts @@ -7,6 +7,7 @@ import { BillItem } from '../concerns/billItem'; import { Modifier } from '../modifier'; import { IChargeAttributes } from './interface'; import { IModifierAttributes } from '../modifier/interface'; +import { ChargesCollection } from './collection'; import { Plu, TaxGroup, Department } from '../nomenclature'; @@ -194,21 +195,39 @@ export class Charge extends BillItem { } get plu() :Plu { - if (this.pluId) return Plu.find(this.pluId); + let _plu :Plu; + if (this.pluId) Plu.find(this.pluId, (plu)=> { + _plu = plu; + }).catch((err)=> { + console.warn(`Charge#plu ${this.pluId} ${err.message}`); + }); + return _plu; } set plu(plu :Plu) { this.pluId = plu.id; } get taxGroup() { - if (this.taxGroupId) return TaxGroup.find(this.taxGroupId); + let _taxGroup :TaxGroup; + if (this.taxGroupId) TaxGroup.find(this.taxGroupId, (taxGroup)=> { + _taxGroup = taxGroup; + }).catch((err)=> { + console.warn(`Charge#taxGroup ${this.taxGroupId} ${err.message}`); + }); + return _taxGroup; } set taxGroup(taxGroup :TaxGroup) { this.taxGroupId = taxGroup.id; } get department() { - if (this.departmentId) return Department.find(this.departmentId); + let _department :Department; + if (this.departmentId) Department.find(this.departmentId, (department)=> { + _department = department; + }).catch((err)=> { + console.warn(`Charge#department ${this.departmentId} ${err.message}`); + }); + return _department; } set department(department :Department) { this.departmentId = department.id; @@ -222,4 +241,4 @@ Charge.validates('modifier', { invalid: (self)=> { return self.modifier && !self.modifier.isValid; }}); -export { ChargesCollection } from './collection'; \ No newline at end of file +export { ChargesCollection }; \ No newline at end of file diff --git a/src/billing/interface.ts b/src/billing/interface.ts index 8ae6ae0..fa6089e 100644 --- a/src/billing/interface.ts +++ b/src/billing/interface.ts @@ -1,3 +1,8 @@ +// Copyright (c) 2016 AlexV +// +// This software is released under the MIT License. +// http://opensource.org/licenses/mit-license.php + import * as NObjects from './nomenclature'; export interface IBillAttributes { diff --git a/src/billing/modifier/index.ts b/src/billing/modifier/index.ts index 7bb7675..84ee610 100644 --- a/src/billing/modifier/index.ts +++ b/src/billing/modifier/index.ts @@ -6,6 +6,7 @@ import { BillItem } from '../concerns/billItem'; import { Charge } from '../charge'; import { IModifierAttributes } from './interface'; +import { ModifiersCollection } from './collection'; /** * @@ -128,4 +129,4 @@ Modifier.validates('value', { notEqualTo: 0, } }); -export { ModifiersCollection } from './collection'; \ No newline at end of file +export { ModifiersCollection }; \ No newline at end of file diff --git a/src/billing/nomenclature/department/index.ts b/src/billing/nomenclature/department/index.ts index c79ba77..5a2fa43 100644 --- a/src/billing/nomenclature/department/index.ts +++ b/src/billing/nomenclature/department/index.ts @@ -1,3 +1,8 @@ +// Copyright (c) 2016 AlexV +// +// This software is released under the MIT License. +// http://opensource.org/licenses/mit-license.php + import { Storable } from '../../storable'; import { IDepartment } from './interface'; import { TaxGroup } from '../index'; @@ -13,7 +18,13 @@ export class Department extends Storable { } get taxGroup() :TaxGroup { - if (this.taxGroupId) return TaxGroup.find(this.taxGroupId); + let _taxGroup :TaxGroup + if (this.taxGroupId) TaxGroup.find(this.taxGroupId, (taxGroup)=> { + _taxGroup = taxGroup; + }).catch((err)=> { + console.warn(`Plu#taxGroup ${this.taxGroupId} ${err.message}`); + }); + return _taxGroup; } constructor(attributes :IDepartment) { diff --git a/src/billing/nomenclature/department/interface.ts b/src/billing/nomenclature/department/interface.ts index 91301b3..0c2f9da 100644 --- a/src/billing/nomenclature/department/interface.ts +++ b/src/billing/nomenclature/department/interface.ts @@ -1,3 +1,8 @@ +// Copyright (c) 2016 AlexV +// +// This software is released under the MIT License. +// http://opensource.org/licenses/mit-license.php + import { IStoreRecord, IStoreConfig } from '../../storable/interface'; export declare type TDepartmentConfig = Array | IStoreConfig; diff --git a/src/billing/nomenclature/interface.ts b/src/billing/nomenclature/interface.ts index 3c0579b..74cf107 100644 --- a/src/billing/nomenclature/interface.ts +++ b/src/billing/nomenclature/interface.ts @@ -1,3 +1,8 @@ +// Copyright (c) 2016 AlexV +// +// This software is released under the MIT License. +// http://opensource.org/licenses/mit-license.php + import { TOperatorsConfig } from './operator/interface'; import { TTaxGroupConfig } from './taxGroup/interface'; import { TPaymentTypeConfig } from './paymentType/interface'; diff --git a/src/billing/nomenclature/nomenclature.spec.ts b/src/billing/nomenclature/nomenclature.spec.ts index 6781091..572f9f6 100644 --- a/src/billing/nomenclature/nomenclature.spec.ts +++ b/src/billing/nomenclature/nomenclature.spec.ts @@ -6,7 +6,7 @@ /// import * as Nomenclature from './index'; -import { MemoryStore } from '../store'; +import { MemoryStore } from '../storable'; describe('Nomenclature', ()=> { it('stores', function() { @@ -17,7 +17,8 @@ describe('Nomenclature', ()=> { departments: [], plus: [{ id: 1, code: '2', name: 'Test Plu', departmentId: 3, price: 4 }] }); - let plu = Nomenclature.Plu.find(1); + let plu :Nomenclature.Plu; + Nomenclature.Plu.find(1, (r)=> plu = r ); expect(plu instanceof Nomenclature.Plu).toBeTruthy(); expect([plu.id, plu.code, plu.name, plu.departmentId, plu.price]).toEqual([1, '2', 'Test Plu',3, 4]); }); diff --git a/src/billing/nomenclature/operator/index.ts b/src/billing/nomenclature/operator/index.ts index b1b469d..820a096 100644 --- a/src/billing/nomenclature/operator/index.ts +++ b/src/billing/nomenclature/operator/index.ts @@ -1,3 +1,8 @@ +// Copyright (c) 2016 AlexV +// +// This software is released under the MIT License. +// http://opensource.org/licenses/mit-license.php + import { IOperator } from './interface'; import { Storable } from '../../storable'; diff --git a/src/billing/nomenclature/operator/interface.ts b/src/billing/nomenclature/operator/interface.ts index 3e86e0a..d26bbd1 100644 --- a/src/billing/nomenclature/operator/interface.ts +++ b/src/billing/nomenclature/operator/interface.ts @@ -1,3 +1,8 @@ +// Copyright (c) 2016 AlexV +// +// This software is released under the MIT License. +// http://opensource.org/licenses/mit-license.php + import { IStoreRecord, IStoreConfig } from '../../storable/interface'; export declare type TOperatorsConfig = Array | IStoreConfig; diff --git a/src/billing/nomenclature/paymentType/interface.ts b/src/billing/nomenclature/paymentType/interface.ts index 6603e30..9951aad 100644 --- a/src/billing/nomenclature/paymentType/interface.ts +++ b/src/billing/nomenclature/paymentType/interface.ts @@ -1,3 +1,8 @@ +// Copyright (c) 2016 AlexV +// +// This software is released under the MIT License. +// http://opensource.org/licenses/mit-license.php + import { IStoreRecord, IStoreConfig } from '../../storable/interface'; export declare type TPaymentTypeConfig = Array | IStoreConfig; diff --git a/src/billing/nomenclature/plu/index.ts b/src/billing/nomenclature/plu/index.ts index 0cb8149..e82ea49 100644 --- a/src/billing/nomenclature/plu/index.ts +++ b/src/billing/nomenclature/plu/index.ts @@ -33,7 +33,13 @@ export class Plu extends Storable { } get department() :Department { - if (this.departmentId) return Department.find(this.departmentId); + let _departpent :Department; + if (this.departmentId) Department.find(this.departmentId, (department)=> { + _departpent = department; + }).catch((err)=> { + console.warn(`Plu#department ${this.departmentId} ${err.message}`); + }); + return _departpent; } constructor(attributes :IPlu) { diff --git a/src/billing/nomenclature/plu/interface.ts b/src/billing/nomenclature/plu/interface.ts index e26d436..9112bc5 100644 --- a/src/billing/nomenclature/plu/interface.ts +++ b/src/billing/nomenclature/plu/interface.ts @@ -1,3 +1,8 @@ +// Copyright (c) 2016 AlexV +// +// This software is released under the MIT License. +// http://opensource.org/licenses/mit-license.php + import { IStoreRecord, IStoreConfig } from '../../storable/interface'; export declare type TPluConfig = Array | IStoreConfig; diff --git a/src/billing/nomenclature/taxGroup/interface.ts b/src/billing/nomenclature/taxGroup/interface.ts index 327fe5c..5732fc1 100644 --- a/src/billing/nomenclature/taxGroup/interface.ts +++ b/src/billing/nomenclature/taxGroup/interface.ts @@ -1,3 +1,8 @@ +// Copyright (c) 2016 AlexV +// +// This software is released under the MIT License. +// http://opensource.org/licenses/mit-license.php + import { IStoreRecord, IStoreConfig } from '../../storable/interface'; export declare type TTaxGroupConfig = Array | IStoreConfig; diff --git a/src/billing/payment/index.ts b/src/billing/payment/index.ts index cfa16cd..c7a63b2 100644 --- a/src/billing/payment/index.ts +++ b/src/billing/payment/index.ts @@ -7,6 +7,7 @@ import { BillItem } from '../concerns/billItem'; import { IPaymentAttributes } from './interface'; import { PaymentType } from '../nomenclature'; +import { PaymentsCollection } from './collection'; /** * @@ -101,7 +102,13 @@ export class Payment extends BillItem { } get paymentType() { - if (this.paymentTypeId) return PaymentType.find(this.paymentTypeId); + let _paymentType :PaymentType; + if (this.paymentTypeId) PaymentType.find(this.paymentTypeId, (r)=> { + _paymentType = r; + }).catch((err)=> { + console.warn(`Payment#paymentType ${this.paymentTypeId} ${err.message}`); + });; + return _paymentType; } set paymentType(paymentType :PaymentType) { this.paymentTypeId = paymentType.id; @@ -118,4 +125,4 @@ Payment.validates('paymentType', { } }); -export { PaymentsCollection } from './collection'; \ No newline at end of file +export { PaymentsCollection }; \ No newline at end of file diff --git a/src/billing/payment/payment.spec.ts b/src/billing/payment/payment.spec.ts index c154776..9ddff40 100644 --- a/src/billing/payment/payment.spec.ts +++ b/src/billing/payment/payment.spec.ts @@ -79,11 +79,12 @@ describe('Payment', () => { expect(payment.errors.messages).toContain('Value must be greater than 0'); }); - it('non existing paymentTypeId', function() { + it('non existing paymentTypeId', function(done) { let bill = new Bill(); let payment = bill.payments.new({ paymentTypeId: 101, value: 2 }); expect(payment.isValid).toBeFalsy(); expect(payment.errors.messages).toContain('PaymentType is not included in the list'); + done(); }); }); @@ -115,9 +116,12 @@ describe('Payment', () => { it('set/update nomenclature direct', function() { let payment = new Payment(); - payment.paymentType = Nomenclature.PaymentType.find(1); + let p: Nomenclature.PaymentType; + Nomenclature.PaymentType.find(1, (r)=> payment.paymentType = r ); expect(payment.paymentTypeId).toEqual(1); - payment.update({ paymentType: Nomenclature.PaymentType.find(2) }); + Nomenclature.PaymentType.find(2, (r)=> p = r); + payment.update({ paymentType: p }); + expect(payment.paymentTypeId).toEqual(2); }); }); }); \ No newline at end of file diff --git a/src/billing/storable/index.ts b/src/billing/storable/index.ts index b91fbfb..0bd091f 100644 --- a/src/billing/storable/index.ts +++ b/src/billing/storable/index.ts @@ -14,31 +14,92 @@ export interface IStorableClass { new (...a: any[]): T } +export class StoreCatchable { + _catchCallback :(err: any)=> any; + catch(catchCallback :(err: any)=> any) { + this._catchCallback = catchCallback; + }; + throwAsync(err :any) { + setTimeout(()=> { + if (this._catchCallback) this._catchCallback(err); + else throw err; + }, 0); + } +} + export abstract class Storable { static _store :IStore; + private _queueSize :number = 0; + private _reposeCallback; constructor(attributes :any = {}) { if (attributes.store) (this.constructor).initStore(attributes.store); } - static find(this: IStorableClass, id: number) :T { - if (!this._store) return; - let record = this._store.get(id); - if (record) return new this(record); + incQueue() { + this._queueSize = this._queueSize + 1; + } + decQueue() { + this._queueSize = this._queueSize - 1; + if (!this._queueSize && this._reposeCallback) this._reposeCallback(); + } + + repose(reposeCallback :() => any) { + if (!this._queueSize) reposeCallback(); + else this._reposeCallback = reposeCallback; + } + + static find(this: IStorableClass, id: number, callback :(item: T) => any) :StoreCatchable { + let catchable = new StoreCatchable(); + if (!this._store) { + let className = (this).name; + catchable.throwAsync(new Error(`${className} store is not configured!`)); + } else { + this._store.findById(id, (err, record)=> { + if (err) catchable.throwAsync(err); + else if (!record) catchable.throwAsync(new Error('Not Found')); + else callback(new this(record)); + }); + } + return catchable; } - static all(this: IStorableClass) :Array { - if (!this._store) return; - let records = this._store.query(); - return records.map((record) => { - return new this(record); - }); + static findOne(this: IStorableClass, conditions: any, callback :(item: T) => any) :StoreCatchable { + let catchable = new StoreCatchable(); + if (!this._store) { + let className = (this).name; + catchable.throwAsync(new Error(`${className} store is not configured!`)); + } else { + this._store.findOne(conditions, (err, record)=> { + if (err) catchable.throwAsync(err); + else if (!record) catchable.throwAsync(new Error('Not Found')); + else callback(new this(record)); + }); + } + return catchable; } - static initStore(config :ArrayOrStoreConfig) { + static all(this: IStorableClass, callback: (item: Array) => any) :StoreCatchable { + let catchable = new StoreCatchable(); + if (!this._store) { + let className = (this).name; + catchable.throwAsync(new Error(`${className} store is not configured!`)); + } else { + this._store.find({}, (err, records)=> { + if (err) { + catchable.throwAsync(err); + } else callback(records.map((record)=> { + return new this(record); + })); + }); + } + return catchable; + } + + static initStore(config :ArrayOrStoreConfig | any) { if (config instanceof Array) { this._store = new MemoryStore(config); - } + } else this._store = config; } } diff --git a/src/billing/storable/interface.ts b/src/billing/storable/interface.ts index 2d0f28a..4fcd0c3 100644 --- a/src/billing/storable/interface.ts +++ b/src/billing/storable/interface.ts @@ -7,6 +7,7 @@ export interface IStoreConfig { } export interface IStore { - get(id :number) :IStoreRecord; - query(filter ?:any) :Array; + findById(id :number, callback :any); + find(conditions :any, callback :any); + findOne(conditions :any, callback :any); } diff --git a/src/billing/storable/memoryStore.ts b/src/billing/storable/memoryStore.ts index de4ae9c..21f2c82 100644 --- a/src/billing/storable/memoryStore.ts +++ b/src/billing/storable/memoryStore.ts @@ -12,13 +12,21 @@ export class MemoryStore implements IStore { this._items = items; } - get(id :number) { + findById(id: number, callback: any) { for (let i of this._items) { - if (i.id === id) return i; + if (i.id === id) { + return callback(undefined, i); + } } + return callback(new Error('Not Found')); } - query(filter :any) { - return this._items; + findOne(conditions: any, callback: any) { + if (this._items.length > 0) return callback(undefined, this._items[0]); + else return callback(new Error('Not Found')); + } + + find(conditions :any, callback :any) { + return callback(undefined, this._items); } } \ No newline at end of file diff --git a/src/billing/storable/store.spec.ts b/src/billing/storable/store.spec.ts index 1ec3c43..80579eb 100644 --- a/src/billing/storable/store.spec.ts +++ b/src/billing/storable/store.spec.ts @@ -18,30 +18,54 @@ class TestClass extends Storable { describe('Storable', ()=> { it('attach to a model', function() { let testClass = new TestClass({ store: [{ id: 100, property: 'works' }] }); - let test = TestClass.find(100); + let test :TestClass; + TestClass.find(100, (r)=> test = r); expect(test instanceof TestClass).toBeTruthy(); expect(test.property).toEqual('works'); }); - it('find', function() { + it('find', (done)=> { new TestClass({ store: [ { id: 100, property: 'One' }, { id: 101, property: 'Two' } ]}); - expect(TestClass.find(99)).toBeUndefined(); - let item = TestClass.find(100); + let item :TestClass; + TestClass.find(100, (r)=> item = r); expect(item instanceof TestClass).toBeTruthy(); expect(item.property).toEqual('One'); - item = TestClass.find(101); + TestClass.find(101, (r)=> item = r); expect(item.property).toEqual('Two'); + done(); }); - it('all', function() { + it('find non existing catch', (done)=> { new TestClass({ store: [ { id: 100, property: 'One' }, { id: 101, property: 'Two' } ]}); - let items = TestClass.all(); + let item :TestClass; + TestClass.find(99, (r)=> item = r).catch((err)=> { + expect(err).toEqual(new Error('Not Found')); + done(); + }); + expect(item).toBeUndefined(); + }) + + it('find catchable', ()=> { + new TestClass({ store: [ + { id: 1, property: 'One' } + ]}); + let catchable = TestClass.find(1,()=>{}); + expect(catchable.catch).toBeDefined(); + }); + + it('all', ()=> { + new TestClass({ store: [ + { id: 100, property: 'One' }, + { id: 101, property: 'Two' } + ]}); + let items :any + TestClass.all((rs)=> items = rs); expect(items.length).toEqual(2); expect((items[0]).property).toEqual('One'); expect((items[1]).property).toEqual('Two'); diff --git a/src/index.ts b/src/index.ts index 4a3051f..f6ac997 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,6 +9,7 @@ import { Charge } from './billing/charge'; import { Modifier } from './billing/modifier'; import { Payment } from './billing/payment'; import * as Nomenclature from './billing/nomenclature'; +import { Storable } from './billing/storable'; export { Billing, @@ -16,7 +17,8 @@ export { Charge as BillingCharge, Modifier as BillingModifier, Payment as BillingPayment, - Nomenclature as BillingNomenclature + Nomenclature as BillingNomenclature, + Storable as BillingStorable } export default Billing; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 12de650..d18efb9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,9 +3,6 @@ "module": "commonjs", "target": "es5", "sourceMap": true, - "types": [ - "jasmine" - ], "outDir": "./lib", "declaration": false }, @@ -14,5 +11,9 @@ ], "files": [ "src/index.ts" - ] + ], + "awesomeTypescriptLoaderOptions": { + "resolveGlobs": true, + "forkChecker": true + } } \ No newline at end of file diff --git a/typings.json b/typings.json index 69dd9dc..7da31ca 100644 --- a/typings.json +++ b/typings.json @@ -2,6 +2,6 @@ "globalDependencies": { "core-js": "registry:dt/core-js#0.0.0+20160725163759", "jasmine": "registry:dt/jasmine#2.2.0+20160621224255", - "node": "registry:dt/node#6.0.0+20160831021119" + "node": "registry:dt/node#6.0.0+20160909174046" } -} \ No newline at end of file +} diff --git a/webpack.config.js b/webpack.config.js index 5110a59..1293a7f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -3,6 +3,9 @@ // This software is released under the MIT License. // http://opensource.org/licenses/mit-license.php +var webpack = require('webpack'); +var ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin; + module.exports = { devtool: 'source-map', context: __dirname + "/src", @@ -22,12 +25,20 @@ module.exports = { }, module: { loaders: [ - { - test: /\.ts$/, - loaders: ['ts'] - } + { test: /\.ts$/, loader: 'awesome-typescript' } ] }, + plugins: [ + new ForkCheckerPlugin(), + new webpack.optimize.OccurenceOrderPlugin(true), + new webpack.NoErrorsPlugin(), + new webpack.optimize.DedupePlugin(), + new webpack.optimize.UglifyJsPlugin({ + mangle: { + keep_fnames: true + } + }) + ], externals: { "billing": "BillingJs" }