Skip to content

Commit

Permalink
build: use ng-packagr to generate library
Browse files Browse the repository at this point in the history
  • Loading branch information
trotyl committed Jul 5, 2018
1 parent 61dc87b commit 804cdd3
Show file tree
Hide file tree
Showing 19 changed files with 125 additions and 122 deletions.
14 changes: 14 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,20 @@
"root": "",
"sourceRoot": "",
"projectType": "application"
},
"ng-zorro-antd-lib": {
"root": "components",
"projectType": "library",
"prefix": "nz",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "components/tsconfig.lib.json",
"project": "components/ng-package.json"
}
}
}
}
},
"defaultProject": "ng-zorro-antd-doc",
Expand Down
59 changes: 0 additions & 59 deletions build.sh

This file was deleted.

2 changes: 1 addition & 1 deletion build_scripts/generate-less.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function compileLess(content, savePath, min) {
}

const sourcePath = path.resolve(__dirname, '../components');
const targetPath = path.resolve(__dirname, '../publish/src');
const targetPath = path.resolve(__dirname, '../publish');

const targetFolder = fs.readdirSync(targetPath);
let componentsLessContent = '';
Expand Down
2 changes: 1 addition & 1 deletion components/calendar/nz-calendar-header.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import * as setMonth from 'date-fns/set_month';
import setMonth from 'date-fns/set_month';
import { NzI18nService as I18n } from '../i18n/nz-i18n.service';

@Component({
Expand Down
30 changes: 15 additions & 15 deletions components/calendar/nz-calendar.component.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { coerceBooleanProperty } from '@angular/cdk/coercion';
import { forwardRef, Component, ContentChild, EventEmitter, HostBinding, Input, OnInit, Output, TemplateRef } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import * as addDays from 'date-fns/add_days';
import * as differenceInCalendarDays from 'date-fns/difference_in_calendar_days';
import * as differenceInCalendarMonths from 'date-fns/difference_in_calendar_months';
import * as differenceInCalendarWeeks from 'date-fns/difference_in_calendar_weeks';
import * as endOfMonth from 'date-fns/end_of_month';
import * as isSameDay from 'date-fns/is_same_day';
import * as isSameMonth from 'date-fns/is_same_month';
import * as isSameYear from 'date-fns/is_same_year';
import * as isThisMonth from 'date-fns/is_this_month';
import * as isThisYear from 'date-fns/is_this_year';
import * as setMonth from 'date-fns/set_month';
import * as setYear from 'date-fns/set_year';
import * as startOfMonth from 'date-fns/start_of_month';
import * as startOfWeek from 'date-fns/start_of_week';
import * as startOfYear from 'date-fns/start_of_year';
import addDays from 'date-fns/add_days';
import differenceInCalendarDays from 'date-fns/difference_in_calendar_days';
import differenceInCalendarMonths from 'date-fns/difference_in_calendar_months';
import differenceInCalendarWeeks from 'date-fns/difference_in_calendar_weeks';
import endOfMonth from 'date-fns/end_of_month';
import isSameDay from 'date-fns/is_same_day';
import isSameMonth from 'date-fns/is_same_month';
import isSameYear from 'date-fns/is_same_year';
import isThisMonth from 'date-fns/is_this_month';
import isThisYear from 'date-fns/is_this_year';
import setMonth from 'date-fns/set_month';
import setYear from 'date-fns/set_year';
import startOfMonth from 'date-fns/start_of_month';
import startOfWeek from 'date-fns/start_of_week';
import startOfYear from 'date-fns/start_of_year';
import { NzI18nService as I18n } from '../i18n/nz-i18n.service';
import { NzDateCellDirective as DateCell, NzDateFullCellDirective as DateFullCell, NzMonthCellDirective as MonthCell, NzMonthFullCellDirective as MonthFullCell } from './nz-calendar-cells';

Expand Down
2 changes: 1 addition & 1 deletion components/date-picker/date-picker.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { fakeAsync, flush, inject, tick, ComponentFixture, TestBed } from '@angu
import { FormsModule } from '@angular/forms';
import { By } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import * as isSameDay from 'date-fns/is_same_day';
import isSameDay from 'date-fns/is_same_day';

import { dispatchKeyboardEvent, dispatchMouseEvent } from '../core/testing';
import en_US from '../i18n/languages/en_US';
Expand Down
2 changes: 1 addition & 1 deletion components/date-picker/demo/basic.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component } from '@angular/core';
import * as getISOWeek from 'date-fns/get_iso_week';
import getISOWeek from 'date-fns/get_iso_week';
import { en_US, zh_CN, NzI18nService } from 'ng-zorro-antd';

@Component({
Expand Down
4 changes: 2 additions & 2 deletions components/date-picker/demo/disabled-date.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component } from '@angular/core';
import * as differenceInCalendarDays from 'date-fns/difference_in_calendar_days';
import * as setHours from 'date-fns/set_hours';
import differenceInCalendarDays from 'date-fns/difference_in_calendar_days';
import setHours from 'date-fns/set_hours';

@Component({
selector: 'nz-demo-date-picker-disabled-date',
Expand Down
2 changes: 1 addition & 1 deletion components/date-picker/demo/presetted-ranges.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component } from '@angular/core';
import * as endOfMonth from 'date-fns/end_of_month';
import endOfMonth from 'date-fns/end_of_month';

@Component({
selector: 'nz-demo-date-picker-presetted-ranges',
Expand Down
10 changes: 5 additions & 5 deletions components/date-picker/lib/candy-date/candy-date.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as addMonths from 'date-fns/add_months';
import * as addYears from 'date-fns/add_years';
import * as endOfMonth from 'date-fns/end_of_month';
import * as setDay from 'date-fns/set_day';
// import * as setYear from 'date-fns/set_year';
import addMonths from 'date-fns/add_months';
import addYears from 'date-fns/add_years';
import endOfMonth from 'date-fns/end_of_month';
import setDay from 'date-fns/set_day';
// import setYear from 'date-fns/set_year';
import { firstDayOfWeek } from './util';

/**
Expand Down
2 changes: 1 addition & 1 deletion components/date-picker/month-picker.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { FormsModule } from '@angular/forms';
import { By } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';

import * as isBefore from 'date-fns/is_before';
import isBefore from 'date-fns/is_before';
import { dispatchMouseEvent } from '../core/testing';
import { NzDatePickerModule } from './date-picker.module';
import { CandyDate } from './lib/candy-date';
Expand Down
4 changes: 2 additions & 2 deletions components/date-picker/range-picker.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { fakeAsync, inject, tick, ComponentFixture, TestBed } from '@angular/cor
import { FormsModule } from '@angular/forms';
import { By } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import * as differenceInDays from 'date-fns/difference_in_days';
import * as isSameDay from 'date-fns/is_same_day';
import differenceInDays from 'date-fns/difference_in_days';
import isSameDay from 'date-fns/is_same_day';

import { dispatchMouseEvent } from '../core/testing';
import { NzDatePickerModule } from './date-picker.module';
Expand Down
2 changes: 1 addition & 1 deletion components/i18n/nz-i18n.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { BehaviorSubject, Observable } from 'rxjs';

import { LoggerService } from '../core/util/logger/logger.service';

import * as parse from 'date-fns/parse';
import parse from 'date-fns/parse';

import zh_CN from './languages/zh_CN';
import { NzI18nInterface } from './nz-i18n.interface';
Expand Down
13 changes: 13 additions & 0 deletions components/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../publish",
"deleteDestPath": true,
"lib": {
"entryFile": "ng-zorro-antd.module.ts"
},
"whitelistedNonPeerDependencies": [
"tslib",
"angular",
"date-fns"
]
}
34 changes: 34 additions & 0 deletions components/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "ng-zorro-antd",
"version": "1.1.1",
"license": "MIT",
"description": "An enterprise-class UI components based on Ant Design and Angular",
"schematics": "./schematics/collection.json",
"keywords": [
"ant",
"design",
"angular",
"ui",
"framework",
"frontend"
],
"homepage": "https://ng.ant.design",
"repository": {
"type": "git",
"url": "https://github.com/NG-ZORRO/ng-zorro-antd"
},
"bugs": {
"url": "https://github.com/NG-ZORRO/ng-zorro-antd/issues"
},
"dependencies": {
"date-fns": "^1.29.0",
"@angular/cdk": "^6.0.0"
},
"peerDependencies": {
"@angular/animations": "^6.0.0",
"@angular/cdk": "^6.0.0",
"@angular/common": "^6.0.0",
"@angular/core": "^6.0.0",
"@angular/forms": "^6.0.0"
}
}
1 change: 0 additions & 1 deletion components/tree/nz-tree.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ export class NzTreeService {

/**
* return half checked nodes
* @returns {NzTreeNode[]}
*/
getHalfCheckedNodeList(): NzTreeNode[] {
this.halfCheckedNodeList = [];
Expand Down
25 changes: 25 additions & 0 deletions components/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "es2015",
"module": "es2015",
"sourceMap": true,
"inlineSources": true,
"moduleResolution": "node",
"importHelpers": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"declaration": true,
"outDir": "../release",
"lib": ["es2015", "dom"]
},
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"fullTemplateTypeCheck": false,
"strictInjectionParameters": true,
"flatModuleId": "AUTOGENERATED",
"flatModuleOutFile": "AUTOGENERATED"
}
}
38 changes: 7 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ng-zorro-antd",
"version": "1.1.1",
"name": "ng-zorro-antd-workspace",
"version": "0.0.0-NOT-USED",
"license": "MIT",
"description": "An enterprise-class UI components based on Ant Design and Angular",
"scripts": {
Expand All @@ -15,7 +15,8 @@
"build": "node site_scripts/generate-site init && ng build",
"doc": "npm run site:init && node --max_old_space_size=5120 ./node_modules/@angular/cli/bin/ng build --prod --build-optimizer",
"helper": "bash ./release-helper.sh",
"generate": "bash ./build.sh",
"generate": "ng build ng-zorro-antd-lib",
"postgenerate": "node ./build_scripts/generate-less.js && cp README.md publish/README.md",
"pre-release": "npm run site:init && bash ./build_scripts/replace-publish.sh && npm run generate && node --max_old_space_size=5120 ./node_modules/@angular/cli/bin/ng build --prod && npm run helper",
"test": "ng test --watch=false --code-coverage",
"integration": "npm run generate && bash ./integration-test.sh",
Expand All @@ -25,33 +26,13 @@
"lint": "tslint -c tslint.json 'components/*/*.ts'",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s && node site_scripts/replace-scope-prefix.js"
},
"main": "./bundles/antd.umd.js",
"module": "./esm5/antd.js",
"es2015": "./esm2015/antd.js",
"typings": "./antd.d.ts",
"schematics": "./schematics/collection.json",
"keywords": [
"ant",
"design",
"angular",
"ui",
"framework",
"frontend"
],
"homepage": "https://ng.ant.design",
"repository": {
"type": "git",
"url": "https://github.com/NG-ZORRO/ng-zorro-antd"
},
"bugs": {
"url": "https://github.com/NG-ZORRO/ng-zorro-antd/issues"
},
"dependencies": {
"@angular/cdk": "^6.0.0",
"date-fns": "^1.29.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.6.0",
"@angular-devkit/build-ng-packagr": "^0.6.8",
"@angular-devkit/core": "^0.6.0",
"@angular-devkit/schematics": "^0.6.0",
"@angular/animations": "^6.0.0",
Expand Down Expand Up @@ -89,6 +70,7 @@
"less": "^2.7.3",
"less-plugin-clean-css": "^1.5.1",
"marked": "^0.3.6",
"ng-packagr": "^3.0.0-rc.2",
"ngx-color": "^1.5.2",
"ngx-infinite-scroll": "^6.0.0",
"node-prismjs": "^0.1.1",
Expand All @@ -103,18 +85,12 @@
"rollup-plugin-uglify": "^2.0.1",
"rxjs": "^6.0.0",
"ts-node": "~5.0.1",
"tsickle": "^0.30.0",
"tslib": "^1.9.0",
"tslint": "~5.9.1",
"typescript": "~2.7.2",
"wrench": "^1.5.9",
"yaml-front-matter": "^3.4.0",
"zone.js": "^0.8.26"
},
"peerDependencies": {
"@angular/animations": "^6.0.0",
"@angular/cdk": "^6.0.0",
"@angular/common": "^6.0.0",
"@angular/core": "^6.0.0",
"@angular/forms": "^6.0.0"
}
}
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
Expand Down

0 comments on commit 804cdd3

Please sign in to comment.