Skip to content

Commit 3e74ca5

Browse files
committed
feat(module): add index file to expose public api
1 parent 6d63f50 commit 3e74ca5

5 files changed

Lines changed: 30 additions & 14 deletions

File tree

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ Angular 2 module for saving CSV files.
1414
```
1515
import { BrowserModule } from '@angular/platform-browser';
1616
import { NgModule } from '@angular/core';
17-
import { Ng2CsvModule } from 'ng2csv/Ng2Csv.module';
17+
import { Ng2CsvModule } from 'ng2csv';
1818
import { AppComponent } from './app.component';
19-
19+
2020
@NgModule({
2121
declarations: [
2222
AppComponent
@@ -33,8 +33,8 @@ Angular 2 module for saving CSV files.
3333
3. Inject the `Ng2CsvService` into your component:
3434
```
3535
import { Component } from '@angular/core';
36-
import { Ng2CsvService } from 'ng2csv/Ng2Csv.service';
37-
36+
import { Ng2CsvService } from 'ng2csv';
37+
3838
@Component({
3939
selector: 'app-root',
4040
templateUrl: './app.component.html',
@@ -43,7 +43,7 @@ Angular 2 module for saving CSV files.
4343
})
4444
export class AppComponent {
4545
public constructor(private ng2Csv: Ng2CsvService) {}
46-
46+
4747
public download(): void {
4848
this.ng2Csv.download([
4949
{
@@ -69,14 +69,14 @@ Unless specified, an automatic mapping is used from the data to columns. It does
6969
### Row headers and ordering
7070
You can output a subset of the data's properties to CSV by defining your own custom mapping. This allows you to specify the order columns are written in and what value is written for each row in each column.
7171
```
72-
import { OrderedProjectionCsvRowMapper } from 'ng2csv/OrderedProjectionCsvRowMapper';
72+
import { OrderedProjectionCsvRowMapper } from 'ng2csv';
7373
// ...
7474
const rowMapper = new OrderedProjectionCsvRowMapper<MyType>([
7575
['First Name', x => x.Name],
7676
['Identifier', x => 'N' + x.Id.toString()]
7777
]);
7878
this.ng2Csv.download(myData, 'file.csv', rowMapper);
79-
/*
79+
/*
8080
Generates CSV:
8181
"First Name","Identifier"
8282
Alice,N1
@@ -87,7 +87,7 @@ this.ng2Csv.download(myData, 'file.csv', rowMapper);
8787
### Delimiters, header row
8888
You can control what character is used to separate columns (e.g. to use ';' or tab separators rather than ',') and whether to include a header row.
8989
```
90-
import { CsvConfiguration } from 'ng2csv/CsvConfiguration';
90+
import { CsvConfiguration } from 'ng2csv';
9191
// ...
9292
const csvConfig = new CsvConfiguration();
9393
csvConfig.delimiter = '\t';

package.json

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
"version": "0.2.0",
44
"description": "Angular2 module for saving CSV files.",
55
"main": "Ng2Csv.bundle.js",
6-
"module": "Ng2Csv.module.js",
7-
"jsnext:main": "Ng2Csv.module.js",
8-
"types": "Ng2Csv.module.d.ts",
6+
"module": "index.js",
7+
"jsnext:main": "index.js",
8+
"types": "index.d.ts",
99
"scripts": {
10-
"build": "rm -rf dist && tsc -p tsconfig-esm.json && rollup -c rollup.config.js dist/Ng2Csv.module.js > dist/Ng2Csv.bundle.js && cp package.json dist && ngc && cp README.md dist && cp LICENSE.md dist",
10+
"build": "rm -rf dist && npm run lint && tsc -p tsconfig-esm.json && rollup -c rollup.config.js dist/index.js > dist/Ng2Csv.bundle.js && cp package.json dist && ngc && cp README.md dist && cp LICENSE.md dist",
1111
"test": "karma start --single-run",
1212
"lint": "tslint -c tslint.json 'src/**/*.ts' 'test/**/*.ts'",
13+
"release": "standard-version",
1314
"npmpublish": "cd dist && npm publish"
1415
},
1516
"repository": {
@@ -39,11 +40,14 @@
3940
"@angular/platform-browser": "^2.4.10",
4041
"@angular/platform-browser-dynamic": "^2.4.10",
4142
"@angular/platform-server": "^2.4.10",
43+
"@commitlint/cli": "^6.0.2",
44+
"@commitlint/config-conventional": "^6.0.2",
4245
"@types/file-saver": "0.0.1",
4346
"@types/jasmine": "^2.5.53",
4447
"@types/jsdom": "^11.0.1",
4548
"@types/node": "^8.0.13",
4649
"core-js": "^2.4.1",
50+
"cz-conventional-changelog": "^2.1.0",
4751
"file-saver": "^1.3.3",
4852
"jasmine": "^2.6.0",
4953
"jasmine-core": "^2.6.4",
@@ -57,11 +61,17 @@
5761
"karma-webpack": "^2.0.4",
5862
"rollup": "^0.45.1",
5963
"rxjs": "^5.4.2",
64+
"standard-version": "^4.3.0",
6065
"ts-loader": "^2.2.2",
6166
"ts-node": "^3.2.0",
6267
"tslint": "^5.5.0",
6368
"typescript": "^2.4.1",
6469
"webpack": "^3.2.0",
6570
"zone.js": "^0.7.2"
71+
},
72+
"config": {
73+
"commitizen": {
74+
"path": "./node_modules/cz-conventional-changelog"
75+
}
6676
}
6777
}

src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export { Ng2CsvModule } from './Ng2Csv.module';
2+
export { Ng2CsvService } from './Ng2Csv.service';
3+
export { CsvConfiguration } from './CsvConfiguration';
4+
export { ICsvRowMapper } from './ICsvRowMapper';
5+
export { AutoCsvRowMapper } from './AutoCsvRowMapper';
6+
export { OrderedProjectionCsvRowMapper } from './OrderedProjectionCsvRowMapper';

tsconfig-esm.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
"noStrictGenericChecks": true
1515
},
1616
"files": [
17-
"./src/Ng2Csv.module.ts"
17+
"./src/index.ts"
1818
]
1919
}

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"noStrictGenericChecks": true
1313
},
1414
"files": [
15-
"./src/Ng2Csv.module.ts"
15+
"./src/index.ts"
1616
],
1717
"angularCompilerOptions": {
1818
"skipTemplateCodegen": true

0 commit comments

Comments
 (0)