Skip to content

Commit 6038ce8

Browse files
committed
feat(#23): Support for tree shaking with AoT
1 parent e47c628 commit 6038ce8

File tree

12 files changed

+99
-233
lines changed

12 files changed

+99
-233
lines changed

gulpfile.js

+4-20
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,9 @@
11
const gulp = require('gulp');
2-
const tsc = require('gulp-typescript');
3-
const sourcemaps = require('gulp-sourcemaps');
4-
const merge = require('merge2');
52
const clean = require('gulp-clean');
6-
const tsProject = tsc.createProject('tsconfig.json');
73

84
gulp.task('clean', () => {
9-
return gulp.src(['./src/**/*.d.ts', './src/**/*.js', './src/**/*.js', './src/**/*.js.map'])
10-
.pipe(clean());
11-
});
12-
13-
gulp.task('release', ['clean'], () => {
14-
const tsResult = gulp.src(['./src/**/*.ts', '!./src/**/*.spec.ts'])
15-
.pipe(sourcemaps.init())
16-
.pipe(tsProject());
17-
18-
return merge([
19-
tsResult.js
20-
.pipe(sourcemaps.write('.'))
21-
.pipe(gulp.dest('./src')),
22-
tsResult.dts
23-
.pipe(gulp.dest('./src'))
24-
]);
5+
return gulp.src([
6+
'./src/**/*.d.ts', './src/**/*.js', './src/**/*.js.map', './src/**/*.metadata.json',
7+
'./src/**/*.ngsummary.json','./src/**/*.ngfactory.ts'
8+
]).pipe(clean());
259
});

package.json

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"name": "ngx-pipes",
3-
"version": "1.3.3",
3+
"version": "1.4.0",
44
"author": "Dan Revah",
55
"description": "Useful angular2 pipes",
66
"license": "MIT",
77
"angular-cli": {},
88
"scripts": {
99
"start": "ng serve",
10-
"lint": "tslint \"src/**/*.ts\"",
11-
"test": "ng test"
10+
"test": "ng test",
11+
"build:js": "ngc -p tsconfig.json"
1212
},
1313
"main": "src/app/index.js",
1414
"keywords": [
@@ -47,15 +47,13 @@
4747
"coveralls": "^2.11.15",
4848
"gulp": "^3.9.1",
4949
"gulp-clean": "^0.3.2",
50-
"gulp-typescript": "^3.1.4",
5150
"jasmine-core": "2.4.1",
5251
"jasmine-spec-reporter": "2.5.0",
5352
"karma": "1.2.0",
5453
"karma-chrome-launcher": "^2.0.0",
5554
"karma-cli": "^1.0.1",
5655
"karma-jasmine": "^1.0.2",
5756
"karma-remap-istanbul": "^0.2.1",
58-
"merge2": "^1.0.3",
5957
"rxjs": "5.0.0-beta.12",
6058
"ts-helpers": "^1.1.1",
6159
"ts-node": "1.2.1",

src/app/pipes.module.ts

-6
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,3 @@ import {NgBooleanPipesModule} from './pipes/boolean';
1111
exports: [NgArrayPipesModule, NgStringPipesModule, NgMathPipesModule, NgBooleanPipesModule, NgObjectPipesModule]
1212
})
1313
export class NgPipesModule {}
14-
15-
export * from './pipes/array';
16-
export * from './pipes/object';
17-
export * from './pipes/string';
18-
export * from './pipes/math';
19-
export * from './pipes/boolean';

src/app/pipes/array/flatten.spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ describe('FlattenPipe', () => {
1616
});
1717

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

24-
it('should shallow flatten array', () => {
25-
let deepArray = [1,2,3,[4,5,6,[7,8,9],[10,11,12,13,[14],[15],[16, [17]]]]];
26-
let result = pipe.transform(deepArray, true);
27-
expect(result).toEqual([1,2,3,4,5,6,[7,8,9],[10,11,12,13,[14],[15],[16, [17]]]]);
24+
it('should shallow flatten array', () => {
25+
let deepArray = [1, 2, 3, [4, 5, 6, [7, 8, 9], [10, 11, 12, 13, [14], [15], [16, [17]]]]];
26+
let result = pipe.transform(deepArray, true);
27+
expect(result).toEqual([1, 2, 3, 4, 5, 6, [7, 8, 9], [10, 11, 12, 13, [14], [15], [16, [17]]]]);
2828
});
2929
});

src/app/pipes/array/index.ts

+19-18
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import {SomePipe} from './some';
1515
import {SamplePipe} from './sample';
1616
import {GroupByPipe} from './group-by';
1717
import {FilterByPipe} from './filter-by';
18-
import {NgModule} from '@angular/core';
1918
import {OrderByPipe} from './order-by';
19+
import {NgModule} from '@angular/core';
2020

2121
const ARRAY_PIPES = [
2222
DiffPipe, FlattenPipe, InitialPipe, IntersectionPipe, ReversePipe, TailPipe,
@@ -32,20 +32,21 @@ const ARRAY_PIPES = [
3232
export class NgArrayPipesModule {
3333
}
3434

35-
export * from './diff';
36-
export * from './initial';
37-
export * from './flatten';
38-
export * from './intersection';
39-
export * from './reverse';
40-
export * from './tail';
41-
export * from './truthify';
42-
export * from './union';
43-
export * from './unique';
44-
export * from './without';
45-
export * from './pluck';
46-
export * from './shuffle';
47-
export * from './every';
48-
export * from './some';
49-
export * from './sample';
50-
export * from './group-by';
51-
export * from './filter-by';
35+
export {DiffPipe} from './diff';
36+
export {InitialPipe} from './initial';
37+
export {FlattenPipe} from './flatten';
38+
export {IntersectionPipe} from './intersection';
39+
export {ReversePipe} from './reverse';
40+
export {TailPipe} from './tail';
41+
export {TrurthifyPipe} from './truthify';
42+
export {UnionPipe} from './union';
43+
export {UniquePipe} from './unique';
44+
export {WithoutPipe} from './without';
45+
export {PluckPipe} from './pluck';
46+
export {ShufflePipe} from './shuffle';
47+
export {EveryPipe} from './every';
48+
export {SomePipe} from './some';
49+
export {SamplePipe} from './sample';
50+
export {GroupByPipe} from './group-by';
51+
export {FilterByPipe} from './filter-by';
52+
export {OrderByPipe} from './order-by';

src/app/pipes/boolean/index.ts

+16-16
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ export const BOOLEAN_PIPES = [
3030
})
3131
export class NgBooleanPipesModule {}
3232

33-
export * from './is-defined';
34-
export * from './is-null';
35-
export * from './is-undefined';
36-
export * from './is-string';
37-
export * from './is-function';
38-
export * from './is-number';
39-
export * from './is-array';
40-
export * from './is-object';
41-
export * from './is-greater-equal-than';
42-
export * from './is-greater-than';
43-
export * from './is-less-equal-than';
44-
export * from './is-equal-to';
45-
export * from './is-not-equal-to';
46-
export * from './is-identical-to';
47-
export * from './is-not-identical-to';
48-
export * from './is-less-than';
33+
export {IsDefinedPipe} from './is-defined';
34+
export {IsNullPipe} from './is-null';
35+
export {IsUndefinedPipe} from './is-undefined';
36+
export {IsStringPipe} from './is-string';
37+
export {IsFunctionPipe} from './is-function';
38+
export {IsNumberPipe} from './is-number';
39+
export {IsArrayPipe} from './is-array';
40+
export {IsObjectPipe} from './is-object';
41+
export {IsGreaterEqualThanPipe} from './is-greater-equal-than';
42+
export {IsGreaterThanPipe} from './is-greater-than';
43+
export {IsLessEqualThanPipe} from './is-less-equal-than';
44+
export {IsEqualToPipe} from './is-equal-to';
45+
export {IsNotEqualToPipe} from './is-not-equal-to';
46+
export {IsIdenticalToPipe} from './is-identical-to';
47+
export {IsNotIdenticalToPipe} from './is-not-identical-to';
48+
export {IsLessThanPipe} from './is-less-than';

src/app/pipes/helpers/helpers.spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
import {extractDeepPropertyByMapKey} from './helpers';
3+
34
describe('Utils Tests', () => {
45

56
it('should extract properties properly', () => {

src/app/pipes/math/index.ts

+11-12
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,14 @@ export const MATH_PIPES = [
2424
})
2525
export class NgMathPipesModule {}
2626

27-
export * from './max';
28-
export * from './min';
29-
export * from './percentage';
30-
export * from './sum';
31-
export * from './floor';
32-
export * from './round';
33-
export * from './sqrt';
34-
export * from './pow';
35-
export * from './ceil';
36-
export * from './degrees';
37-
export * from './bytes';
38-
export * from './radians';
27+
export {MaxPipe} from './max';
28+
export {MinPipe} from './min';
29+
export {PercentagePipe} from './percentage';
30+
export {SumPipe} from './sum';
31+
export {FloorPipe} from './floor';
32+
export {RoundPipe} from './round';
33+
export {SqrtPipe} from './sqrt';
34+
export {PowerPipe} from './pow';
35+
export {CeilPipe} from './ceil';
36+
export {DegreesPipe} from './degrees';
37+
export {BytesPipe} from './bytes';

src/app/pipes/object/index.ts

+17-16
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { KeysPipe } from './keys';
2-
import { ValuesPipe } from './values';
3-
import { PairsPipe } from './pairs';
4-
import { PickPipe } from './pick';
5-
import { OmitPipe } from './omit';
6-
import { InvertPipe } from './invert';
7-
import { InvertByPipe } from './invert-by';
8-
import { NgModule } from '@angular/core';
1+
import {KeysPipe} from './keys';
2+
import {ValuesPipe} from './values';
3+
import {PairsPipe} from './pairs';
4+
import {PickPipe} from './pick';
5+
import {OmitPipe} from './omit';
6+
import {InvertPipe} from './invert';
7+
import {InvertByPipe} from './invert-by';
8+
import {NgModule} from '@angular/core';
99

1010
const OBJECT_PIPES = [
1111
KeysPipe, ValuesPipe, PairsPipe, PickPipe, InvertPipe, InvertByPipe,
@@ -17,12 +17,13 @@ const OBJECT_PIPES = [
1717
imports: [],
1818
exports: OBJECT_PIPES
1919
})
20-
export class NgObjectPipesModule {}
20+
export class NgObjectPipesModule {
21+
}
2122

22-
export * from './keys';
23-
export * from './values';
24-
export * from './pairs';
25-
export * from './pick';
26-
export * from './omit';
27-
export * from './invert';
28-
export * from './invert-by';
23+
export {KeysPipe} from './keys';
24+
export {ValuesPipe} from './values';
25+
export {PairsPipe} from './pairs';
26+
export {PickPipe} from './pick';
27+
export {OmitPipe} from './omit';
28+
export {InvertPipe} from './invert';
29+
export {InvertByPipe} from './invert-by';

src/app/pipes/string/index.ts

+18-18
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,21 @@ export const STRING_PIPES = [
3232
})
3333
export class NgStringPipesModule {}
3434

35-
export * from './ucwords';
36-
export * from './ltrim';
37-
export * from './repeat';
38-
export * from './rtrim';
39-
export * from './scan';
40-
export * from './shorten';
41-
export * from './strip-tags';
42-
export * from './trim';
43-
export * from './ucfirst';
44-
export * from './slugify';
45-
export * from './camelize';
46-
export * from './latinise';
47-
export * from './lines';
48-
export * from './underscore';
49-
export * from './match';
50-
export * from './test';
51-
export * from './lpad';
52-
export * from './rpad';
35+
export {UcWordsPipe} from './ucwords';
36+
export {LeftTrimPipe} from './ltrim';
37+
export {RepeatPipe} from './repeat';
38+
export {RightTrimPipe} from './rtrim';
39+
export {ScanPipe} from './scan';
40+
export {ShortenPipe} from './shorten';
41+
export {StripTagsPipe} from './strip-tags';
42+
export {TrimPipe} from './trim';
43+
export {UcFirstPipe} from './ucfirst';
44+
export {SlugifyPipe} from './slugify';
45+
export {CamelizePipe} from './camelize';
46+
export {LatinisePipe} from './latinise';
47+
export {LinesPipe} from './lines';
48+
export {UnderscorePipe} from './underscore';
49+
export {MatchPipe} from './match';
50+
export {TestPipe} from './test';
51+
export {LeftPadPipe} from './lpad';
52+
export {RightPadPipe} from './rpad';

tsconfig.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@
1313
]
1414
},
1515
"include": [
16-
"src/app/pipes.module.ts"
16+
"src/app/pipes.module.ts",
17+
"src/app/index.ts",
18+
"index.ts"
1719
],
1820
"exclude": [
1921
"node_modules",
2022
"**/*.spec.ts"
2123
],
2224
"angularCompilerOptions": {
23-
"genDir": "compiled"
25+
"strictMetadataEmit": true
2426
}
2527
}

0 commit comments

Comments
 (0)