diff --git a/packages/app-check-interop-types/index.d.ts b/packages/app-check-interop-types/index.d.ts index cc16c5e4680..504c63c5819 100644 --- a/packages/app-check-interop-types/index.d.ts +++ b/packages/app-check-interop-types/index.d.ts @@ -34,10 +34,10 @@ export interface FirebaseAppCheckInternal { removeTokenListener(listener: AppCheckTokenListener): void; } -type AppCheckTokenListener = (token: AppCheckTokenResult) => void; +export type AppCheckTokenListener = (token: AppCheckTokenResult) => void; // If the error field is defined, the token field will be populated with a dummy token -interface AppCheckTokenResult { +export interface AppCheckTokenResult { readonly token: string; readonly error?: Error; } diff --git a/packages/firebase/.gitignore b/packages/firebase/.gitignore index 228443ec909..ea616f7f428 100644 --- a/packages/firebase/.gitignore +++ b/packages/firebase/.gitignore @@ -1,4 +1,6 @@ /firebase*.js /firebase*.map /firebase*.gz -/firebase*.tgz \ No newline at end of file +/firebase*.tgz +/custom/*.d.ts +/packages \ No newline at end of file diff --git a/packages/firebase/custom/analytics-remote-config.ts b/packages/firebase/custom/analytics-remote-config.ts new file mode 100644 index 00000000000..db11a53fd3f --- /dev/null +++ b/packages/firebase/custom/analytics-remote-config.ts @@ -0,0 +1,23 @@ +/** + * @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 { registerVersion } from '@firebase/app'; +import { version } from '../package.json'; + +export * as app from '@firebase/app'; +export * as analytics from '@firebase/analytics'; +export * as remoteConfig from '@firebase/remote-config'; diff --git a/packages/firebase/custom/index.all.ts b/packages/firebase/custom/index.all.ts new file mode 100644 index 00000000000..2ad81407664 --- /dev/null +++ b/packages/firebase/custom/index.all.ts @@ -0,0 +1,34 @@ +/** + * @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 { registerVersion } from '@firebase/app'; +import { version } from '../package.json'; + +registerVersion('fire-js-all', version, 'cdn'); +export * as app from '@firebase/app'; +export * as ai from '@firebase/ai'; +export * as analytics from '@firebase/analytics'; +export * as appCheck from '@firebase/app-check'; +export * as auth from '@firebase/auth'; +export * as dataConnect from '@firebase/data-connect'; +export * as database from '@firebase/database'; +export * as firestore from '@firebase/firestore'; +export * as functions from '@firebase/functions'; +export * as installations from '@firebase/installations'; +export * as messaging from '@firebase/messaging'; +export * as performance from '@firebase/performance'; +export * as remoteConfig from '@firebase/remote-config'; diff --git a/packages/firebase/package.json b/packages/firebase/package.json index 4f785d15c8c..aa107876e57 100644 --- a/packages/firebase/package.json +++ b/packages/firebase/package.json @@ -403,7 +403,7 @@ }, "scripts": { "build": "rollup -c && gulp cdn-type-module-path && yarn build:compat", - "build:internal": "rollup -c && gulp cdn-type-module-path-internal && yarn build:compat", + "build:internal": "rollup -c rollup-internal.config.js && gulp cdn-type-module-path-internal && yarn build:compat", "build:compat": "rollup -c compat/rollup.config.js", "dev": "rollup -c -w", "test": "echo 'No test suite for firebase wrapper'", @@ -446,6 +446,7 @@ "@rollup/plugin-node-resolve": "16.0.0", "rollup-plugin-sourcemaps": "0.6.3", "@rollup/plugin-terser": "0.4.4", + "rollup-plugin-dts": "5.3.1", "rollup-plugin-typescript2": "0.36.0", "rollup-plugin-uglify": "6.0.4", "gulp": "4.0.2", diff --git a/packages/firebase/rollup-internal.config.js b/packages/firebase/rollup-internal.config.js index 7511a41a502..cba458bae92 100644 --- a/packages/firebase/rollup-internal.config.js +++ b/packages/firebase/rollup-internal.config.js @@ -21,8 +21,23 @@ */ // When run in google3, original rollup.config.js will have been renamed to rollup-main.config.js. -import baseBuilds from './rollup-main.config.js'; +import { cdnBuilds, plugins } from './rollup.config.js'; import license from 'rollup-plugin-license'; +import typescript from 'typescript'; +import rollupTypescriptPlugin from 'rollup-plugin-typescript2'; +import dts from 'rollup-plugin-dts'; +import { parse } from 'path'; + +const typescriptPluginCustom = rollupTypescriptPlugin({ + typescript, + allowJs: true, + include: ['*.ts', '**/*.ts', '*.js', '**/*.js'], + tsconfigOverride: { + compilerOptions: { + declaration: true + } + } +}); const firebaseLicense = license({ banner: `@license @@ -30,10 +45,52 @@ const firebaseLicense = license({ SPDX-License-Identifier: Apache-2.0` }); -const buildsWithLicense = baseBuilds.map(build => { +const buildsWithLicense = cdnBuilds.map(build => { return Object.assign({}, build, { plugins: build.plugins.concat(firebaseLicense) }); }); -export default buildsWithLicense; +/** + * Custom builds that include combinations of multiple products. + */ +const customBuilds = [ + { inputFile: 'custom/index.all.ts', outputFile: 'firebase.js' }, + { + inputFile: 'custom/analytics-remote-config.ts', + outputFile: 'firebase-analytics-rc.js' + } +] + .map(build => { + const { dir, name } = parse(build.inputFile); + console.log(`${dir}/${name}.d.ts`); + console.log(`dist/${name}.global.d.ts`); + return [ + { + input: build.inputFile, + output: { + file: build.outputFile, + sourcemap: true, + format: 'es' + }, + plugins: [...plugins, typescriptPluginCustom, firebaseLicense] + }, + { + input: `${dir}/${name}.d.ts`, + output: { + file: `dist/${name}.global.d.ts`, + format: 'es' + }, + plugins: [ + dts({ + respectExternal: true + }) + ] + } + ]; + }) + .flat(); + +console.log(customBuilds.length); + +export default [/*...buildsWithLicense,*/ ...customBuilds]; diff --git a/packages/firebase/rollup.config.js b/packages/firebase/rollup.config.js index f96ff01666c..849bb394ef1 100644 --- a/packages/firebase/rollup.config.js +++ b/packages/firebase/rollup.config.js @@ -134,7 +134,7 @@ const componentBuilds = pkg.components /** * CDN script builds */ -const cdnBuilds = [ +export const cdnBuilds = [ { input: 'app/index.cdn.ts', output: { @@ -175,4 +175,6 @@ const cdnBuilds = [ }) ]; +export { plugins }; + export default [...appBuilds, ...componentBuilds, ...cdnBuilds];