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 authored and hsuanxyz committed Sep 17, 2018
1 parent 21f0703 commit f391b15
Show file tree
Hide file tree
Showing 34 changed files with 173 additions and 145 deletions.
14 changes: 14 additions & 0 deletions angular.json
Expand Up @@ -86,6 +86,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
64 changes: 0 additions & 64 deletions build.sh

This file was deleted.

2 changes: 1 addition & 1 deletion build_scripts/generate-less.js
Expand Up @@ -21,7 +21,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
12 changes: 12 additions & 0 deletions build_scripts/migration-styles.js
@@ -0,0 +1,12 @@
const fs = require('fs-extra');
const path = require('path');

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

fs.mkdirsSync(targetPath);
fs.copySync(path.resolve(sourcePath, `style`), path.resolve(targetPath, `style`));
fs.copySync(path.resolve(sourcePath, `ng-zorro-antd.css`), path.resolve(targetPath, `ng-zorro-antd.css`));
fs.copySync(path.resolve(sourcePath, `ng-zorro-antd.min.css`), path.resolve(targetPath, `ng-zorro-antd.min.css`));
fs.outputFileSync(path.resolve(targetPath, `ng-zorro-antd.less`), `@import "../style/index.less";
@import "../components.less";`);
2 changes: 1 addition & 1 deletion components/calendar/nz-calendar-header.component.ts
@@ -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
@@ -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
1 change: 1 addition & 0 deletions components/core/util/index.ts
@@ -0,0 +1 @@
export * from './public-api';
8 changes: 8 additions & 0 deletions components/core/util/public-api.ts
@@ -0,0 +1,8 @@
export * from './calculate-node-height';
export * from './check';
export * from './convert';
export * from './getMentions';
export * from './keycodes';
export * from './nz-global-monitor';
export * from './textarea-caret-position';
export * from './throttleByAnimationFrame';
2 changes: 1 addition & 1 deletion components/date-picker/date-picker.component.spec.ts
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
@@ -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
@@ -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
@@ -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
12 changes: 6 additions & 6 deletions components/date-picker/lib/candy-date/candy-date.ts
@@ -1,9 +1,9 @@
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 setMonth from 'date-fns/set_month';
// 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 setMonth from 'date-fns/set_month';
// 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
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
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
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
@@ -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"
]
}
5 changes: 3 additions & 2 deletions components/ng-zorro-antd.module.ts
Expand Up @@ -14,6 +14,7 @@ import { NzCarouselModule } from './carousel/nz-carousel.module';
import { NzCascaderModule } from './cascader/nz-cascader.module';
import { NzCheckboxModule } from './checkbox/nz-checkbox.module';
import { NzCollapseModule } from './collapse/nz-collapse.module';
import { NzWaveModule } from './core/wave/nz-wave.module';
import { NzDatePickerModule } from './date-picker/date-picker.module';
import { NzDividerModule } from './divider/nz-divider.module';
import { NzDrawerModule } from './drawer/nz-drawer.module';
Expand Down Expand Up @@ -52,7 +53,6 @@ import { NzTransferModule } from './transfer/nz-transfer.module';
import { NzTreeSelectModule } from './tree-select/nz-tree-select.module';
import { NzTreeModule } from './tree/nz-tree.module';
import { NzUploadModule } from './upload/nz-upload.module';
import { NzWaveModule } from './core/wave/nz-wave.module';

export * from './affix';
export * from './alert';
Expand All @@ -70,6 +70,7 @@ export * from './collapse';
export * from './date-picker';
export * from './divider';
export * from './dropdown';
export * from './drawer';
export * from './form';
export * from './grid';
export * from './i18n';
Expand Down Expand Up @@ -109,6 +110,7 @@ export * from './tree-select';
export * from './time-picker';
export * from './version';
export * from './core/wave';
export * from './core/util';

@NgModule({
exports: [
Expand Down Expand Up @@ -140,7 +142,6 @@ export * from './core/wave';
NzCardModule,
NzAvatarModule,
NzTimelineModule,
NzTimePickerModule,
NzTransferModule,
NzCarouselModule,
NzCollapseModule,
Expand Down
36 changes: 36 additions & 0 deletions components/package.json
@@ -0,0 +1,36 @@
{
"name": "ng-zorro-antd",
"version": "1.5.0",
"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",
"tslib": "^1.9.0",
"typescript": "~2.9.2"
}
}
27 changes: 27 additions & 0 deletions components/tsconfig.lib.json
@@ -0,0 +1,27 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"baseUrl": "./",
"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,
"enableResourceInlining": true,
"flatModuleId": "AUTOGENERATED",
"flatModuleOutFile": "AUTOGENERATED"
}
}
1 change: 1 addition & 0 deletions components/tsconfig.spec.json
Expand Up @@ -4,6 +4,7 @@
"outDir": "../out-tsc/spec",
"baseUrl": "./",
"module": "commonjs",
"esModuleInterop": true,
"target": "es5",
"types": [
"jasmine",
Expand Down
4 changes: 2 additions & 2 deletions docs/customize-theme.en-US.md
Expand Up @@ -40,7 +40,7 @@ Here is an example of `theme.less`
```css
// -------- import official less file -----------
@import "../node_modules/ng-zorro-antd/src/ng-zorro-antd.less";
@import "../node_modules/ng-zorro-antd/ng-zorro-antd.less";

// -------- override less var -----------
@primary-color : #f5222d;
Expand All @@ -57,7 +57,7 @@ Here is an example set icon url to the folder `assets/fonts`

```css
// -------- import official less file -----------
@import "../node_modules/ng-zorro-antd/src/ng-zorro-antd.less";
@import "../node_modules/ng-zorro-antd/ng-zorro-antd.less";

// -------- override less var -----------
@icon-url : "/assets/fonts/iconfont";
Expand Down

0 comments on commit f391b15

Please sign in to comment.