Skip to content

Make the exp release script support new packages #4139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages-exp/functions-compat/src/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import firebase from '@firebase/app-compat';
import { _FirebaseNamespace } from '@firebase/app-types/private';
import { FunctionsService } from './service';
import '@firebase/functions-exp';
import {
Component,
ComponentType,
Expand Down
2 changes: 1 addition & 1 deletion packages-exp/remote-config-compat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
"build": "rollup -c",
"build:release": "yarn build",
"build:release": "rollup -c rollup.config.release.js",
"build:deps": "lerna run --scope @firebase/remote-config-compat --include-dependencies build",
"dev": "rollup -c -w",
"test": "run-p lint test:all",
Expand Down
35 changes: 1 addition & 34 deletions packages-exp/remote-config-compat/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,7 @@
import typescriptPlugin from 'rollup-plugin-typescript2';
import typescript from 'typescript';
import json from '@rollup/plugin-json';
import pkg from './package.json';

const deps = Object.keys(
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
);

export const es5BuildsNoPlugin = [
/**
* Browser Builds
*/
{
input: 'src/index.ts',
output: [
{ file: pkg.main, format: 'cjs', sourcemap: true },
{ file: pkg.browser, format: 'es', sourcemap: true }
],
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
}
];

export const es2017BuildsNoPlugin = [
/**
* Browser Builds
*/
{
input: 'src/index.ts',
output: {
file: pkg.esm2017,
format: 'es',
sourcemap: true
},
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
}
];
import { es5BuildsNoPlugin, es2017BuildsNoPlugin } from './rollup.shared.js';

/**
* ES5 Builds
Expand Down
67 changes: 67 additions & 0 deletions packages-exp/remote-config-compat/rollup.config.release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import typescriptPlugin from 'rollup-plugin-typescript2';
import typescript from 'typescript';
import json from '@rollup/plugin-json';
import { es5BuildsNoPlugin, es2017BuildsNoPlugin } from './rollup.shared.js';
import { importPathTransformer } from '../../scripts/exp/ts-transform-import-path';

/**
* ES5 Builds
*/
const es5BuildPlugins = [
typescriptPlugin({
typescript,
clean: true,
abortOnError: false,
transformers: [importPathTransformer]
}),
json()
];

const es5Builds = es5BuildsNoPlugin.map(build => ({
...build,
plugins: es5BuildPlugins
}));

/**
* ES2017 Builds
*/
const es2017BuildPlugins = [
typescriptPlugin({
typescript,
tsconfigOverride: {
compilerOptions: {
target: 'es2017'
}
},
clean: true,
abortOnError: false,
transformers: [importPathTransformer]
}),
json({
preferConst: true
})
];

const es2017Builds = es2017BuildsNoPlugin.map(build => ({
...build,
plugins: es2017BuildPlugins
}));

export default [...es5Builds, ...es2017Builds];
51 changes: 51 additions & 0 deletions packages-exp/remote-config-compat/rollup.shared.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import pkg from './package.json';

const deps = Object.keys(
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
);

export const es5BuildsNoPlugin = [
/**
* Browser Builds
*/
{
input: 'src/index.ts',
output: [
{ file: pkg.main, format: 'cjs', sourcemap: true },
{ file: pkg.browser, format: 'es', sourcemap: true }
],
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
}
];

export const es2017BuildsNoPlugin = [
/**
* Browser Builds
*/
{
input: 'src/index.ts',
output: {
file: pkg.esm2017,
format: 'es',
sourcemap: true
},
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
}
];
4 changes: 2 additions & 2 deletions packages/firestore/api-extractor.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"extends": "../../config/api-extractor.json",
// Point it to your entry point d.ts file.
"mainEntryPointFilePath": "<projectFolder>/exp-types/index.d.ts",
"mainEntryPointFilePath": "<projectFolder>/dist/exp/index.d.ts",
"additionalEntryPoints": [
{
"modulePath": "lite",
"filePath": "lite-types/index.d.ts"
"filePath": "<projectFolder>/dist/lite/index.d.ts"
}
]
}
5 changes: 3 additions & 2 deletions packages/firestore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"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",
"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",
"bundle": "rollup -c",
"prebuild": "tsc --emitDeclarationOnly --declaration -p tsconfig.json && run-p api-report:exp api-report:lite",
"prebuild": "tsc --emitDeclarationOnly --declaration -p tsconfig.json; run-p api-report:exp api-report:lite",
"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",
"build:scripts": "tsc -moduleResolution node --module commonjs scripts/*.ts && ls scripts/*.js | xargs -I % sh -c 'terser % -o %'",
"build:release": "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'",
Expand All @@ -19,6 +19,7 @@
"build:exp": "rollup -c rollup.config.exp.js",
"build:lite": "rollup -c rollup.config.lite.js",
"build:exp:release": "yarn build:exp && yarn build:lite",
"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",
"predev": "yarn prebuild",
"dev": "rollup -c -w",
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
Expand Down Expand Up @@ -108,4 +109,4 @@
],
"reportDir": "./coverage/node"
}
}
}
23 changes: 20 additions & 3 deletions scripts/exp/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ async function publishExpPackages({ dryRun }: { dryRun: boolean }) {
/**
* Welcome to the firebase release CLI!
*/
console.log('Welcome to the Firebase Exp Packages release CLI!');
console.log(
`Welcome to the Firebase Exp Packages release CLI! dryRun: ${dryRun}`
);

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

Expand Down Expand Up @@ -138,9 +140,15 @@ async function buildPackages() {
'run',
'--scope',
// We replace `@firebase/app-exp` with `@firebase/app` during compilation, so we need to
// compile @firebase/app to make rollup happy though it's not an actual dependency.
// compile @firebase/app first to make rollup happy though it's not an actual dependency.
'@firebase/app',
'--scope',
// the same reason above
'@firebase/functions',
'--scope',
// the same reason above
'@firebase/remote-config',
'--scope',
'@firebase/util',
'--scope',
'@firebase/component',
Expand Down Expand Up @@ -176,6 +184,15 @@ async function buildPackages() {

// Build exp packages developed in place
// Firestore
await spawn(
'yarn',
['lerna', 'run', '--scope', '@firebase/firestore', 'prebuild'],
{
cwd: projectRoot,
stdio: 'inherit'
}
);

await spawn(
'yarn',
['lerna', 'run', '--scope', '@firebase/firestore', 'build:exp:release'],
Expand Down