Skip to content

Commit f0ddca0

Browse files
committed
compat release build
1 parent 4716a30 commit f0ddca0

File tree

3 files changed

+102
-2
lines changed

3 files changed

+102
-2
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import { resolve } from 'path';
19+
import sourcemaps from 'rollup-plugin-sourcemaps';
20+
import rollupTypescriptPlugin from 'rollup-plugin-typescript2';
21+
import typescript from 'typescript';
22+
import json from 'rollup-plugin-json';
23+
import pkg from '../package.json';
24+
import compatPkg from './package.json';
25+
import appPkg from './app/package.json';
26+
27+
const external = Object.keys(pkg.dependencies || {});
28+
29+
const plugins = [sourcemaps(), json()];
30+
31+
const typescriptPlugin = rollupTypescriptPlugin({
32+
typescript,
33+
tsconfigOverride: {
34+
compilerOptions: {
35+
declaration: false
36+
}
37+
}
38+
});
39+
40+
/**
41+
* Individual Component Builds
42+
*/
43+
const appBuilds = [
44+
/**
45+
* App Browser Builds
46+
*/
47+
{
48+
input: `${__dirname}/app/index.ts`,
49+
output: [
50+
{
51+
file: resolve(__dirname, 'app', appPkg.main),
52+
format: 'cjs',
53+
sourcemap: true
54+
},
55+
{
56+
file: resolve(__dirname, 'app', appPkg.module),
57+
format: 'es',
58+
sourcemap: true
59+
}
60+
],
61+
plugins: [...plugins, typescriptPlugin],
62+
external
63+
}
64+
];
65+
66+
const componentBuilds = compatPkg.components
67+
// The "app" component is treated differently because it doesn't depend on itself.
68+
.filter(component => component !== 'app')
69+
.map(component => {
70+
const pkg = require(`${__dirname}/${component}/package.json`);
71+
return [
72+
{
73+
input: `${__dirname}/${component}/index.ts`,
74+
output: [
75+
{
76+
file: resolve(__dirname, component, pkg.main),
77+
format: 'cjs',
78+
sourcemap: true
79+
},
80+
{
81+
file: resolve(__dirname, component, pkg.module),
82+
format: 'es',
83+
sourcemap: true
84+
}
85+
],
86+
plugins: [...plugins, typescriptPlugin],
87+
external
88+
}
89+
];
90+
})
91+
.reduce((a, b) => a.concat(b), []);
92+
93+
export default [...appBuilds, ...componentBuilds];

packages-exp/firebase-exp/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@
2828
},
2929
"scripts": {
3030
"build": "rollup -c && gulp firebase-js && yarn build:compat",
31-
"build:release": "rollup -c rollup.config.release.js && gulp firebase-js && yarn build:compat",
31+
"build:release": "rollup -c rollup.config.release.js && gulp firebase-js && yarn build:compat:release",
3232
"build:compat": "rollup -c compat/rollup.config.js",
33+
"build:compat:release": "rollup -c compat/rollup.config.release.js",
3334
"dev": "rollup -c -w",
3435
"prepare": "yarn build:release",
3536
"test": "echo 'No test suite for firebase wrapper'",

packages-exp/firebase-exp/rollup.config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ const componentBuilds = pkg.components
116116
.filter(component => component !== 'app')
117117
.map(component => {
118118
const pkg = require(`./${component}/package.json`);
119+
// It is needed for handling sub modules, for example firestore/lite which should produce firebase-firestore-lite.js
120+
// Otherwise, we will create a directory with '/' in the name.
121+
const componentName = component.replace('/', '-');
119122
return [
120123
{
121124
input: `${component}/index.ts`,
@@ -136,7 +139,10 @@ const componentBuilds = pkg.components
136139
},
137140
{
138141
input: `${component}/index.ts`,
139-
output: createUmdOutputConfig(`firebase-${component}.js`, component),
142+
output: createUmdOutputConfig(
143+
`firebase-${componentName}.js`,
144+
componentName
145+
),
140146
plugins: [...plugins, typescriptPluginUMD, uglify()],
141147
external: ['@firebase/app-exp']
142148
}

0 commit comments

Comments
 (0)