Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependencies for Angular Universal #1377

Merged
merged 4 commits into from
Feb 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@angular/core": "^5.0.0",
"@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"bufferutil": "^3.0.3",
"@firebase/app": "^0.1.6",
"@firebase/app-types": "^0.1.1",
"@firebase/auth": "^0.3.2",
Expand All @@ -47,7 +48,10 @@
"@firebase/storage-types": "^0.1.1",
"firebase": "^4.8.2",
"rxjs": "^5.5.4",
"zone.js": "^0.8.0"
"utf-8-validate": "^4.0.0",
"ws": "^3.3.2",
"zone.js": "^0.8.0",
"xmlhttprequest": "^1.8.0"
},
"devDependencies": {
"@angular/compiler-cli": "^5.0.0",
Expand Down
4 changes: 4 additions & 0 deletions src/firebase-node/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Patches for loading angularfire in a Universal Context

global['WebSocket'] = require("ws");
global['XMLHttpRequest'] = require("xmlhttprequest").XMLHttpRequest;
25 changes: 25 additions & 0 deletions src/firebase-node/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "angularfire2",
"version": "ANGULARFIRE2_VERSION",
"description": "Fixes for Node.js",
"main": "index.js",
"keywords": [
"angular",
"firebase",
"rxjs"
],
"repository": {
"type": "git",
"url": "git+https://github.com/angular/angularfire2.git"
},
"author": "angular,firebase",
"license": "MIT",
"peerDependencies": {
"xmlhttprequest": "XMLHTTPREQUEST_VERSION",
"ws": "WS_VERSION",
"bufferutil": "BUFFERUTIL_VERSION",
"utf-8-validate": "UTF_8_VALIDATE_VERSION"
},
"typings": "index.d.ts"
}

15 changes: 14 additions & 1 deletion tools/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ const VERSIONS = {
RXJS_VERSION: pkg.dependencies['rxjs'],
ZONEJS_VERSION: pkg.dependencies['zone.js'],
ANGULARFIRE2_VERSION: pkg.version,
FIRESTORE_VERSION: pkg.dependencies['firestore']
FIRESTORE_VERSION: pkg.dependencies['firestore'],
WS_VERSION: pkg.dependencies['ws'],
BUFFERUTIL_VERSION: pkg.dependencies['bufferutil'],
UTF_8_VALIDATE_VERSION: pkg.dependencies['utf-8-validate'],
XMLHTTPREQUEST_VERSION: pkg.dependencies['xmlhttprequest']
};

const MODULE_NAMES = {
Expand All @@ -114,6 +118,7 @@ const SRC_PKG_PATHS = {
database: `${process.cwd()}/src/database/package.json`,
"database-deprecated": `${process.cwd()}/src/database-deprecated/package.json`,
firestore: `${process.cwd()}/src/firestore/package.json`,
"firebase-node": `${process.cwd()}/src/firebase-node/package.json`,
storage: `${process.cwd()}/src/storage/package.json`
};

Expand All @@ -123,6 +128,7 @@ const DEST_PKG_PATHS = {
database: `${process.cwd()}/dist/packages-dist/database/package.json`,
"database-deprecated": `${process.cwd()}/dist/packages-dist/database-deprecated/package.json`,
firestore: `${process.cwd()}/dist/packages-dist/firestore/package.json`,
"firebase-node": `${process.cwd()}/dist/packages-dist/firebase-node/package.json`,
storage: `${process.cwd()}/dist/packages-dist/storage/package.json`
};

Expand Down Expand Up @@ -268,6 +274,10 @@ function copyDocs() {
return copy(`${process.cwd()}/docs`, `${process.cwd()}/dist/packages-dist/docs`);
}

function copyNodeFixes() {
return copy(`${process.cwd()}/src/firebase-node`, `${process.cwd()}/dist/packages-dist/firebase-node`);
}

function measure(module) {
const path = `${process.cwd()}/dist/packages-dist/bundles/${module}.umd.js`;
const file = readFileSync(path);
Expand All @@ -286,6 +296,7 @@ function getVersions() {
getDestPackageFile('auth'),
getDestPackageFile('database'),
getDestPackageFile('firestore'),
getDestPackageFile('firebase-node'),
getDestPackageFile('storage'),
getDestPackageFile('database-deprecated')
];
Expand Down Expand Up @@ -343,6 +354,8 @@ function buildLibrary(globals) {
.switchMap(() => Observable.from(copyNpmIgnore()))
.switchMap(() => Observable.from(copyReadme()))
.switchMap(() => Observable.from(copyDocs()))
.switchMap(() => Observable.from(copyNodeFixes()))
.switchMap(() => replaceVersionsObservable('firebase-node', VERSIONS))
.do(() => {
const coreStats = measure('core');
const authStats = measure('auth');
Expand Down
Loading