Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

Commit 04d303a

Browse files
jamesdanielsmyspivey
authored andcommitted
feat(): Dependencies for Angular Universal
Added WS and xmlhttprequest as dependencies, as they are required to allow normal functions of the Firebase JS SDK in Universal. Created a new `angularfire/firebase-node` module, which includes these + will include any additional fixes for Universal in the future. The rest of the SSR work is taking place in angular#1454.
1 parent ec82fa2 commit 04d303a

File tree

5 files changed

+183
-10
lines changed

5 files changed

+183
-10
lines changed

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"@angular/core": "^5.0.0",
3535
"@angular/platform-browser": "^5.0.0",
3636
"@angular/platform-browser-dynamic": "^5.0.0",
37+
"bufferutil": "^3.0.3",
3738
"@firebase/app": "^0.1.6",
3839
"@firebase/app-types": "^0.1.1",
3940
"@firebase/auth": "^0.3.2",
@@ -47,7 +48,10 @@
4748
"@firebase/storage-types": "^0.1.1",
4849
"firebase": "^4.8.2",
4950
"rxjs": "^5.5.4",
50-
"zone.js": "^0.8.0"
51+
"utf-8-validate": "^4.0.0",
52+
"ws": "^3.3.2",
53+
"zone.js": "^0.8.0",
54+
"xmlhttprequest": "^1.8.0"
5155
},
5256
"devDependencies": {
5357
"@angular/compiler-cli": "^5.0.0",

src/firebase-node/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Patches for loading angularfire in a Universal Context
2+
3+
global['WebSocket'] = require("ws");
4+
global['XMLHttpRequest'] = require("xmlhttprequest").XMLHttpRequest;

src/firebase-node/package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "angularfire2",
3+
"version": "ANGULARFIRE2_VERSION",
4+
"description": "Fixes for Node.js",
5+
"main": "index.js",
6+
"keywords": [
7+
"angular",
8+
"firebase",
9+
"rxjs"
10+
],
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/angular/angularfire2.git"
14+
},
15+
"author": "angular,firebase",
16+
"license": "MIT",
17+
"peerDependencies": {
18+
"xmlhttprequest": "XMLHTTPREQUEST_VERSION",
19+
"ws": "WS_VERSION",
20+
"bufferutil": "BUFFERUTIL_VERSION",
21+
"utf-8-validate": "UTF_8_VALIDATE_VERSION"
22+
},
23+
"typings": "index.d.ts"
24+
}
25+

tools/build.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ const VERSIONS = {
8787
RXJS_VERSION: pkg.dependencies['rxjs'],
8888
ZONEJS_VERSION: pkg.dependencies['zone.js'],
8989
ANGULARFIRE2_VERSION: pkg.version,
90-
FIRESTORE_VERSION: pkg.dependencies['firestore']
90+
FIRESTORE_VERSION: pkg.dependencies['firestore'],
91+
WS_VERSION: pkg.dependencies['ws'],
92+
BUFFERUTIL_VERSION: pkg.dependencies['bufferutil'],
93+
UTF_8_VALIDATE_VERSION: pkg.dependencies['utf-8-validate'],
94+
XMLHTTPREQUEST_VERSION: pkg.dependencies['xmlhttprequest']
9195
};
9296

9397
const MODULE_NAMES = {
@@ -114,6 +118,7 @@ const SRC_PKG_PATHS = {
114118
database: `${process.cwd()}/src/database/package.json`,
115119
"database-deprecated": `${process.cwd()}/src/database-deprecated/package.json`,
116120
firestore: `${process.cwd()}/src/firestore/package.json`,
121+
"firebase-node": `${process.cwd()}/src/firebase-node/package.json`,
117122
storage: `${process.cwd()}/src/storage/package.json`
118123
};
119124

@@ -123,6 +128,7 @@ const DEST_PKG_PATHS = {
123128
database: `${process.cwd()}/dist/packages-dist/database/package.json`,
124129
"database-deprecated": `${process.cwd()}/dist/packages-dist/database-deprecated/package.json`,
125130
firestore: `${process.cwd()}/dist/packages-dist/firestore/package.json`,
131+
"firebase-node": `${process.cwd()}/dist/packages-dist/firebase-node/package.json`,
126132
storage: `${process.cwd()}/dist/packages-dist/storage/package.json`
127133
};
128134

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

277+
function copyNodeFixes() {
278+
return copy(`${process.cwd()}/src/firebase-node`, `${process.cwd()}/dist/packages-dist/firebase-node`);
279+
}
280+
271281
function measure(module) {
272282
const path = `${process.cwd()}/dist/packages-dist/bundles/${module}.umd.js`;
273283
const file = readFileSync(path);
@@ -286,6 +296,7 @@ function getVersions() {
286296
getDestPackageFile('auth'),
287297
getDestPackageFile('database'),
288298
getDestPackageFile('firestore'),
299+
getDestPackageFile('firebase-node'),
289300
getDestPackageFile('storage'),
290301
getDestPackageFile('database-deprecated')
291302
];
@@ -343,6 +354,8 @@ function buildLibrary(globals) {
343354
.switchMap(() => Observable.from(copyNpmIgnore()))
344355
.switchMap(() => Observable.from(copyReadme()))
345356
.switchMap(() => Observable.from(copyDocs()))
357+
.switchMap(() => Observable.from(copyNodeFixes()))
358+
.switchMap(() => replaceVersionsObservable('firebase-node', VERSIONS))
346359
.do(() => {
347360
const coreStats = measure('core');
348361
const authStats = measure('auth');

0 commit comments

Comments
 (0)