Skip to content

Commit d3871cb

Browse files
committed
fix(modules): WIP repacking of modules
1 parent 743773e commit d3871cb

28 files changed

+195
-61
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"conventional-changelog-cli": "^1.2.0",
5353
"es6-module-loader": "^0.17.10",
5454
"es6-shim": "^0.35.0",
55+
"fs-extra": "^4.0.0",
5556
"gulp": "^3.9.0",
5657
"gulp-jasmine": "^2.2.1",
5758
"gulp-typescript": "^2.10.0",

src/angularfire2_worker_app.ts

-9
This file was deleted.

src/angularfire2_worker_render.ts

-17
This file was deleted.

src/app/index.ts

-1
This file was deleted.

src/app/package.json

-1
This file was deleted.

src/auth.ts

-2
This file was deleted.

src/auth/auth.module.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { NgModule, NgZone } from '@angular/core';
22
import * as firebase from 'firebase/app';
33
import 'firebase/auth';
4-
import { FirebaseApp } from '../app/index';
5-
import { AngularFireModule } from '../angularfire2';
4+
import { FirebaseApp, AngularFireModule } from '../core';
65
import { AngularFireAuth } from './auth';
76

87
export function _getAngularFireAuth(app: FirebaseApp) {

src/auth/auth.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { TestBed, inject } from '@angular/core/testing';
77
import { _do } from 'rxjs/operator/do';
88
import { take } from 'rxjs/operator/take';
99
import { skip } from 'rxjs/operator/skip';
10-
import { FirebaseApp, FirebaseAppConfig, AngularFireModule } from '../angularfire2';
10+
import { FirebaseApp, FirebaseAppConfig, AngularFireModule } from '../core';
1111
import { AngularFireAuth } from './auth';
1212
import { AngularFireAuthModule } from './auth.module';
1313
import { COMMON_CONFIG } from '../test-config';

src/auth/auth.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Auth } from '../interfaces';
66
import { Observable } from 'rxjs/Observable';
77
import { Observer } from 'rxjs/Observer';
88
import { observeOn } from 'rxjs/operator/observeOn';
9-
import { FirebaseApp } from '../app/index';
9+
import { FirebaseApp } from '../core';
1010

1111
@Injectable()
1212
export class AngularFireAuth {

src/auth/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './auth';
2+
export * from './auth.module';

src/auth/tsconfig-build.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"compilerOptions": {
3+
"experimentalDecorators": true,
4+
"emitDecoratorMetadata": true,
5+
"module": "es2015",
6+
"target": "es2015",
7+
"noImplicitAny": false,
8+
"outDir": "../../dist/packages/auth",
9+
"rootDir": ".",
10+
"sourceMap": true,
11+
"inlineSources": true,
12+
"declaration": true,
13+
"removeComments": true,
14+
"strictNullChecks": true,
15+
"lib": [
16+
"es2015",
17+
"dom"
18+
],
19+
"skipLibCheck": true,
20+
"moduleResolution": "node"
21+
},
22+
"files": [
23+
"index.ts",
24+
"../../node_modules/zone.js/dist/zone.js.d.ts"
25+
],
26+
"angularCompilerOptions": {
27+
"skipTemplateCodegen": true,
28+
"strictMetadataEmit": true
29+
}
30+
}

src/auth/tsconfig-esm.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "tsconfig-build.json",
3+
"compilerOptions": {
4+
"target": "es5",
5+
"outDir": "../../dist/packages-dist/auth"
6+
}
7+
}

src/angularfire2.spec.ts renamed to src/core/angularfire2.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { TestBed, inject, withModule, async } from '@angular/core/testing';
33
import { ReflectiveInjector, Provider, PlatformRef, NgModule, Compiler, ApplicationRef, CompilerFactory } from '@angular/core';
44
import { FirebaseApp, FirebaseAppConfig, AngularFireModule } from './angularfire2';
55
import { Subscription } from 'rxjs/Subscription';
6-
import { COMMON_CONFIG } from './test-config';
6+
import { COMMON_CONFIG } from '../test-config';
77
import { BrowserModule } from '@angular/platform-browser';
88

99
describe('angularfire', () => {

src/angularfire2.ts renamed to src/core/angularfire2.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
import * as firebase from 'firebase/app';
2-
import * as utils from './utils';
3-
import { FirebaseAppConfigToken, FirebaseApp, _firebaseAppFactory } from './app/index';
4-
import { FirebaseListFactoryOpts, FirebaseObjectFactoryOpts, FirebaseAppConfig } from './interfaces';
2+
import { FirebaseAppConfigToken, FirebaseApp, _firebaseAppFactory } from './firebase.app.module';
53
import { Injectable, InjectionToken, OpaqueToken, NgModule } from '@angular/core';
64

5+
export interface FirebaseAppConfig {
6+
apiKey?: string;
7+
authDomain?: string;
8+
databaseURL?: string;
9+
storageBucket?: string;
10+
messagingSenderId?: string;
11+
projectId?: string;
12+
}
13+
714
const FirebaseAppName = new InjectionToken<string>('FirebaseAppName');
815

916
export const FirebaseAppProvider = {
@@ -27,4 +34,4 @@ export class AngularFireModule {
2734
}
2835
}
2936

30-
export { FirebaseApp, FirebaseAppName, FirebaseAppConfigToken, FirebaseAppConfig };
37+
export { FirebaseApp, FirebaseAppName, FirebaseAppConfigToken };

src/app/firebase.app.module.ts renamed to src/core/firebase.app.module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { InjectionToken, } from '@angular/core';
2-
import { FirebaseAppConfig } from '../interfaces';
2+
import { FirebaseAppConfig } from './';
33
import * as firebase from 'firebase/app';
44

55
export const FirebaseAppConfigToken = new InjectionToken<FirebaseAppConfig>('FirebaseAppConfigToken');

src/core/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './angularfire2';

src/core/package.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "angularfire2",
3+
"version": "4.0.0-rc.1",
4+
"description": "The core module",
5+
"main": "../../bundles/core.umd.js",
6+
"module": "index.es5.js",
7+
"es2015": "index.js",
8+
"keywords": [
9+
"angular",
10+
"firebase",
11+
"rxjs"
12+
],
13+
"repository": {
14+
"type": "git",
15+
"url": "git+https://github.com/angular/angularfire2.git"
16+
},
17+
"author": "angular,firebase",
18+
"license": "MIT",
19+
"peerDependencies": {
20+
"@angular/common": "^4.0.0",
21+
"@angular/core": "^4.0.0",
22+
"@angular/platform-browser": "^4.0.0",
23+
"@angular/platform-browser-dynamic": "^4.0.0",
24+
"firebase": "^4.0.0",
25+
"rxjs": "^5.0.1",
26+
"zone.js": "^0.8.0"
27+
},
28+
"typings": "index.d.ts"
29+
}

src/core/tsconfig-build.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"compilerOptions": {
3+
"experimentalDecorators": true,
4+
"emitDecoratorMetadata": true,
5+
"module": "es2015",
6+
"target": "es2015",
7+
"noImplicitAny": false,
8+
"outDir": "../../dist/packages/core",
9+
"rootDir": ".",
10+
"sourceMap": true,
11+
"inlineSources": true,
12+
"declaration": true,
13+
"removeComments": true,
14+
"strictNullChecks": true,
15+
"lib": [
16+
"es2015",
17+
"dom"
18+
],
19+
"skipLibCheck": true,
20+
"moduleResolution": "node"
21+
},
22+
"files": [
23+
"index.ts",
24+
"../../node_modules/zone.js/dist/zone.js.d.ts"
25+
],
26+
"angularCompilerOptions": {
27+
"skipTemplateCodegen": true,
28+
"strictMetadataEmit": true
29+
}
30+
}

src/core/tsconfig-esm.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "tsconfig-build.json",
3+
"compilerOptions": {
4+
"target": "es5",
5+
"outDir": "../../dist/packages-dist/core"
6+
}
7+
}

src/database.ts

-7
This file was deleted.

src/database/database.module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { NgModule } from '@angular/core';
22
import * as firebase from 'firebase/app';
33
import 'firebase/database';
4-
import { AngularFireModule, FirebaseApp } from '../angularfire2';
4+
import { AngularFireModule, FirebaseApp } from '../core';
55
import { AngularFireDatabase } from './database';
66

77
export function _getAngularFireDatabase(app: FirebaseApp) {

src/database/database.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as firebase from 'firebase/app';
22
import 'firebase/database';
33
import { Inject, Injectable } from '@angular/core';
4-
import { FirebaseAppConfigToken, FirebaseAppConfig, FirebaseApp } from '../angularfire2';
4+
import { FirebaseAppConfigToken, FirebaseAppConfig, FirebaseApp } from '../core';
55
import { FirebaseListFactory } from './firebase_list_factory';
66
import { FirebaseListObservable } from './firebase_list_observable';
77
import { FirebaseListFactoryOpts, FirebaseObjectFactoryOpts, PathReference } from '../interfaces';

src/database/index.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export * from './database';
2+
export * from './firebase_list_factory';
3+
export * from './firebase_list_observable';
4+
export * from './firebase_object_factory';
5+
export * from './firebase_object_observable';
6+
export * from './query_observable';
7+
export * from './database.module';

src/database/tsconfig-build.json

Whitespace-only changes.

src/index.ts

-1
This file was deleted.

src/interfaces.ts

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
import * as firebase from 'firebase/app';
22
import { Observable } from 'rxjs/Observable';
33

4-
export interface FirebaseAppConfig {
5-
apiKey?: string;
6-
authDomain?: string;
7-
databaseURL?: string;
8-
storageBucket?: string;
9-
messagingSenderId?: string;
10-
projectId?: string;
11-
}
12-
134
export interface FirebaseOperationCases {
145
stringCase: () => firebase.Promise<void>;
156
firebaseCase?: () => firebase.Promise<void>;
@@ -95,4 +86,4 @@ export type DatabaseReference = firebase.database.Reference;
9586
export type DatabaseQuery = firebase.database.Query;
9687
export type QueryReference = DatabaseReference | DatabaseQuery;
9788
export type PathReference = QueryReference | string;
98-
export type Auth = firebase.auth.Auth;
89+
export type Auth = firebase.auth.Auth;

src/test-root.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import './angularfire2.spec';
1+
import './core/angularfire2.spec';
22
import './database/firebase_list_factory.spec';
33
import './database/firebase_object_factory.spec';
44
import './database/firebase_list_observable.spec';

tools/build.js

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// TS -> ES2015 -> ES5 -> UMD
2+
3+
// tsc -> tsc -p -> rollup
4+
5+
const { rollup } = require('rollup');
6+
const { spawn } = require('child_process');
7+
const { Observable } = require('rxjs');
8+
const { copy } = require('fs-extra');
9+
10+
function spawnObservable(command, args) {
11+
return Observable.create(observer => {
12+
const cmd = spawn(command, args);
13+
observer.next('');
14+
cmd.stdout.on('data', (data) => { observer.next(data.toString('utf8')); });
15+
cmd.stderr.on('data', (data) => { observer.error(data.toString('utf8')); });
16+
cmd.on('close', (data) => { observer.complete(); });
17+
});
18+
}
19+
20+
function createUmd(module) {
21+
return rollup({
22+
entry: `${process.cwd()}/dist/packages/${module}/index.js`
23+
})
24+
.then(bundle => {
25+
const result = bundle.generate({
26+
format: 'umd',
27+
moduleName: 'angularfire2'
28+
});
29+
return bundle.write({
30+
format: 'umd',
31+
dest: `${process.cwd()}/dist/bundles/${module}.umd.js`,
32+
moduleName: 'angularfire2'
33+
});
34+
});
35+
}
36+
37+
function getSrcPackageFile(module) {
38+
return `${process.cwd()}/src/${module}/package.json`;
39+
}
40+
41+
function getDestPackageFile(module) {
42+
return `${process.cwd()}/dist/packages/${module}/package.json`;
43+
}
44+
45+
function buildModule(name) {
46+
const module$ = spawnObservable('node_modules/.bin/tsc', [`-p`, `${process.cwd()}/src/${name}/tsconfig-build.json`]);
47+
// Run tsc -> copy files -> run rollup
48+
return module$
49+
.mergeMap(() => {
50+
return Observable.from(copy(getSrcPackageFile(name), getDestPackageFile(name)))
51+
})
52+
.mergeMap(() => {
53+
return Observable.from(createUmd(name))
54+
});
55+
}
56+
57+
buildModule('core').subscribe(
58+
data => { console.log(data) },
59+
err => { console.log(err) },
60+
() => { console.log('complete') }
61+
);

0 commit comments

Comments
 (0)