Skip to content

Commit

Permalink
feat(packaging): change package structure
Browse files Browse the repository at this point in the history
The new package structure enables better tooling support when you
develop your application with TypeScript.

BREAKING CHANGES:

* The module name has changed. So you have to change
  your import path.
  old: `angular2_google_maps/angular2_google_maps`
  new: `angular2-google-maps/core`
* ES5 files that can be consumed using CommonJS are now in the root
  directory (old path was `/cjs/angular2_google_maps`)
* The ES6 files directory has changed:
  Old dir: `/es6/angular2_google_maps`
  New dir: `/es6`
* The TypeScript files directory has changed:
  Old dir: `/ts/angular2_google_maps`
  New dir: `/ts`
* The `/typings` directory with bundled typings was deleted.
  (Typings are now in the root directory seperated by file)
  • Loading branch information
sebholstein committed Dec 21, 2015
1 parent de569df commit 77d634e
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 69 deletions.
7 changes: 4 additions & 3 deletions assets/release/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
7 changes: 4 additions & 3 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
42 changes: 23 additions & 19 deletions gulp/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
18 changes: 4 additions & 14 deletions gulp/config.js
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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/',
},
};
5 changes: 3 additions & 2 deletions gulp/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)),
]);
});

Expand Down
26 changes: 0 additions & 26 deletions gulp/typings.js

This file was deleted.

2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
File renamed without changes.

0 comments on commit 77d634e

Please sign in to comment.