Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
404 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,4 +52,5 @@ src/ngFactory | |
*.metadata.json | ||
dist | ||
|
||
examples/webpack/node_modules | ||
examples/webpack/node_modules | ||
examples/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,73 @@ | ||
"use strict"; | ||
|
||
require('shelljs/global'); | ||
const shell = require('shelljs'); | ||
const chalk = require('chalk'); | ||
|
||
const PACKAGE = `ngx-youtube-player`; | ||
module.exports.PACKAGE = PACKAGE; | ||
const NPM_DIR = `dist`; | ||
const MODULES_DIR = `${NPM_DIR}/modules`; | ||
const ESM2015_DIR = `${NPM_DIR}/esm2015`; | ||
const ESM5_DIR = `${NPM_DIR}/esm5`; | ||
const BUNDLES_DIR = `${NPM_DIR}/bundles`; | ||
const OUT_DIR_ESM5 = `${NPM_DIR}/package/esm5`; | ||
|
||
echo('Start building...'); | ||
shell.echo(`Start building...`); | ||
|
||
rm(`-Rf`, `${NPM_DIR}/*`); | ||
mkdir(`-p`, `./${MODULES_DIR}`); | ||
mkdir(`-p`, `./${BUNDLES_DIR}`); | ||
shell.rm(`-Rf`, `${NPM_DIR}/*`); | ||
shell.mkdir(`-p`, `./${ESM2015_DIR}`); | ||
shell.mkdir(`-p`, `./${ESM5_DIR}`); | ||
shell.mkdir(`-p`, `./${BUNDLES_DIR}`); | ||
|
||
/* TSLint with Codelyzer */ | ||
// https://github.com/palantir/tslint/blob/master/src/configs/recommended.ts | ||
// https://github.com/mgechev/codelyzer | ||
echo(`Start TSLint`); | ||
exec(`tslint --project ./tsconfig.json --type-check ./src/**/*.ts`); | ||
echo(chalk.green(`TSLint completed`)); | ||
|
||
/* Aot compilation: ES2015 sources */ | ||
echo(`Start AoT compilation`); | ||
exec(`ngc -p tsconfig-build.json`); | ||
echo(chalk.green(`AoT compilation completed`)); | ||
|
||
/* Creates bundles: ESM/ES5 and UMD bundles */ | ||
echo(`Start bundling`); | ||
echo(`Rollup package`); | ||
exec(`rollup -i ${NPM_DIR}/${PACKAGE}.js -o ${MODULES_DIR}/${PACKAGE}.js --sourcemap`, {silent: true}); | ||
exec(`node scripts/map-sources -f ${MODULES_DIR}/${PACKAGE}.js`); | ||
|
||
echo(`Downleveling ES2015 to ESM/ES5`); | ||
cp(`${MODULES_DIR}/${PACKAGE}.js`, `${MODULES_DIR}/${PACKAGE}.es5.ts`); | ||
exec(`tsc ${MODULES_DIR}/${PACKAGE}.es5.ts --target es5 --module es2015 --noLib --sourceMap`, {silent: true}); | ||
exec(`node scripts/map-sources -f ${MODULES_DIR}/${PACKAGE}.es5.js`); | ||
rm(`-f`, `${MODULES_DIR}/${PACKAGE}.es5.ts`); | ||
|
||
echo(`Run Rollup conversion on package`); | ||
exec(`rollup -c rollup.config.js --sourcemap`, {silent: true}); | ||
exec(`node scripts/map-sources -f ${BUNDLES_DIR}/${PACKAGE}.umd.js`); | ||
|
||
echo(`Minifying`); | ||
cd(`${BUNDLES_DIR}`); | ||
exec(`uglifyjs -c --screw-ie8 --comments -o ${PACKAGE}.umd.min.js --source-map ${PACKAGE}.umd.min.js.map --source-map-include-sources ${PACKAGE}.umd.js`, {silent: true}); | ||
exec(`node ../../scripts/map-sources -f ${PACKAGE}.umd.min.js`); | ||
cd(`..`); | ||
cd(`..`); | ||
|
||
echo(chalk.green(`Bundling completed`)); | ||
|
||
rm(`-Rf`, `${NPM_DIR}/*.js`); | ||
rm(`-Rf`, `${NPM_DIR}/*.js.map`); | ||
rm(`-Rf`, `${NPM_DIR}/src/**/*.js`); | ||
rm(`-Rf`, `${NPM_DIR}/src/**/*.js.map`); | ||
|
||
cp(`-Rf`, [`package.json`, `LICENSE`, `README.md`], `${NPM_DIR}`); | ||
|
||
echo(chalk.green(`End building`)); | ||
shell.echo(`Start TSLint`); | ||
shell.exec(`tslint -c tslint.json -t stylish src/**/*.ts`); | ||
shell.echo(chalk.green(`TSLint completed`)); | ||
|
||
/* AoT compilation */ | ||
shell.echo(`Start AoT compilation`); | ||
if (shell.exec(`ngc -p tsconfig-build.json`).code !== 0) { | ||
shell.echo(chalk.red(`Error: AoT compilation failed`)); | ||
shell.exit(1); | ||
} | ||
shell.echo(chalk.green(`AoT compilation completed`)); | ||
|
||
/* BUNDLING PACKAGE */ | ||
shell.echo(`Start bundling`); | ||
shell.echo(`Rollup package`); | ||
if (shell.exec(`rollup -c rollup.es.config.js -i ${NPM_DIR}/${PACKAGE}.js -o ${ESM2015_DIR}/${PACKAGE}.js`).code !== 0) { | ||
shell.echo(chalk.red(`Error: Rollup package failed`)); | ||
shell.exit(1); | ||
} | ||
|
||
shell.echo(`Produce ESM5 version`); | ||
shell.exec(`ngc -p tsconfig-build.json --target es5 -d false --outDir ${OUT_DIR_ESM5} --importHelpers true --sourceMap`); | ||
if (shell.exec(`rollup -c rollup.es.config.js -i ${OUT_DIR_ESM5}/${PACKAGE}.js -o ${ESM5_DIR}/${PACKAGE}.js`).code !== 0) { | ||
shell.echo(chalk.red(`Error: ESM5 version failed`)); | ||
shell.exit(1); | ||
} | ||
|
||
shell.echo(`Run Rollup conversion on package`); | ||
if (shell.exec(`rollup -c rollup.config.js -i ${ESM5_DIR}/${PACKAGE}.js -o ${BUNDLES_DIR}/${PACKAGE}.umd.js`).code !== 0) { | ||
shell.echo(chalk.red(`Error: Rollup conversion failed`)); | ||
shell.exit(1); | ||
} | ||
|
||
shell.echo(`Minifying`); | ||
shell.cd(`${BUNDLES_DIR}`); | ||
shell.exec(`uglifyjs ${PACKAGE}.umd.js -c --comments -o ${PACKAGE}.umd.min.js --source-map "filename='${PACKAGE}.umd.min.js.map', includeSources"`); | ||
shell.cd(`..`); | ||
shell.cd(`..`); | ||
|
||
shell.echo(chalk.green(`Bundling completed`)); | ||
|
||
shell.rm(`-Rf`, `${NPM_DIR}/package`); | ||
shell.rm(`-Rf`, `${NPM_DIR}/node_modules`); | ||
shell.rm(`-Rf`, `${NPM_DIR}/*.js`); | ||
shell.rm(`-Rf`, `${NPM_DIR}/*.js.map`); | ||
shell.rm(`-Rf`, `${NPM_DIR}/src/**/*.js`); | ||
shell.rm(`-Rf`, `${NPM_DIR}/src/**/*.js.map`); | ||
|
||
shell.cp(`-Rf`, [`package.json`, `LICENSE`, `README.md`], `${NPM_DIR}`); | ||
|
||
shell.echo(chalk.green(`End building`)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* @license ngx-youtube-library | ||
* Copyright (c) 2018 Oren Farhi | ||
* MIT license | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ |
Binary file not shown.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,39 @@ | ||
import resolve from 'rollup-plugin-node-resolve'; | ||
import sourcemaps from 'rollup-plugin-sourcemaps'; | ||
|
||
/** | ||
* Add here external dependencies that actually you use. | ||
* | ||
* About RxJS | ||
* Each RxJS functionality that you use in the library must be added as external dependency. | ||
* - For main classes use 'Rx': | ||
* e.g. import { Observable } from 'rxjs/Observable'; => 'rxjs/Observable': 'Rx' | ||
* - For observable methods use 'Rx.Observable': | ||
* e.g. import 'rxjs/add/observable/merge'; => 'rxjs/add/observable/merge': 'Rx.Observable' | ||
* or for lettable operators: | ||
* e.g. import { merge } from 'rxjs/observable/merge'; => 'rxjs/observable/merge': 'Rx.Observable' | ||
* - For operators use 'Rx.Observable.prototype': | ||
* e.g. import 'rxjs/add/operator/map'; => 'rxjs/add/operator/map': 'Rx.Observable.prototype' | ||
* or for lettable operators: | ||
* e.g. import { map } from 'rxjs/operators'; => 'rxjs/operators': 'Rx.Observable.prototype' | ||
*/ | ||
const globals = { | ||
'@angular/core': 'ng.core', | ||
'@angular/common': 'ng.common', | ||
'rxjs/Observable': 'Rx', | ||
'rxjs/ReplaySubject': 'Rx', | ||
'rxjs/Observer': 'Rx' | ||
}; | ||
|
||
export default { | ||
entry: './dist/modules/ngx-youtube-player.es5.js', | ||
dest: './dist/bundles/ngx-youtube-player.umd.js', | ||
format: 'umd', | ||
exports: 'named', | ||
moduleName: 'ng.ngxYoutubePlayer', | ||
external: [ | ||
'@angular/core', | ||
'@angular/common', | ||
'rxjs/Observable', | ||
'rxjs/Observer' | ||
], | ||
globals: { | ||
'@angular/core': 'ng.core', | ||
'@angular/common': 'ng.common', | ||
'rxjs/Observable': 'Rx', | ||
'rxjs/Observer': 'Rx' | ||
}, | ||
onwarn: () => { return } | ||
external: Object.keys(globals), | ||
plugins: [resolve(), sourcemaps()], | ||
onwarn: () => { return }, | ||
output: { | ||
format: 'umd', | ||
name: 'ng.ngxYoutubePlayer', | ||
globals: globals, | ||
sourcemap: true, | ||
exports: 'named' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import sourcemaps from 'rollup-plugin-sourcemaps'; | ||
import license from 'rollup-plugin-license'; | ||
|
||
const path = require('path'); | ||
|
||
export default { | ||
output: { | ||
format: 'es', | ||
sourcemap: true | ||
}, | ||
plugins: [ | ||
sourcemaps(), | ||
license({ | ||
sourceMap: true, | ||
|
||
banner: { | ||
file: path.join(__dirname, 'license-banner.txt'), | ||
encoding: 'utf-8', | ||
} | ||
}) | ||
], | ||
onwarn: () => { return } | ||
} |
Oops, something went wrong.