chore(build): Add WebWorker bundle.

Closes #3207

Closes #3881
This commit is contained in:
Jason Teplitz 2015-08-27 10:39:39 -07:00
parent be07390859
commit 3468f7cfd5
19 changed files with 111 additions and 1840 deletions

View File

@ -39,6 +39,8 @@ module.exports = new Package('angular-v2-docs', [jsdocPackage, nunjucksPackage,
readFilesProcessor.basePath = path.resolve(__dirname, '../..');
readTypeScriptModules.sourceFiles = [
'angular2/angular2.ts',
'angular2/web_worker/worker.ts',
'angular2/web_worker/ui.ts',
'angular2/router.ts',
'angular2/http.ts'
];
@ -48,24 +50,38 @@ module.exports = new Package('angular-v2-docs', [jsdocPackage, nunjucksPackage,
{
id: 'angular2/angular2',
references: ['../es6-promise/es6-promise.d.ts', '../rx/rx.d.ts'],
namespace: 'ng',
modules: {
'angular2/angular2': 'angular2/angular2',
'angular2/angular2': {
namespace: 'ng',
id: 'angular2/angular2'
},
'angular2/web_worker/worker': {
namespace: 'ngWorker',
id: 'angular2/web_worker/worker'
},
'angular2/web_worker/ui': {
namespace: 'ngUi',
id: 'angular2/web_worker/ui'
}
}
},
{
id: 'angular2/router',
namespace: 'ngRouter',
references: ['./angular2.d.ts'],
modules: {
'angular2/router': 'angular2/router'
'angular2/router': {
namespace: 'ngRouter',
id: 'angular2/router'
}
}
},
{
id: 'angular2/http',
namespace: 'ngHttp',
modules: {
'angular2/http':'angular2/http'
'angular2/http': {
namespace: 'ngHttp',
id: 'angular2/http'
}
}
}
];
@ -109,4 +125,4 @@ module.exports = new Package('angular-v2-docs', [jsdocPackage, nunjucksPackage,
'${ doc.docType }.template.html',
'common.template.html'
];
});
});

View File

@ -32,11 +32,11 @@ module.exports = function createTypeDefinitionFile(log) {
outputPath: docPath,
// A type definition may include a number of top level modules
// And those modules could be aliased (such as 'angular2/angular2.api' -> 'angular2/angular2')
moduleDocs: _.transform(def.modules, function(moduleDocs, id, alias) {
moduleDocs[id] = {
moduleDocs: _.transform(def.modules, function(moduleDocs, props, alias) {
moduleDocs[props.id] = {
id: alias,
doc: null,
namespace: def.namespace,
namespace: props.namespace,
references: def.references
};
})

View File

@ -14,7 +14,12 @@ describe('createTypeDefinitionFile processor', function() {
// Initialize the processor
processor.typeDefinitions = [{
id: 'angular2/angular2',
modules: { 'angular2/angular2': 'angular2/angular2' }
modules: {
'angular2/angular2': {
id: 'angular2/angular2',
namespace: 'ng'
}
}
}];
});
@ -45,4 +50,4 @@ describe('createTypeDefinitionFile processor', function() {
});
});
});
});

View File

@ -5,7 +5,8 @@ interface List<T> extends Array<T> {}
interface Map<K,V> {}
interface StringMap<K,V> extends Map<K,V> {}
declare module ng {
{% for alias, module in doc.moduleDocs %}
declare module {$ module.namespace $} {
// See https://github.com/Microsoft/TypeScript/issues/1168
class BaseException /* extends Error */ {
message: string;
@ -14,4 +15,5 @@ declare module ng {
}
interface InjectableReference {}
}
{% endfor %}
{% endblock %}

View File

@ -1073,6 +1073,27 @@ gulp.task('!bundle.js.dev', ['build.js.dev'], function() {
});
});
// WebWorker build
gulp.task("!bundle.web_worker.js.dev", ["build.js.dev"], function() {
var devBundleConfig = merge(true, bundleConfig);
devBundleConfig.paths =
merge(true, devBundleConfig.paths, {
"*": "dist/js/dev/es6/*.js"
});
return bundler.bundle(
devBundleConfig,
'angular2/web_worker/ui',
'./dist/build/web_worker/ui.dev.js',
{ sourceMaps: true }).
then(function() {
return bundler.bundle(
devBundleConfig,
'angular2/web_worker/worker',
'./dist/build/web_worker/worker.dev.js',
{ sourceMaps: true});
});
});
gulp.task('!router.bundle.js.dev', ['build.js.dev'], function() {
var devBundleConfig = merge(true, bundleConfig);
devBundleConfig.paths =
@ -1165,16 +1186,19 @@ function insertRXLicense(source) {
}
}
function addDevDependencies(outputFile) {
return bundler.modify(
JS_DEV_DEPS.concat(['dist/build/' + outputFile]),
outputFile)
.pipe(insert.transform(insertRXLicense))
.pipe(gulp.dest('dist/js/bundle'));
}
gulp.task('!bundle.js.dev.deps', ['!bundle.js.dev'], function() {
return merge2(
bundler.modify(
JS_DEV_DEPS.concat(['dist/build/angular2.dev.js']),
'angular2.dev.js')
.pipe(insert.transform(insertRXLicense))
.pipe(gulp.dest('dist/js/bundle')),
bundler.modify(
['dist/build/http.dev.js'], 'http.dev.js')
.pipe(gulp.dest('dist/js/bundle')));
var bundle = addDevDependencies('angular2.dev.js');
return merge2(bundle, bundler.modify(
['dist/build/http.dev.js'], 'http.dev.js')
.pipe(gulp.dest('dist/js/bundle')));
});
gulp.task('!bundle.js.sfx.dev.deps', ['!bundle.js.sfx.dev'], function() {
@ -1187,10 +1211,16 @@ gulp.task('!bundle.js.sfx.dev.deps', ['!bundle.js.sfx.dev'], function() {
.pipe(gulp.dest('dist/js/bundle')));
});
gulp.task('!bundle.web_worker.js.dev.deps', ['!bundle.web_worker.js.dev'], function() {
return merge2(addDevDependencies("web_worker/ui.dev.js",
addDevDependencies("web_worker/worker.dev.js")));
});
gulp.task('bundles.js', [
'!bundle.js.prod.deps',
'!bundle.js.dev.deps',
'!bundle.js.min.deps',
'!bundle.web_worker.js.dev.deps',
'!bundle.js.sfx.dev.deps',
'!router.bundle.js.dev',
'!test.bundle.js.dev']);

View File

@ -14,3 +14,4 @@ export * from './directives';
export * from './forms';
export * from './render';
export * from './profile';
export {bootstrap} from 'angular2/src/core/application';

View File

@ -6,3 +6,4 @@ export * from './directives';
export * from './forms';
export * from './render';
export * from './profile';
export {bootstrap} from 'angular2/src/core/application';

View File

@ -4,7 +4,6 @@
* Define angular core API here.
*/
export {APP_COMPONENT} from 'angular2/src/core/application_tokens';
export {commonBootstrap as bootstrap} from 'angular2/src/core/application_common';
export {Type} from 'angular2/src/core/facade/lang';
export {ApplicationRef} from 'angular2/src/core/application_ref';

View File

@ -1,5 +1,23 @@
/// <reference path="../../../globals.d.ts" />
var _global: BrowserNodeGlobal = <any>(typeof window === 'undefined' ? global : window);
// TODO(jteplitz602): Load WorkerGlobalScope from lib.webworker.d.ts file #3492
declare var WorkerGlobalScope;
var globalScope: BrowserNodeGlobal;
if (typeof window === 'undefined') {
if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
// TODO: Replace any with WorkerGlobalScope from lib.webworker.d.ts #3492
globalScope = <any>self;
} else {
globalScope = <any>global;
}
} else {
globalScope = <any>window;
};
// Need to declare a new variable for global here since TypeScript
// exports the original value of the symbol.
var _global: BrowserNodeGlobal = globalScope;
export {_global as global};
export var Type = Function;

View File

@ -1,5 +1,6 @@
import {EventEmitter} from 'angular2/src/core/facade/async';
import {BaseException} from 'angular2/src/core/facade/lang';
export {EventEmitter, Observable} from 'angular2/src/core/facade/async';
function _abstract() {
throw new BaseException("This method is abstract");

View File

@ -6,6 +6,7 @@ import {
import {MessageBus} from 'angular2/src/web_workers/shared/message_bus';
import {BaseException} from "angular2/src/core/facade/lang";
import {bootstrapUICommon} from "angular2/src/web_workers/ui/impl";
export * from 'angular2/src/web_workers/shared/message_bus';
/**
* Bootstrapping a WebWorker

View File

@ -10,6 +10,7 @@ import {Promise} from 'angular2/src/core/facade/async';
import {bootstrapWebWorkerCommon} from "angular2/src/web_workers/worker/application_common";
import {ApplicationRef} from "angular2/src/core/application_ref";
import {Injectable} from "angular2/di";
export * from "angular2/src/web_workers/shared/message_bus";
// TODO(jteplitz602) remove this and compile with lib.webworker.d.ts (#3492)
interface PostMessageInterface {

View File

@ -0,0 +1 @@
export * from "../src/web_workers/ui/application";

View File

@ -0,0 +1,9 @@
export * from '../metadata';
export * from '../change_detection';
export * from '../core';
export * from '../di';
export * from '../directives';
export * from '../forms';
export * from '../render';
export * from '../profile';
export * from '../src/web_workers/worker/application';

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,4 @@
$SCRIPTS$
window = {
setTimeout: setTimeout,
Map: Map,
Set: Set,
Array: Array,
Reflect: Reflect,
RegExp: RegExp,
Promise: Promise,
Date: Date,
zone: zone
};
assert = function() {};
importScripts("b64.js");

View File

@ -1,19 +1,5 @@
$SCRIPTS$
window = {
setTimeout: setTimeout,
Map: Map,
Set: Set,
Array: Array,
Reflect: Reflect,
RegExp: RegExp,
Promise: Promise,
Date: Date,
zone: zone
};
assert = function() {};
System.config({
baseURL: '/',
defaultJSExtensions: true,

View File

@ -1,19 +1,5 @@
$SCRIPTS$
window = {
setTimeout: setTimeout,
Map: Map,
Set: Set,
Array: Array,
Reflect: Reflect,
RegExp: RegExp,
Promise: Promise,
Date: Date,
zone: zone
};
assert = function() {};
System.config({
baseURL: '/',
defaultJSExtensions: true,

View File

@ -1,2 +1,2 @@
importScripts("/examples/src/assets/zone-microtask-web-workers.js", "long-stack-trace-zone.js",
"traceur-runtime.js", "system.src.js", "Reflect.js");
importScripts("zone-microtask.js", "long-stack-trace-zone.js", "traceur-runtime.js",
"system.src.js", "Reflect.js");