Skip to content

Commit

Permalink
feat(#23): Support for tree shaking with AoT
Browse files Browse the repository at this point in the history
  • Loading branch information
danrevah committed Feb 6, 2017
1 parent e47c628 commit 6038ce8
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 233 deletions.
24 changes: 4 additions & 20 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
const gulp = require('gulp');
const tsc = require('gulp-typescript');
const sourcemaps = require('gulp-sourcemaps');
const merge = require('merge2');
const clean = require('gulp-clean');
const tsProject = tsc.createProject('tsconfig.json');

gulp.task('clean', () => {
return gulp.src(['./src/**/*.d.ts', './src/**/*.js', './src/**/*.js', './src/**/*.js.map'])
.pipe(clean());
});

gulp.task('release', ['clean'], () => {
const tsResult = gulp.src(['./src/**/*.ts', '!./src/**/*.spec.ts'])
.pipe(sourcemaps.init())
.pipe(tsProject());

return merge([
tsResult.js
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./src')),
tsResult.dts
.pipe(gulp.dest('./src'))
]);
return gulp.src([
'./src/**/*.d.ts', './src/**/*.js', './src/**/*.js.map', './src/**/*.metadata.json',
'./src/**/*.ngsummary.json','./src/**/*.ngfactory.ts'
]).pipe(clean());
});
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "ngx-pipes",
"version": "1.3.3",
"version": "1.4.0",
"author": "Dan Revah",
"description": "Useful angular2 pipes",
"license": "MIT",
"angular-cli": {},
"scripts": {
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test"
"test": "ng test",
"build:js": "ngc -p tsconfig.json"
},
"main": "src/app/index.js",
"keywords": [
Expand Down Expand Up @@ -47,15 +47,13 @@
"coveralls": "^2.11.15",
"gulp": "^3.9.1",
"gulp-clean": "^0.3.2",
"gulp-typescript": "^3.1.4",
"jasmine-core": "2.4.1",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"merge2": "^1.0.3",
"rxjs": "5.0.0-beta.12",
"ts-helpers": "^1.1.1",
"ts-node": "1.2.1",
Expand Down
6 changes: 0 additions & 6 deletions src/app/pipes.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,3 @@ import {NgBooleanPipesModule} from './pipes/boolean';
exports: [NgArrayPipesModule, NgStringPipesModule, NgMathPipesModule, NgBooleanPipesModule, NgObjectPipesModule]
})
export class NgPipesModule {}

export * from './pipes/array';
export * from './pipes/object';
export * from './pipes/string';
export * from './pipes/math';
export * from './pipes/boolean';
12 changes: 6 additions & 6 deletions src/app/pipes/array/flatten.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ describe('FlattenPipe', () => {
});

it('should deep flatten array', () => {
let deepArray = [1,2,3,[4,5,6,[7,8,9],[10,11,12,13,[14],[15],[16, [17]]]]];
let deepArray = [1, 2, 3, [4, 5, 6, [7, 8, 9], [10, 11, 12, 13, [14], [15], [16, [17]]]]];
let result = pipe.transform(deepArray);
expect(result).toEqual([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]);
expect(result).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]);
});

it('should shallow flatten array', () => {
let deepArray = [1,2,3,[4,5,6,[7,8,9],[10,11,12,13,[14],[15],[16, [17]]]]];
let result = pipe.transform(deepArray, true);
expect(result).toEqual([1,2,3,4,5,6,[7,8,9],[10,11,12,13,[14],[15],[16, [17]]]]);
it('should shallow flatten array', () => {
let deepArray = [1, 2, 3, [4, 5, 6, [7, 8, 9], [10, 11, 12, 13, [14], [15], [16, [17]]]]];
let result = pipe.transform(deepArray, true);
expect(result).toEqual([1, 2, 3, 4, 5, 6, [7, 8, 9], [10, 11, 12, 13, [14], [15], [16, [17]]]]);
});
});
37 changes: 19 additions & 18 deletions src/app/pipes/array/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import {SomePipe} from './some';
import {SamplePipe} from './sample';
import {GroupByPipe} from './group-by';
import {FilterByPipe} from './filter-by';
import {NgModule} from '@angular/core';
import {OrderByPipe} from './order-by';
import {NgModule} from '@angular/core';

const ARRAY_PIPES = [
DiffPipe, FlattenPipe, InitialPipe, IntersectionPipe, ReversePipe, TailPipe,
Expand All @@ -32,20 +32,21 @@ const ARRAY_PIPES = [
export class NgArrayPipesModule {
}

export * from './diff';
export * from './initial';
export * from './flatten';
export * from './intersection';
export * from './reverse';
export * from './tail';
export * from './truthify';
export * from './union';
export * from './unique';
export * from './without';
export * from './pluck';
export * from './shuffle';
export * from './every';
export * from './some';
export * from './sample';
export * from './group-by';
export * from './filter-by';
export {DiffPipe} from './diff';
export {InitialPipe} from './initial';
export {FlattenPipe} from './flatten';
export {IntersectionPipe} from './intersection';
export {ReversePipe} from './reverse';
export {TailPipe} from './tail';
export {TrurthifyPipe} from './truthify';
export {UnionPipe} from './union';
export {UniquePipe} from './unique';
export {WithoutPipe} from './without';
export {PluckPipe} from './pluck';
export {ShufflePipe} from './shuffle';
export {EveryPipe} from './every';
export {SomePipe} from './some';
export {SamplePipe} from './sample';
export {GroupByPipe} from './group-by';
export {FilterByPipe} from './filter-by';
export {OrderByPipe} from './order-by';
32 changes: 16 additions & 16 deletions src/app/pipes/boolean/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ export const BOOLEAN_PIPES = [
})
export class NgBooleanPipesModule {}

export * from './is-defined';
export * from './is-null';
export * from './is-undefined';
export * from './is-string';
export * from './is-function';
export * from './is-number';
export * from './is-array';
export * from './is-object';
export * from './is-greater-equal-than';
export * from './is-greater-than';
export * from './is-less-equal-than';
export * from './is-equal-to';
export * from './is-not-equal-to';
export * from './is-identical-to';
export * from './is-not-identical-to';
export * from './is-less-than';
export {IsDefinedPipe} from './is-defined';
export {IsNullPipe} from './is-null';
export {IsUndefinedPipe} from './is-undefined';
export {IsStringPipe} from './is-string';
export {IsFunctionPipe} from './is-function';
export {IsNumberPipe} from './is-number';
export {IsArrayPipe} from './is-array';
export {IsObjectPipe} from './is-object';
export {IsGreaterEqualThanPipe} from './is-greater-equal-than';
export {IsGreaterThanPipe} from './is-greater-than';
export {IsLessEqualThanPipe} from './is-less-equal-than';
export {IsEqualToPipe} from './is-equal-to';
export {IsNotEqualToPipe} from './is-not-equal-to';
export {IsIdenticalToPipe} from './is-identical-to';
export {IsNotIdenticalToPipe} from './is-not-identical-to';
export {IsLessThanPipe} from './is-less-than';
1 change: 1 addition & 0 deletions src/app/pipes/helpers/helpers.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import {extractDeepPropertyByMapKey} from './helpers';

describe('Utils Tests', () => {

it('should extract properties properly', () => {
Expand Down
23 changes: 11 additions & 12 deletions src/app/pipes/math/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ export const MATH_PIPES = [
})
export class NgMathPipesModule {}

export * from './max';
export * from './min';
export * from './percentage';
export * from './sum';
export * from './floor';
export * from './round';
export * from './sqrt';
export * from './pow';
export * from './ceil';
export * from './degrees';
export * from './bytes';
export * from './radians';
export {MaxPipe} from './max';
export {MinPipe} from './min';
export {PercentagePipe} from './percentage';
export {SumPipe} from './sum';
export {FloorPipe} from './floor';
export {RoundPipe} from './round';
export {SqrtPipe} from './sqrt';
export {PowerPipe} from './pow';
export {CeilPipe} from './ceil';
export {DegreesPipe} from './degrees';
export {BytesPipe} from './bytes';
33 changes: 17 additions & 16 deletions src/app/pipes/object/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { KeysPipe } from './keys';
import { ValuesPipe } from './values';
import { PairsPipe } from './pairs';
import { PickPipe } from './pick';
import { OmitPipe } from './omit';
import { InvertPipe } from './invert';
import { InvertByPipe } from './invert-by';
import { NgModule } from '@angular/core';
import {KeysPipe} from './keys';
import {ValuesPipe} from './values';
import {PairsPipe} from './pairs';
import {PickPipe} from './pick';
import {OmitPipe} from './omit';
import {InvertPipe} from './invert';
import {InvertByPipe} from './invert-by';
import {NgModule} from '@angular/core';

const OBJECT_PIPES = [
KeysPipe, ValuesPipe, PairsPipe, PickPipe, InvertPipe, InvertByPipe,
Expand All @@ -17,12 +17,13 @@ const OBJECT_PIPES = [
imports: [],
exports: OBJECT_PIPES
})
export class NgObjectPipesModule {}
export class NgObjectPipesModule {
}

export * from './keys';
export * from './values';
export * from './pairs';
export * from './pick';
export * from './omit';
export * from './invert';
export * from './invert-by';
export {KeysPipe} from './keys';
export {ValuesPipe} from './values';
export {PairsPipe} from './pairs';
export {PickPipe} from './pick';
export {OmitPipe} from './omit';
export {InvertPipe} from './invert';
export {InvertByPipe} from './invert-by';
36 changes: 18 additions & 18 deletions src/app/pipes/string/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ export const STRING_PIPES = [
})
export class NgStringPipesModule {}

export * from './ucwords';
export * from './ltrim';
export * from './repeat';
export * from './rtrim';
export * from './scan';
export * from './shorten';
export * from './strip-tags';
export * from './trim';
export * from './ucfirst';
export * from './slugify';
export * from './camelize';
export * from './latinise';
export * from './lines';
export * from './underscore';
export * from './match';
export * from './test';
export * from './lpad';
export * from './rpad';
export {UcWordsPipe} from './ucwords';
export {LeftTrimPipe} from './ltrim';
export {RepeatPipe} from './repeat';
export {RightTrimPipe} from './rtrim';
export {ScanPipe} from './scan';
export {ShortenPipe} from './shorten';
export {StripTagsPipe} from './strip-tags';
export {TrimPipe} from './trim';
export {UcFirstPipe} from './ucfirst';
export {SlugifyPipe} from './slugify';
export {CamelizePipe} from './camelize';
export {LatinisePipe} from './latinise';
export {LinesPipe} from './lines';
export {UnderscorePipe} from './underscore';
export {MatchPipe} from './match';
export {TestPipe} from './test';
export {LeftPadPipe} from './lpad';
export {RightPadPipe} from './rpad';
6 changes: 4 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
]
},
"include": [
"src/app/pipes.module.ts"
"src/app/pipes.module.ts",
"src/app/index.ts",
"index.ts"
],
"exclude": [
"node_modules",
"**/*.spec.ts"
],
"angularCompilerOptions": {
"genDir": "compiled"
"strictMetadataEmit": true
}
}
Loading

0 comments on commit 6038ce8

Please sign in to comment.