Skip to content

Commit 694a299

Browse files
authored
Make the exp release script support new packages (#4139)
* update exp release script * remove unneeded imports * compile functions * build remote config compat * make firstore exp release work again * revert * revert more
1 parent 5682141 commit 694a299

File tree

7 files changed

+143
-41
lines changed

7 files changed

+143
-41
lines changed

packages-exp/functions-compat/src/register.ts

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import firebase from '@firebase/app-compat';
1919
import { _FirebaseNamespace } from '@firebase/app-types/private';
2020
import { FunctionsService } from './service';
21-
import '@firebase/functions-exp';
2221
import {
2322
Component,
2423
ComponentType,

packages-exp/remote-config-compat/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
1414
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
1515
"build": "rollup -c",
16-
"build:release": "yarn build",
16+
"build:release": "rollup -c rollup.config.release.js",
1717
"build:deps": "lerna run --scope @firebase/remote-config-compat --include-dependencies build",
1818
"dev": "rollup -c -w",
1919
"test": "run-p lint test:all",

packages-exp/remote-config-compat/rollup.config.js

+1-34
Original file line numberDiff line numberDiff line change
@@ -18,40 +18,7 @@
1818
import typescriptPlugin from 'rollup-plugin-typescript2';
1919
import typescript from 'typescript';
2020
import json from '@rollup/plugin-json';
21-
import pkg from './package.json';
22-
23-
const deps = Object.keys(
24-
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
25-
);
26-
27-
export const es5BuildsNoPlugin = [
28-
/**
29-
* Browser Builds
30-
*/
31-
{
32-
input: 'src/index.ts',
33-
output: [
34-
{ file: pkg.main, format: 'cjs', sourcemap: true },
35-
{ file: pkg.browser, format: 'es', sourcemap: true }
36-
],
37-
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
38-
}
39-
];
40-
41-
export const es2017BuildsNoPlugin = [
42-
/**
43-
* Browser Builds
44-
*/
45-
{
46-
input: 'src/index.ts',
47-
output: {
48-
file: pkg.esm2017,
49-
format: 'es',
50-
sourcemap: true
51-
},
52-
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
53-
}
54-
];
21+
import { es5BuildsNoPlugin, es2017BuildsNoPlugin } from './rollup.shared.js';
5522

5623
/**
5724
* ES5 Builds
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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 typescriptPlugin from 'rollup-plugin-typescript2';
19+
import typescript from 'typescript';
20+
import json from '@rollup/plugin-json';
21+
import { es5BuildsNoPlugin, es2017BuildsNoPlugin } from './rollup.shared.js';
22+
import { importPathTransformer } from '../../scripts/exp/ts-transform-import-path';
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+
}));
41+
42+
/**
43+
* ES2017 Builds
44+
*/
45+
const es2017BuildPlugins = [
46+
typescriptPlugin({
47+
typescript,
48+
tsconfigOverride: {
49+
compilerOptions: {
50+
target: 'es2017'
51+
}
52+
},
53+
clean: true,
54+
abortOnError: false,
55+
transformers: [importPathTransformer]
56+
}),
57+
json({
58+
preferConst: true
59+
})
60+
];
61+
62+
const es2017Builds = es2017BuildsNoPlugin.map(build => ({
63+
...build,
64+
plugins: es2017BuildPlugins
65+
}));
66+
67+
export default [...es5Builds, ...es2017Builds];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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 pkg from './package.json';
19+
20+
const deps = Object.keys(
21+
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
22+
);
23+
24+
export const es5BuildsNoPlugin = [
25+
/**
26+
* Browser Builds
27+
*/
28+
{
29+
input: 'src/index.ts',
30+
output: [
31+
{ file: pkg.main, format: 'cjs', sourcemap: true },
32+
{ file: pkg.browser, format: 'es', sourcemap: true }
33+
],
34+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
35+
}
36+
];
37+
38+
export const es2017BuildsNoPlugin = [
39+
/**
40+
* Browser Builds
41+
*/
42+
{
43+
input: 'src/index.ts',
44+
output: {
45+
file: pkg.esm2017,
46+
format: 'es',
47+
sourcemap: true
48+
},
49+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
50+
}
51+
];

packages/firestore/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"api-report:exp": "(cd exp; api-extractor run --local --verbose) && TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' ts-node ../../repo-scripts/prune-dts/prune-dts.ts --input dist/exp/private.d.ts --output dist/exp/index.d.ts",
1111
"api-report:lite": "(cd lite; api-extractor run --local --verbose) && TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' ts-node ../../repo-scripts/prune-dts/prune-dts.ts --input dist/lite/private.d.ts --output dist/lite/index.d.ts",
1212
"bundle": "rollup -c",
13-
"prebuild": "tsc --emitDeclarationOnly --declaration -p tsconfig.json && run-p api-report:exp api-report:lite",
13+
"prebuild": "tsc --emitDeclarationOnly --declaration -p tsconfig.json; run-p api-report:exp api-report:lite",
1414
"build": "run-p 'bundle rollup.config.browser.js' 'bundle rollup.config.browser.memory.js' 'bundle rollup.config.node.js' 'bundle rollup.config.node.memory.js' 'bundle rollup.config.rn.js' 'bundle rollup.config.rn.memory.js' build:lite build:exp",
1515
"build:scripts": "tsc -moduleResolution node --module commonjs scripts/*.ts && ls scripts/*.js | xargs -I % sh -c 'terser % -o %'",
1616
"prebuild:release": "yarn prebuild",
@@ -20,6 +20,7 @@
2020
"build:exp": "rollup -c rollup.config.exp.js",
2121
"build:lite": "rollup -c rollup.config.lite.js",
2222
"build:exp:release": "yarn build:exp && yarn build:lite",
23+
"postbuild:exp:release": "node ../../scripts/exp/remove-exp.js dist/exp/index.d.ts && node ../../scripts/exp/remove-exp.js dist/lite/index.d.ts",
2324
"predev": "yarn prebuild",
2425
"dev": "rollup -c -w",
2526
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
@@ -109,4 +110,4 @@
109110
],
110111
"reportDir": "./coverage/node"
111112
}
112-
}
113+
}

scripts/exp/release.ts

+20-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ async function publishExpPackages({ dryRun }: { dryRun: boolean }) {
4747
/**
4848
* Welcome to the firebase release CLI!
4949
*/
50-
console.log('Welcome to the Firebase Exp Packages release CLI!');
50+
console.log(
51+
`Welcome to the Firebase Exp Packages release CLI! dryRun: ${dryRun}`
52+
);
5153

5254
/**
5355
* Update fields in package.json and stuff
@@ -76,7 +78,7 @@ async function publishExpPackages({ dryRun }: { dryRun: boolean }) {
7678
* since the last release. This simplifies the script and works fine for exp packages.
7779
*
7880
* 2. Removes -exp in package names because we will publish them using
79-
* the existing package names under a special release tag (e.g. firebase@exp).
81+
* the existing package names under a special release tag (firebase@exp).
8082
*/
8183
const versions = await updatePackageNamesAndVersions(packagePaths);
8284

@@ -138,9 +140,15 @@ async function buildPackages() {
138140
'run',
139141
'--scope',
140142
// We replace `@firebase/app-exp` with `@firebase/app` during compilation, so we need to
141-
// compile @firebase/app to make rollup happy though it's not an actual dependency.
143+
// compile @firebase/app first to make rollup happy though it's not an actual dependency.
142144
'@firebase/app',
143145
'--scope',
146+
// the same reason above
147+
'@firebase/functions',
148+
'--scope',
149+
// the same reason above
150+
'@firebase/remote-config',
151+
'--scope',
144152
'@firebase/util',
145153
'--scope',
146154
'@firebase/component',
@@ -176,6 +184,15 @@ async function buildPackages() {
176184

177185
// Build exp packages developed in place
178186
// Firestore
187+
await spawn(
188+
'yarn',
189+
['lerna', 'run', '--scope', '@firebase/firestore', 'prebuild'],
190+
{
191+
cwd: projectRoot,
192+
stdio: 'inherit'
193+
}
194+
);
195+
179196
await spawn(
180197
'yarn',
181198
['lerna', 'run', '--scope', '@firebase/firestore', 'build:exp:release'],

0 commit comments

Comments
 (0)