Skip to content

Commit cb96380

Browse files
committed
firebase Package Build Refactor
1 parent afa2c20 commit cb96380

File tree

8 files changed

+165
-966
lines changed

8 files changed

+165
-966
lines changed

packages/firebase/gulpfile.js

Lines changed: 0 additions & 81 deletions
This file was deleted.

packages/firebase/index.dev.js

Lines changed: 0 additions & 24 deletions
This file was deleted.

packages/firebase/index.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
<!-- This file is for dev purposes only, it is ommitted from the NPM package -->
2-
<html>
3-
<head>
4-
<script src="/firebase-dev.js"></script>
5-
</head>
6-
</html>
1+
<script src="./firebase-app.js"></script>
2+
<script src="./firebase-auth.js"></script>
3+
<script src="./firebase-database.js"></script>
4+
<script src="./firebase-firestore.js"></script>
5+
<script src="./firebase-functions.js"></script>
6+
<script src="./firebase-messaging.js"></script>
7+
<script src="./firebase-storage.js"></script>

packages/firebase/package.json

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@
1818
"url": "https://github.com/firebase/firebase-js-sdk.git"
1919
},
2020
"scripts": {
21-
"dev": "run-p watch:compiler watch:server",
22-
"watch:compiler": "gulp watch",
23-
"watch:server": "webpack-dev-server --config webpack.dev.js --colors",
24-
"prepare": "gulp build"
21+
"build": "rollup -c",
22+
"dev": "rollup -c -w",
23+
"prepare": "npm run build"
2524
},
2625
"main": "index.node.js",
2726
"browser": "index.js",
@@ -39,16 +38,10 @@
3938
"xmlhttprequest": "^1.8.0"
4039
},
4140
"devDependencies": {
42-
"compression-webpack-plugin": "^1.1.7",
43-
"git-rev-sync": "^1.10.0",
44-
"gulp": "^4.0.0",
45-
"gulp-concat": "^2.6.1",
46-
"gulp-sourcemaps": "^2.6.4",
47-
"npm-run-all": "^4.1.1",
48-
"webpack": "^3.11.0",
49-
"webpack-dev-server": "^2.11.1",
50-
"webpack-stream": "^4.0.2",
51-
"wrapper-webpack-plugin": "^1.0.0"
41+
"rollup": "^0.57.1",
42+
"rollup-plugin-commonjs": "^9.1.0",
43+
"rollup-plugin-node-resolve": "^3.3.0",
44+
"rollup-plugin-uglify": "^3.0.0"
5245
},
5346
"typings": "index.d.ts"
5447
}

packages/firebase/rollup.config.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/**
2+
* Copyright 2018 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import resolve from 'rollup-plugin-node-resolve';
18+
import commonjs from 'rollup-plugin-commonjs';
19+
import uglify from 'rollup-plugin-uglify';
20+
import pkg from './package.json';
21+
22+
const plugins = [
23+
resolve(),
24+
commonjs(),
25+
uglify()
26+
];
27+
28+
const GLOBAL_NAME = 'firebase';
29+
30+
/**
31+
* This is the firebase/app level config
32+
*/
33+
const appConfig = {
34+
input: 'app/index.js',
35+
output: {
36+
file: 'firebase-app.js',
37+
format: 'umd',
38+
name: GLOBAL_NAME
39+
},
40+
plugins,
41+
};
42+
43+
/**
44+
* This is the top level `firebase` config
45+
*/
46+
const firebaseJsConfig = {
47+
input: 'index.js',
48+
output: {
49+
file: 'firebase.js',
50+
format: 'umd',
51+
name: GLOBAL_NAME
52+
},
53+
plugins
54+
};
55+
56+
/**
57+
* All of these configs are built to extend the top two configs
58+
*/
59+
const components = ['auth', 'database', 'firestore', 'functions', 'messaging', 'storage'];
60+
61+
const componentsConfig = components.map(component => ({
62+
input: `${component}/index.js`,
63+
output: {
64+
file: `firebase-${component}.js`,
65+
format: 'iife',
66+
extend: true,
67+
name: GLOBAL_NAME,
68+
globals: {
69+
'@firebase/app': GLOBAL_NAME
70+
},
71+
},
72+
plugins,
73+
external: [
74+
'@firebase/app',
75+
]
76+
}));
77+
78+
export default [
79+
appConfig,
80+
...componentsConfig,
81+
firebaseJsConfig
82+
];

packages/firebase/webpack.config.js

Lines changed: 0 additions & 122 deletions
This file was deleted.

0 commit comments

Comments
 (0)