Skip to content

Commit f8f0902

Browse files
authored
Fixes for database and analytics exp release (#4321)
* add database to firebase-exp * release database exp * do not abort on error for exp build * add release build to analytics exp * build hackery * remove prepare from analytics-exp
1 parent d8d1384 commit f8f0902

File tree

10 files changed

+248
-29
lines changed

10 files changed

+248
-29
lines changed

packages-exp/analytics-exp/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
1313
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
1414
"build": "rollup -c && yarn api-report",
15+
"build:release": "rollup -c rollup.config.release.js && yarn api-report",
1516
"build:deps": "lerna run --scope @firebase/analytics-exp --include-dependencies build",
1617
"dev": "rollup -c -w",
1718
"test": "run-p lint test:all",
1819
"test:all": "run-p test:browser test:integration",
1920
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test:all",
2021
"test:browser": "karma start --single-run --nocache",
2122
"test:integration": "karma start ./karma.integration.conf.js --single-run --nocache",
22-
"prepare": "yarn build",
2323
"api-report": "api-extractor run --local --verbose",
2424
"predoc": "node ../../scripts/exp/remove-exp.js temp",
2525
"doc": "api-documenter markdown --input temp --output docs",

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

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import json from '@rollup/plugin-json';
1919
import typescriptPlugin from 'rollup-plugin-typescript2';
2020
import typescript from 'typescript';
2121
import pkg from './package.json';
22+
import { es2017BuildsNoPlugin, es5BuildsNoPlugin } from './rollup.shared';
2223

2324
const deps = Object.keys(
2425
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
@@ -34,20 +35,13 @@ const es5BuildPlugins = [
3435
json()
3536
];
3637

37-
const es5Builds = [
38-
/**
39-
* Browser Builds
40-
*/
41-
{
42-
input: './src/index.ts',
43-
output: [
44-
{ file: pkg.main, format: 'cjs', sourcemap: true },
45-
{ file: pkg.module, format: 'es', sourcemap: true }
46-
],
47-
plugins: es5BuildPlugins,
48-
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
38+
const es5Builds = es5BuildsNoPlugin.map(build => ({
39+
...build,
40+
plugins: es5BuildPlugins,
41+
treeshake: {
42+
moduleSideEffects: false
4943
}
50-
];
44+
}));
5145

5246
/**
5347
* ES2017 Builds
@@ -64,20 +58,12 @@ const es2017BuildPlugins = [
6458
json({ preferConst: true })
6559
];
6660

67-
const es2017Builds = [
68-
/**
69-
* Browser Builds
70-
*/
71-
{
72-
input: './src/index.ts',
73-
output: {
74-
file: pkg.esm2017,
75-
format: 'es',
76-
sourcemap: true
77-
},
78-
plugins: es2017BuildPlugins,
79-
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
61+
const es2017Builds = es2017BuildsNoPlugin.map(build => ({
62+
...build,
63+
plugins: es2017BuildPlugins,
64+
treeshake: {
65+
moduleSideEffects: false
8066
}
81-
];
67+
}));
8268

8369
export default [...es5Builds, ...es2017Builds];
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/**
2+
* @license
3+
* Copyright 2019 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 typescriptPlugin from 'rollup-plugin-typescript2';
19+
import typescript from 'typescript';
20+
import json from '@rollup/plugin-json';
21+
import { importPathTransformer } from '../../scripts/exp/ts-transform-import-path';
22+
import { es2017BuildsNoPlugin, es5BuildsNoPlugin } from './rollup.shared';
23+
24+
/**
25+
* ES5 Builds
26+
*/
27+
const es5BuildPlugins = [
28+
typescriptPlugin({
29+
typescript,
30+
clean: true,
31+
abortOnError: false,
32+
transformers: [importPathTransformer]
33+
}),
34+
json()
35+
];
36+
37+
const es5Builds = es5BuildsNoPlugin.map(build => ({
38+
...build,
39+
plugins: es5BuildPlugins,
40+
treeshake: {
41+
moduleSideEffects: false
42+
}
43+
}));
44+
45+
/**
46+
* ES2017 Builds
47+
*/
48+
const es2017BuildPlugins = [
49+
typescriptPlugin({
50+
typescript,
51+
tsconfigOverride: {
52+
compilerOptions: {
53+
target: 'es2017'
54+
}
55+
},
56+
abortOnError: false,
57+
clean: true,
58+
transformers: [importPathTransformer]
59+
}),
60+
json({
61+
preferConst: true
62+
})
63+
];
64+
65+
const es2017Builds = es2017BuildsNoPlugin.map(build => ({
66+
...build,
67+
plugins: es2017BuildPlugins,
68+
treeshake: {
69+
moduleSideEffects: false
70+
}
71+
}));
72+
73+
export default [...es5Builds, ...es2017Builds];
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* @license
3+
* Copyright 2018 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+
import pkg from './package.json';
18+
19+
const deps = Object.keys(
20+
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
21+
);
22+
23+
export const es5BuildsNoPlugin = [
24+
/**
25+
* Browser Builds
26+
*/
27+
{
28+
input: 'src/index.ts',
29+
output: [
30+
{ file: pkg.main, format: 'cjs', sourcemap: true },
31+
{ file: pkg.module, format: 'es', sourcemap: true }
32+
],
33+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
34+
}
35+
];
36+
37+
/**
38+
* ES2017 Builds
39+
*/
40+
export const es2017BuildsNoPlugin = [
41+
{
42+
/**
43+
* Browser Build
44+
*/
45+
input: 'src/index.ts',
46+
output: {
47+
file: pkg.esm2017,
48+
format: 'es',
49+
sourcemap: true
50+
},
51+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
52+
}
53+
];
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
export * from '@firebase/database';
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "firebase-exp/database",
3+
"main": "dist/index.cjs.js",
4+
"browser": "dist/index.esm.js",
5+
"module": "dist/index.esm.js",
6+
"typings": "dist/firestore/index.d.ts"
7+
}
8+

packages-exp/firebase-exp/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"storage",
7171
"performance",
7272
"remote-config",
73-
"messaging"
73+
"messaging",
74+
"database"
7475
]
7576
}

packages/database/rollup.config.exp.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const deps = Object.keys(
3333
const es5BuildPlugins = [
3434
typescriptPlugin({
3535
typescript,
36+
abortOnError: false,
3637
transformers: [importPathTransformer]
3738
}),
3839
json()
@@ -74,6 +75,7 @@ const es2017BuildPlugins = [
7475
target: 'es2017'
7576
}
7677
},
78+
abortOnError: false,
7779
transformers: [importPathTransformer]
7880
}),
7981
json({ preferConst: true })
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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 { projectRoot, readPackageJson } from '../utils';
19+
import { writeFile as _writeFile, readFile as _readFile } from 'fs';
20+
import { promisify } from 'util';
21+
22+
const writeFile = promisify(_writeFile);
23+
const packagePath = `${projectRoot}/packages/database`;
24+
25+
/**
26+
* Transform package.json in @firebase/database so that we can use scripts/exp/release.ts to release Database exp.
27+
* It does following things:
28+
* 1. Update package.json to point to exp binaries
29+
* 2. Update version to '0.0.900', the version number we choose for releasing exp packages
30+
* (9 stands for v9, 900 to avoid conflict with official versions).
31+
* The release script will append commit hash to it and release the package with that version.
32+
* e.g. 0.0.900-exp.fe85035e1
33+
* 3. Replace peerDependencies with the exp version, so the release script can match and update them to the correct version.
34+
*/
35+
export async function prepare() {
36+
// Update package.json
37+
const packageJson = await readPackageJson(packagePath);
38+
const expPackageJson = await readPackageJson(`${packagePath}/exp`);
39+
packageJson.version = '0.0.900';
40+
41+
packageJson.peerDependencies = {
42+
'@firebase/app-exp': '0.x',
43+
'@firebase/app-types-exp': '0.x'
44+
};
45+
46+
packageJson.main = expPackageJson.main.replace('../', '');
47+
packageJson.module = expPackageJson.module.replace('../', '');
48+
packageJson.browser = expPackageJson.browser.replace('../', '');
49+
packageJson.esm2017 = expPackageJson.esm2017.replace('../', '');
50+
51+
packageJson.typings = expPackageJson.typings.replace('../', '');
52+
53+
// include files to be published
54+
packageJson.files = [...packageJson.files, packageJson.typings];
55+
56+
// update package.json files
57+
await writeFile(
58+
`${packagePath}/package.json`,
59+
`${JSON.stringify(packageJson, null, 2)}\n`,
60+
{ encoding: 'utf-8' }
61+
);
62+
}

scripts/exp/release.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import chalk from 'chalk';
3030
import Listr from 'listr';
3131
import { prepare as prepareFirestoreForRelease } from './prepare-firestore-for-exp-release';
3232
import { prepare as prepareStorageForRelease } from './prepare-storage-for-exp-release';
33+
import { prepare as prepareDatabaseForRelease } from './prepare-database-for-exp-release';
3334
import * as yargs from 'yargs';
3435

3536
const prompt = createPromptModule();
@@ -60,6 +61,7 @@ async function publishExpPackages({ dryRun }: { dryRun: boolean }) {
6061
*/
6162
await prepareFirestoreForRelease();
6263
await prepareStorageForRelease();
64+
await prepareDatabaseForRelease();
6365

6466
/**
6567
* build packages
@@ -73,6 +75,7 @@ async function publishExpPackages({ dryRun }: { dryRun: boolean }) {
7375

7476
packagePaths.push(`${projectRoot}/packages/firestore`);
7577
packagePaths.push(`${projectRoot}/packages/storage`);
78+
packagePaths.push(`${projectRoot}/packages/database`);
7679

7780
/**
7881
* It does 2 things:
@@ -195,6 +198,9 @@ async function buildPackages() {
195198
// the same reason above
196199
'@firebase/remote-config',
197200
'--scope',
201+
// the same reason above
202+
'@firebase/analytics',
203+
'--scope',
198204
'@firebase/util',
199205
'--scope',
200206
'@firebase/component',
@@ -258,6 +264,16 @@ async function buildPackages() {
258264
}
259265
);
260266

267+
// Database
268+
await spawn(
269+
'yarn',
270+
['lerna', 'run', '--scope', '@firebase/database', 'build:exp'],
271+
{
272+
cwd: projectRoot,
273+
stdio: 'inherit'
274+
}
275+
);
276+
261277
// remove packages/installations/dist, otherwise packages that depend on packages-exp/installations-exp (e.g. Perf, FCM)
262278
// will incorrectly reference packages/installations.
263279
const installationsDistDirPath = resolve(

0 commit comments

Comments
 (0)