Skip to content

Commit

Permalink
rollup sourcemaps and es2015 modules (#120)
Browse files Browse the repository at this point in the history
* rollup sourcemaps and es2015 modules

* fix codecov settings

* paths always failing

* _component -> instance
  • Loading branch information
scttcper authored Apr 29, 2017
1 parent 37dca26 commit cb66e23
Show file tree
Hide file tree
Showing 24 changed files with 246 additions and 167 deletions.
13 changes: 5 additions & 8 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
coverage:
status:
default:
threshold: null
patch:
default:
threshold: null
changes:
default:
threshold: null
project:
default:
target: auto
threshold: 10
base: auto
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ testem.log
/typings
/deploy
/waste
/build

# e2e
/e2e/*.js
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@types/lodash.clonedeep": "^4.5.2",
"@types/lodash.random": "^3.2.2",
"@types/node": "^7.0.14",
"codelyzer": "^3.0.0",
"codelyzer": "^3.0.1",
"jasmine-core": "^2.6.1",
"jasmine-spec-reporter": "^4.0.0",
"karma": "^1.6.0",
Expand All @@ -55,8 +55,9 @@
"protractor": "^5.1.1",
"rimraf": "^2.6.1",
"rollup": "^0.41.6",
"rollup-plugin-sourcemaps": "^0.4.2",
"ts-node": "^3.0.2",
"tslint": "^5.1.0",
"typescript": "^2.2.2"
"typescript": "^2.3.2"
}
}
26 changes: 26 additions & 0 deletions rollup.es.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const sourcemaps = require('rollup-plugin-sourcemaps');

export default {
entry: './build/toastr.js',
dest: './deploy/toastr.js',
format: 'es',
moduleName: 'ngxtoastr',
sourceMap: true,
globals: {
'@angular/core': 'ng.core',
'@angular/common': 'ng.common',
'@angular/platform-browser': 'ng.platformBrowser',
'rxjs/Observable': 'Rx',
'rxjs/Subject': 'Rx'
},
external: [
'@angular/core',
'@angular/common',
'@angular/platform-browser',
'rxjs/Observable',
'rxjs/Subject'
],
plugins: [
sourcemaps()
]
};
17 changes: 15 additions & 2 deletions rollup.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
const sourcemaps = require('rollup-plugin-sourcemaps');

export default {
entry: './deploy/toastr.js',
entry: './build/toastr.js',
dest: './deploy/toastr.umd.js',
format: 'umd',
moduleName: 'ngxtoastr',
sourceMap: true,
globals: {
'@angular/core': 'ng.core',
'@angular/common': 'ng.common',
'@angular/platform-browser': 'ng.platformBrowser',
'rxjs/Observable': 'Rx',
'rxjs/Subject': 'Rx'
}
},
external: [
'@angular/core',
'@angular/common',
'@angular/platform-browser',
'rxjs/Observable',
'rxjs/Subject'
],
plugins: [
sourcemaps()
]
};
16 changes: 8 additions & 8 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FormsModule } from '@angular/forms';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { CommonModule } from '@angular/common';

import { ToastrModule, ActiveToast } from 'ngx-toastr';
import { ToastrModule, ActiveToast } from '../lib';

import { AppComponent } from './app.component';
import { PinkToast } from './pink.toast';
Expand Down Expand Up @@ -57,25 +57,25 @@ describe('AppComponent', () => {
.then(() => {
done();
});
opened.portal._component.tapToast();
opened.portal.instance.tapToast();
});
it('should extend life on mouseover and exit', (done) => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
const opened: ActiveToast = app.openToast();
opened.portal._component.stickAround();
opened.portal._component.delayedHideToast();
expect(opened.portal._component.options.timeOut).toBe(1000);
opened.portal.instance.stickAround();
opened.portal.instance.delayedHideToast();
expect(opened.portal.instance.options.timeOut).toBe(1000);
done();
});
it('should keep on mouse exit with extended timeout 0', (done) => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
app.options.extendedTimeOut = 0;
const opened: ActiveToast = app.openToast();
opened.portal._component.stickAround();
opened.portal._component.delayedHideToast();
expect(opened.portal._component.options.timeOut).toBe(0);
opened.portal.instance.stickAround();
opened.portal.instance.delayedHideToast();
expect(opened.portal.instance.options.timeOut).toBe(0);
done();
});
it('should trigger onShown for openPinkToast', (done) => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, VERSION } from '@angular/core';
import { cloneDeep, random } from 'lodash';

import { ToastrConfig, ToastrService } from 'ngx-toastr';
import { ToastrConfig, ToastrService } from '../lib';

import { PinkToast } from './pink.toast';

Expand Down
2 changes: 1 addition & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

import { ToastrModule } from 'ngx-toastr';
import { ToastrModule } from '../lib';

import { AppComponent } from './app.component';
import { PinkToast } from './pink.toast';
Expand Down
2 changes: 1 addition & 1 deletion src/app/pink.toast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
state,
} from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { Toast, ToastData, ToastrService, ToastRef } from 'ngx-toastr';
import { Toast, ToastData, ToastrService, ToastRef } from '../lib';

@Component({
selector: '[pink-toast-component]',
Expand Down
10 changes: 10 additions & 0 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export { BasePortalHost, ComponentPortal } from './portal/portal';
export { Overlay } from './overlay/overlay';
export { OverlayContainer } from './overlay/overlay-container';
export { OverlayRef } from './overlay/overlay-ref';
export { ToastContainerModule, ToastContainerDirective } from './toastr/toast-directive'
export { Toast } from './toastr/toast-component';
export { ToastrService, ActiveToast } from './toastr/toastr-service';
export { ToastrConfig, ToastConfig, ToastData } from './toastr/toastr-config';
export { ToastrModule } from './toastr/toastr-module';
export { ToastRef } from './toastr/toast-injector';
2 changes: 1 addition & 1 deletion src/lib/overlay/overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DomPortalHost } from '../portal/dom-portal-host';
import { OverlayRef } from './overlay-ref';

import { OverlayContainer } from './overlay-container';
import { ToastContainerDirective } from '../toast-directive';
import { ToastContainerDirective } from '../toastr/toast-directive';


/**
Expand Down
8 changes: 4 additions & 4 deletions src/lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"version": "5.0.7",
"description": "Toastr for Angular",
"main": "toastr.umd.js",
"module": "toastr.js",
"jsnext:main": "toastr.js",
"typings": "toastr.d.ts",
"module": "toastr.es5.js",
"es2015": "toastr.js",
"typings": "index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/scttcper/ngx-toastr.git"
Expand All @@ -32,6 +32,6 @@
"peerDependencies": {
"@angular/core": ">=2.4.0 <=5.0.0",
"@angular/common": ">=2.4.0 <=5.0.0",
"rxjs": "^5.0.0"
"rxjs": "^5.3.0"
}
}
10 changes: 0 additions & 10 deletions src/lib/toastr.ts

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Injector} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Subject} from 'rxjs/Subject';

import {OverlayRef} from './overlay/overlay-ref';
import {OverlayRef} from '../overlay/overlay-ref';
import {ToastData} from './toastr-config';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs/Subject';

import { ComponentType } from './portal/portal';
import { ComponentType } from '../portal/portal';
import { Toast } from './toast-component';


Expand Down
4 changes: 2 additions & 2 deletions src/lib/toastr-module.ts → src/lib/toastr/toastr-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { CommonModule } from '@angular/common';
import { Toast } from './toast-component';
import { ToastrService } from './toastr-service';
import { ToastrConfig } from './toastr-config';
import { OverlayContainer } from './overlay/overlay-container';
import { Overlay } from './overlay/overlay';
import { OverlayContainer } from '../overlay/overlay-container';
import { Overlay } from '../overlay/overlay';

export const TOAST_CONFIG = new OpaqueToken('ToastConfig');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Injectable, Injector, ComponentRef } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';

import { Overlay } from './overlay/overlay';
import { ComponentPortal } from './portal/portal';
import { Overlay } from '../overlay/overlay';
import { ComponentPortal } from '../portal/portal';
import { ToastConfig, ToastrConfig, ToastData } from './toastr-config';
import { ToastInjector, ToastRef } from './toast-injector';
import { ToastContainerDirective } from './toast-directive';
Expand Down
28 changes: 28 additions & 0 deletions src/lib/tsconfig.flat.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"declaration": true,
"module": "es2015",
"target": "es2015",
"baseUrl": ".",
"stripInternal": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"outDir": "../../build",
"rootDir": ".",
"lib": ["es2015", "dom"],
"skipLibCheck": true,
// don't auto-discover @types/node, it results in a ///<reference in the .d.ts output
"types": []
},
"files": [
"./index.ts"
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"skipTemplateCodegen": true,
"flatModuleOutFile": "toastr.js",
"flatModuleId": "toastr"
}
}
6 changes: 3 additions & 3 deletions src/lib/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
"moduleResolution": "node",
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"outDir": "../../deploy",
"outDir": "../../build",
"sourceMap": false,
"target": "es5",
"types": []
},
"angularCompilerOptions": {
"genDir": "../../waste"
},
"exclude": [
"node_modules"
"files": [
"./index.ts"
]
}
16 changes: 10 additions & 6 deletions stage-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,25 @@ set -exu
# into the ./deploy folder. This script should be run from the root of the project

yarn cleanup
NGC="node node_modules/.bin/ngc"

# compile src directory and create d.ts files
./node_modules/.bin/ngc -p ./src/lib/tsconfig.lib.json -d
# Run Angular Compiler
$NGC -p ./src/lib/tsconfig.flat.json -d
./node_modules/.bin/rollup -c rollup.es.js

# Repeat the process for es5 version
$NGC -p ./src/lib/tsconfig.lib.json -d
# create umd
./node_modules/.bin/rollup -c rollup.js

# copy root readme and license to deployment folder
# for multiple
# for d in ./deploy/*; do cp README.md "$d"; done
# for d in ./deploy/*; do cp LICENSE "$d"; done
# single
cp README.md ./deploy
cp LICENSE ./deploy

# copy package.json files that are in lib folders
# find src/lib -name 'package.json' -type f -exec cp {} ./deploy \;
cp ./src/lib/package.json ./deploy
cp ./src/lib/toastr.css ./deploy

# Copy non-js files from build
rsync -a build/ deploy
5 changes: 1 addition & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
"lib": [
"es2016",
"dom"
],
"paths": {
"ngx-toastr": ["./lib/toastr"]
}
]
}
}
Loading

0 comments on commit cb66e23

Please sign in to comment.