Skip to content
This repository has been archived by the owner on Jun 14, 2020. It is now read-only.

Commit

Permalink
Use new bundle starting point (closes #61)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsebastien committed Dec 20, 2015
1 parent 686932d commit 96199e1
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* 0.2.0
* BREAKING CHANGE: scripts-javascript-dist now uses core/boot.js as entry point (vs core/core.bootstrap.js in earlier versions) (fixes #
* this new default behavior can be customized by specifying the `distEntryPoint` option (see README or UPGRADE guide)
* 0.1.1
* added unit testing support with karma & jasmine
* removed gulp-tsd dependency
Expand Down
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ module.exports = function (config) {
// doc: https://www.npmjs.com/package/karma-jspm
// reference config: https://github.com/gunnarlium/babel-jspm-karma-jasmine-istanbul
jspm: {
// Path to your SystemJS/JSPM configuration file
// Path to your SystemJS/JSPM configuration file
config: "jspm.conf.js",
// Where to find jspm packages
Expand All @@ -513,7 +513,7 @@ module.exports = function (config) {
".tmp/**/!(*.spec).js" // make sure that all files are available
],
// SystemJS configuration specifically for tests, added after your config file.
// SystemJS configuration specifically for tests, added after your config file.
// Good for adding test libraries and mock modules
paths: {}
}
Expand All @@ -523,8 +523,8 @@ module.exports = function (config) {

Dev dependencies to add for the above Karma configuration:
```
"jasmine": "2.4.x",
"karma-jasmine": "0.3.x",
"jasmine": "2.4.x",
"karma-jasmine": "0.3.x",
```

### Minimal (application-specific) required file contents
Expand Down Expand Up @@ -646,6 +646,25 @@ The command will give you a description of each task. The most important to star

You can run the `gulp -T` command get an visual idea of the links between the different tasks.

## Options
The build can be customized by passing options.
Defining options is done as in the following example gulpfile.babel.js:

```
"use strict";
import gulp from "gulp";
import modernWebDevBuild from "modern-web-dev-build";
let options = {};
options.distEntryPoint = "core/core.bootstrap";
```

Available options:
* distEntryPoint: must be a relative path from .tmp/ to the file to use as entry point for creating the production JS bundle. The extension does not need to be specified (JSPM is used to load the file)

## Build dependencies
* gulp: build system (https://www.npmjs.com/package/gulp)
* babel: ES2015 to ES5 transpiler; used for the gulp build
Expand Down
21 changes: 21 additions & 0 deletions UPGRADE.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Upgrade guide

## From 0.1.1 to 0.2.0
#61 breaks compatibility with existing projects.

In order to fix this, you need to rename app/core/core.bootstrap.ts to core/boot.ts (and rename the template accordingly) and ensure that you adapt app/index.html as well.

If you're not willing to rename as proposed above, then you can define the `distEntryPoint` option.

Here's an example gulpfile.babel.js:

```
"use strict";
import gulp from "gulp";
import modernWebDevBuild from "modern-web-dev-build";
let options = {};
options.distEntryPoint = "core/core.bootstrap";
```

## From 0.1.0 to 0.1.1
To upgrade you can simply increment the dependency version in your project.
To benefit from the unit testing support, you should add a karma.conf.js file to your project. Check the readme for details about its contents (though you can configure Karma as you wish/need).
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "modern-web-dev-build",
"description": "Modern Web Development Build.",
"version": "0.1.1",
"version": "0.2.0",
"author": {
"name": "Sebastien Dubois",
"email": "[email protected]",
Expand Down
2 changes: 1 addition & 1 deletion src/gulp/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ let javascript = {
src: [
folders.app + globs.scripts.javascript
],
srcDist: folders.temp + "/core/core.bootstrap.js",
srcDist: folders.temp + "/core/boot.js",
dest: folders.temp,
destDist: folders.dist + folders.scripts + "/" + finalJsBundleName,
finalJsBundlePath: folders.scripts + "/" + finalJsBundleName
Expand Down
15 changes: 13 additions & 2 deletions src/gulp/tasks/scripts-javascript-dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,34 @@ import config from "../config";

//import size from "gulp-size";

import path from "path";
import gutil from "gulp-util";

class ScriptsJavaScriptDistTaskLoader extends AbstractTaskLoader {
registerTask(gulp){
super.registerTask(gulp);

gulp.task("scripts-javascript-dist", "Package all JavaScript code for production", () =>{
// Assuming that all TS and ES2015 code has already been converted to ES5 using the System module type
// Assuming that there is a single entrypoint for the application
// We only need to create the final bundle

// Determine the entry point for the bundle creation (i.e., where to start from)
let distEntryPoint = config.javascript.srcDist;

if(gulp.options.distEntryPoint){
distEntryPoint = path.join(config.folders.temp, gulp.options.distEntryPoint);
gutil.log("Production bundle entry point customized: ", distEntryPoint);
}

// Create the bundle
// Reference: https://github.com/systemjs/builder/issues/203
let jspm = require("jspm");

jspm.setPackagePath(".");

return jspm.bundleSFX(
config.javascript.srcDist,
distEntryPoint, // where to start creating the bundle from
config.javascript.destDist, {
sourceMaps: false, // no need for sourcemaps in prod
lowResSourceMaps: false, // can speed up generation
Expand Down

0 comments on commit 96199e1

Please sign in to comment.