diff --git a/assets/release/README.md b/assets/release/README.md index 18a2fc697..b94797d78 100644 --- a/assets/release/README.md +++ b/assets/release/README.md @@ -5,9 +5,10 @@ The sources for this package are in the [angular2-google-maps](https://github.co This package contains different sources for different users: -1. The files under `/cjs` are es5 compatible files that can be consumed using CommonJS. -2. The files under `/es6` are es6 compatible files that can be transpiled to es5 using any transpiler. +1. The files located in the root dir are ES5 compatible files that can be consumed using CommonJS. +2. The files under `/es6` are ES6 compatible files that can be transpiled to E5 using any transpiler. 3. The files under `/ts` are the TypeScript source files. -4. The files under `/typings` are the Typescript type definition files for this package, useful for local typescript development. +4. The `/bundles` directory contains the following files: + * `angular2-google-maps.js` and `angular2-google-maps.min.js` are bundles that can be consumed using SystemJS. License: See LICENSE file in this folder. diff --git a/docs/getting-started.md b/docs/getting-started.md index ec289abf9..0181bb67e 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -20,7 +20,8 @@ npm install angular2-google-maps ``` This package contains different sources for different users: -1. The files under `/cjs` are ES5 compatible files that can be consumed using CommonJS. -2. The files under `/es6` are ES6 compatible files that can be transpiled to ES5 using any transpiler. +1. The files located in the root dir are ES5 compatible files that can be consumed using CommonJS. +2. The files under `/es6` are ES6 compatible files that can be transpiled to E5 using any transpiler. 3. The files under `/ts` are the TypeScript source files. -4. The files under `/typings` are the Typescript type definition files for this package, useful for local typescript development. +4. The `/bundles` directory contains the following files: + * `angular2-google-maps.js` and `angular2-google-maps.min.js` are bundles that can be consumed using SystemJS. diff --git a/gulp/bundle.js b/gulp/bundle.js index adde14e1a..5ee8f90e8 100644 --- a/gulp/bundle.js +++ b/gulp/bundle.js @@ -2,40 +2,44 @@ const gulp = require('gulp'); const config = require('./config'); const path = require('path'); const $ = require('gulp-load-plugins')(); - const Builder = require('systemjs-builder'); const bundleConfig = { - baseURL: config.PATHS.dist.cjs.base, + baseURL: config.PATHS.dist.cjs, defaultJSExtensions: true, paths: { + 'angular2-google-maps/*': '*', 'angular2/*': path.join(__dirname, '../node_modules/angular2/*'), 'rxjs/*': path.join(__dirname, '../node_modules/rxjs/*'), }, }; -function bundle(moduleName, outputFile, outputConfig) { +function bundle(moduleName, moduleBundleName, minify, done) { + const outputConfig = { + sourceMaps: true, + minify: minify, + }; const builder = new Builder(); builder.config(bundleConfig); - return builder.bundle(moduleName, outputFile, outputConfig); + const outputFile = path.join(config.PATHS.dist.bundles, moduleBundleName + (minify ? '.min' : '') + '.js'); + const bundlePromise = builder.bundle(moduleName + ' - angular2/* - rxjs/*', outputFile, outputConfig); + + if (!minify) { + bundlePromise.then(() => { + gulp.src(outputFile) + .pipe($.connect.reload()); + done(); + }); + } + return bundlePromise; } -gulp.task('bundle:cjs', ['scripts:cjs'], function cleanDist(done) { - const distFileName = path.join(config.PATHS.dist.bundles, 'angular2_google_maps.js'); - bundle('angular2_google_maps/angular2_google_maps - angular2/* - rxjs/*', distFileName, { - sourceMaps: true, - }).then(() => { - gulp.src(distFileName) - .pipe($.connect.reload()); - done(); - }); +gulp.task('bundle:cjs', ['scripts:cjs'], function bundleCjs(done) { + bundle('angular2-google-maps/core', 'angular2-google-maps', false, done); }); -gulp.task('bundle:cjs-min', ['scripts:cjs'], function cleanDist() { - bundle('angular2_google_maps/angular2_google_maps - angular2/* - rxjs/*', path.join(config.PATHS.dist.bundles, 'angular2_google_maps.min.js'), { - sourceMaps: true, - minify: true, - }); +gulp.task('bundle:cjs:min', ['scripts:cjs'], function bundleCjsMin(done) { + bundle('angular2-google-maps/core', 'angular2-google-maps', true, done); }); -gulp.task('bundle', ['bundle:cjs', 'bundle:cjs-min']); +gulp.task('bundle', ['bundle:cjs', 'bundle:cjs:min']); diff --git a/gulp/config.js b/gulp/config.js index 61d140332..b17faf8f8 100644 --- a/gulp/config.js +++ b/gulp/config.js @@ -1,7 +1,5 @@ const path = require('path'); -const MODULE_NAME = 'angular2_google_maps'; - // note: for all paths, the base dir is ../ module.exports.PATHS = { srcDir: 'src', @@ -12,17 +10,9 @@ module.exports.PATHS = { tsConfig: path.join(__dirname, '../tsconfig.json'), dist: { base: 'dist', - cjs: { - base: 'dist/cjs', - moduleDir: 'dist/cjs/' + MODULE_NAME, - }, - es6: 'dist/es6/' + MODULE_NAME, - ts: 'dist/ts/' + MODULE_NAME, - typings: 'dist/typings', - bundles: 'dist/bundles', - }, - tmp: { - base: 'tmp', - typings: 'tmp/typings', + cjs: 'dist', + es6: 'dist/es6/', + ts: 'dist/ts/', + bundles: 'dist/bundles/', }, }; diff --git a/gulp/scripts.js b/gulp/scripts.js index 2f8deaf57..13026910f 100644 --- a/gulp/scripts.js +++ b/gulp/scripts.js @@ -11,6 +11,7 @@ gulp.task('scripts:ts', function scriptsTs() { gulp.task('scripts:es6', function scriptsEs6() { const taskConfig = $.typescript.createProject(config.PATHS.tsConfig, { + module: 'ES6', target: 'ES6', emitDecoratorMetadata: true, experimentalDecorators: true, @@ -38,8 +39,8 @@ gulp.task('scripts:cjs', function scriptsEs5() { .pipe($.typescript(taskConfigCjs)); return merge([ - tsResult.dts.pipe(gulp.dest(config.PATHS.dist.cjs.moduleDir)), - tsResult.js.pipe(sourcemaps.write('.')).pipe(gulp.dest(config.PATHS.dist.cjs.moduleDir)), + tsResult.dts.pipe(gulp.dest(config.PATHS.dist.cjs)), + tsResult.js.pipe(sourcemaps.write('.')).pipe(gulp.dest(config.PATHS.dist.cjs)), ]); }); diff --git a/gulp/typings.js b/gulp/typings.js deleted file mode 100644 index f94302dc3..000000000 --- a/gulp/typings.js +++ /dev/null @@ -1,26 +0,0 @@ -const gulp = require('gulp'); -const config = require('./config'); -const path = require('path'); -const dts = require('dts-bundle'); -const replace = require('replace'); - -gulp.task('typings', ['scripts:cjs'], function typings(done) { - const outFile = path.join(__dirname, '../', config.PATHS.dist.typings, 'angular2_google_maps.d.ts'); - - dts.bundle({ - name: 'angular2_google_maps', - indent: ' ', - prefix: '', - main: path.join(config.PATHS.dist.cjs.moduleDir, 'angular2_google_maps.d.ts'), - out: outFile, - }); - - replace({ - paths: [outFile], - regex: 'declare module \'angular2_google_maps\'', - replacement: 'declare module \'angular2_google_maps/angular2_google_maps\'', - silent: true, - }); - - done(); -}); diff --git a/gulpfile.js b/gulpfile.js index 51c0d23b5..847476580 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -5,7 +5,7 @@ const runSequence = require('run-sequence'); // all grunt tasks, which are defined here, are intended for use via the CLI. gulp.task('build', function build(done) { - runSequence('clean:dist', 'lint', ['copy-release-assets', 'scripts', 'typings', 'bundle'], done); + runSequence('clean:dist', 'lint', ['copy-release-assets', 'scripts', 'bundle'], done); }); gulp.task('serve', ['connect', 'watch']); diff --git a/package.json b/package.json index 906a72827..7ba78d107 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,6 @@ "@reactivex/rxjs": "5.0.0-alpha.10", "babel-eslint": "4.1.6", "del": "2.2.0", - "dts-bundle": "https://github.com/SebastianM/dts-bundle/tarball/master", "eslint": "1.10.1", "eslint-config-airbnb": "1.0.0", "eslint-plugin-react": "3.11.3", diff --git a/src/angular2_google_maps.ts b/src/core.ts similarity index 100% rename from src/angular2_google_maps.ts rename to src/core.ts