diff --git a/integration/firebase-typings/index.submodules.ts b/integration/firebase-typings/index.submodules.ts new file mode 100644 index 00000000000..1ae7b0ca4d3 --- /dev/null +++ b/integration/firebase-typings/index.submodules.ts @@ -0,0 +1,29 @@ +/** + * Copyright 2017 Google Inc. + * + * 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 * as firebase from 'firebase/app'; + +/** + * Verifying the namespace types are properly exposed from the `firebase` + * package + */ +let app: firebase.app.App; +let auth: firebase.auth.Auth; +let database: firebase.database.Database; +let firestore: firebase.firestore.Firestore; +let functions: firebase.functions.Functions; +let messaging: firebase.messaging.Messaging; +let storage: firebase.storage.Storage; diff --git a/integration/firebase-typings/index.ts b/integration/firebase-typings/index.ts index 631cd339b33..7803000ec96 100644 --- a/integration/firebase-typings/index.ts +++ b/integration/firebase-typings/index.ts @@ -21,7 +21,9 @@ import * as firebase from 'firebase'; * package */ let app: firebase.app.App; +let auth: firebase.auth.Auth; let database: firebase.database.Database; let firestore: firebase.firestore.Firestore; +let functions: firebase.functions.Functions; let messaging: firebase.messaging.Messaging; let storage: firebase.storage.Storage; diff --git a/packages/firebase/app/index.node.ts b/packages/app/index.node.ts similarity index 77% rename from packages/firebase/app/index.node.ts rename to packages/app/index.node.ts index f4ab6cdd777..9ecb14ea400 100644 --- a/packages/firebase/app/index.node.ts +++ b/packages/app/index.node.ts @@ -1,5 +1,5 @@ /** - * Copyright 2018 Google Inc. + * Copyright 2017 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,13 +14,13 @@ * limitations under the License. */ -import '@firebase/polyfill'; -import firebase from '@firebase/app'; +import { FirebaseNamespace } from '@firebase/app-types'; import { _FirebaseNamespace } from '@firebase/app-types/private'; +import { createFirebaseNamespace } from './src/firebaseApp'; import Storage from 'dom-storage'; import { XMLHttpRequest } from 'xmlhttprequest'; -const _firebase = firebase as _FirebaseNamespace; +const _firebase = createFirebaseNamespace() as _FirebaseNamespace; _firebase.INTERNAL.extendNamespace({ INTERNAL: { @@ -32,4 +32,6 @@ _firebase.INTERNAL.extendNamespace({ } }); +export const firebase = _firebase as FirebaseNamespace; + export default firebase; diff --git a/packages/firebase/app/index.rn.ts b/packages/app/index.rn.ts similarity index 78% rename from packages/firebase/app/index.rn.ts rename to packages/app/index.rn.ts index 5b76cabd76d..45c692498ab 100644 --- a/packages/firebase/app/index.rn.ts +++ b/packages/app/index.rn.ts @@ -1,5 +1,5 @@ /** - * Copyright 2018 Google Inc. + * Copyright 2017 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,9 +14,9 @@ * limitations under the License. */ -import '@firebase/polyfill'; -import firebase from '@firebase/app'; +import { FirebaseNamespace } from '@firebase/app-types'; import { _FirebaseNamespace } from '@firebase/app-types/private'; +import { createFirebaseNamespace } from './src/firebaseApp'; /** * To avoid having to include the @types/react-native package, which breaks @@ -25,7 +25,7 @@ import { _FirebaseNamespace } from '@firebase/app-types/private'; */ const { AsyncStorage } = require('react-native'); -const _firebase = firebase as _FirebaseNamespace; +const _firebase = createFirebaseNamespace() as _FirebaseNamespace; _firebase.INTERNAL.extendNamespace({ INTERNAL: { @@ -35,4 +35,6 @@ _firebase.INTERNAL.extendNamespace({ } }); +export const firebase = _firebase as FirebaseNamespace; + export default firebase; diff --git a/packages/app/package.json b/packages/app/package.json index 13ce95a4e30..98583dc8606 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -3,8 +3,10 @@ "version": "0.3.0", "description": "The primary entrypoint to the Firebase JS SDK", "author": "Firebase (https://firebase.google.com/)", - "main": "dist/index.cjs.js", + "main": "dist/index.node.cjs.js", + "browser": "dist/index.cjs.js", "module": "dist/index.esm.js", + "react-native": "dist/index.rn.cjs.js", "files": [ "dist" ], @@ -21,7 +23,9 @@ "dependencies": { "@firebase/app-types": "0.3.0", "@firebase/util": "0.2.0", - "tslib": "1.9.0" + "tslib": "1.9.0", + "dom-storage": "2.1.0", + "xmlhttprequest": "1.8.0" }, "devDependencies": { "@types/chai": "4.1.2", diff --git a/packages/app/rollup.config.js b/packages/app/rollup.config.js index 6b2fdb91623..b40f8b57027 100644 --- a/packages/app/rollup.config.js +++ b/packages/app/rollup.config.js @@ -39,12 +39,32 @@ const plugins = [ const external = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -export default { - input: 'index.ts', - output: [ - { file: pkg.main, format: 'cjs' }, - { file: pkg.module, format: 'es' } - ], - plugins, - external -}; +export default [ + { + input: 'index.ts', + output: [ + { file: pkg.browser, format: 'cjs' }, + { file: pkg.module, format: 'es' } + ], + plugins, + external + }, + { + input: 'index.node.ts', + output: { + file: pkg.main, + format: 'cjs' + }, + plugins, + external + }, + { + input: 'index.rn.ts', + output: { + file: pkg['react-native'], + format: 'cjs' + }, + plugins, + external: [...external, 'react-native'] + } +]; diff --git a/packages/firebase/.gitignore b/packages/firebase/.gitignore index ccb614b6e4d..8bda5ffc95e 100644 --- a/packages/firebase/.gitignore +++ b/packages/firebase/.gitignore @@ -2,4 +2,3 @@ /firebase*.map /firebase*.gz /firebase*.tgz -*/*.d.ts diff --git a/packages/firebase/app/package.json b/packages/firebase/app/package.json index eb6892bca60..0c618a657c8 100644 --- a/packages/firebase/app/package.json +++ b/packages/firebase/app/package.json @@ -1,8 +1,6 @@ { "name": "firebase/app", - "main": "dist/index.node.cjs.js", - "browser": "dist/index.cjs.js", - "react-native": "dist/index.rn.cjs.js", + "main": "dist/index.cjs.js", "module": "dist/index.esm.js", - "typings": "dist/app/index.d.ts" + "typings": "../index.d.ts" } diff --git a/packages/firebase/auth/package.json b/packages/firebase/auth/package.json index 1dbe586d615..c8087a423f4 100644 --- a/packages/firebase/auth/package.json +++ b/packages/firebase/auth/package.json @@ -1,6 +1,5 @@ { "name": "firebase/auth", "main": "dist/index.cjs.js", - "module": "dist/index.esm.js", - "typings": "dist/auth/index.d.ts" + "module": "dist/index.esm.js" } diff --git a/packages/firebase/database/package.json b/packages/firebase/database/package.json index 27bc93abf00..a8bbb715f92 100644 --- a/packages/firebase/database/package.json +++ b/packages/firebase/database/package.json @@ -1,6 +1,5 @@ { "name": "firebase/database", "main": "dist/index.cjs.js", - "module": "dist/index.esm.js", - "typings": "dist/database/index.d.ts" + "module": "dist/index.esm.js" } diff --git a/packages/firebase/firestore/package.json b/packages/firebase/firestore/package.json index e9a48aeffef..2da50651476 100644 --- a/packages/firebase/firestore/package.json +++ b/packages/firebase/firestore/package.json @@ -1,6 +1,5 @@ { "name": "firebase/firestore", "main": "dist/index.cjs.js", - "module": "dist/index.esm.js", - "typings": "dist/firestore/index.d.ts" + "module": "dist/index.esm.js" } diff --git a/packages/firebase/functions/package.json b/packages/firebase/functions/package.json index 28be10c3dd5..09db1de5f48 100644 --- a/packages/firebase/functions/package.json +++ b/packages/firebase/functions/package.json @@ -1,6 +1,5 @@ { "name": "firebase/functions", "main": "dist/index.cjs.js", - "module": "dist/index.esm.js", - "typings": "dist/functions/index.d.ts" + "module": "dist/index.esm.js" } diff --git a/packages/firebase/messaging/package.json b/packages/firebase/messaging/package.json index b0a0852722f..465ed16e03f 100644 --- a/packages/firebase/messaging/package.json +++ b/packages/firebase/messaging/package.json @@ -1,6 +1,5 @@ { "name": "firebase/messaging", "main": "dist/index.cjs.js", - "module": "dist/index.esm.js", - "typings": "dist/messaging/index.d.ts" + "module": "dist/index.esm.js" } diff --git a/packages/firebase/package.json b/packages/firebase/package.json index ecdc1a1339d..f3395bd5ffe 100644 --- a/packages/firebase/package.json +++ b/packages/firebase/package.json @@ -34,9 +34,7 @@ "@firebase/functions": "0.2.1", "@firebase/messaging": "0.3.1", "@firebase/polyfill": "0.3.1", - "@firebase/storage": "0.2.1", - "dom-storage": "2.1.0", - "xmlhttprequest": "1.8.0" + "@firebase/storage": "0.2.1" }, "devDependencies": { "rollup": "0.57.1", diff --git a/packages/firebase/rollup.config.js b/packages/firebase/rollup.config.js index 73725db8ba1..9246d2ca7a5 100644 --- a/packages/firebase/rollup.config.js +++ b/packages/firebase/rollup.config.js @@ -54,60 +54,6 @@ const external = Object.keys(pkg.dependencies || {}); */ const GLOBAL_NAME = 'firebase'; -/** - * Complete Package Builds - */ -const completeBuilds = [ - /** - * App Browser Builds - */ - { - input: 'src/index.module.ts', - output: [ - { file: pkg.browser, format: 'cjs' }, - { file: pkg.module, format: 'es' } - ], - plugins, - external - }, - { - input: 'src/index.cdn.ts', - output: { - file: 'firebase.js', - format: 'umd', - name: GLOBAL_NAME - }, - plugins: [...plugins, uglify()] - }, - /** - * App Node.js Builds - */ - { - input: 'src/index.node.ts', - output: { file: pkg.main, format: 'cjs' }, - plugins: [ - resolveModule({ - module: false, - jsnext: false - }), - typescript({ - typescript: require('typescript') - }), - commonjs() - ], - external - }, - /** - * App React Native Builds - */ - { - input: 'src/index.rn.ts', - output: { file: pkg['react-native'], format: 'cjs' }, - plugins, - external: [...external, 'react-native'] - } -]; - /** * Individual Component Builds */ @@ -118,39 +64,12 @@ const appBuilds = [ { input: 'app/index.ts', output: [ - { file: resolve('app', appPkg.browser), format: 'cjs' }, + { file: resolve('app', appPkg.main), format: 'cjs' }, { file: resolve('app', appPkg.module), format: 'es' } ], plugins, external }, - /** - * App Node.js Builds - */ - { - input: 'app/index.node.ts', - output: { file: resolve('app', appPkg.main), format: 'cjs' }, - plugins: [ - resolveModule({ - module: false, - jsnext: false - }), - typescript({ - typescript: require('typescript') - }), - commonjs() - ], - external - }, - /** - * App React Native Builds - */ - { - input: 'app/index.rn.ts', - output: { file: resolve('app', appPkg['react-native']), format: 'cjs' }, - plugins, - external: [...external, 'react-native'] - }, /** * App UMD Builds */ @@ -214,4 +133,49 @@ const componentBuilds = components }) .reduce((a, b) => a.concat(b), []); -export default [...completeBuilds, ...appBuilds, ...componentBuilds]; +/** + * Complete Package Builds + */ +const completeBuilds = [ + /** + * App Browser Builds + */ + { + input: 'src/index.ts', + output: [ + { file: pkg.browser, format: 'cjs' }, + { file: pkg.module, format: 'es' } + ], + plugins, + external + }, + { + input: 'src/index.cdn.ts', + output: { + file: 'firebase.js', + format: 'umd', + name: GLOBAL_NAME + }, + plugins: [...plugins, uglify()] + }, + /** + * App Node.js Builds + */ + { + input: 'src/index.node.ts', + output: { file: pkg.main, format: 'cjs' }, + plugins, + external + }, + /** + * App React Native Builds + */ + { + input: 'src/index.rn.ts', + output: { file: pkg['react-native'], format: 'cjs' }, + plugins, + external + } +]; + +export default [...appBuilds, ...componentBuilds, ...completeBuilds]; diff --git a/packages/firebase/src/index.module.ts b/packages/firebase/src/index.ts similarity index 100% rename from packages/firebase/src/index.module.ts rename to packages/firebase/src/index.ts diff --git a/packages/firebase/storage/package.json b/packages/firebase/storage/package.json index e1b27303fd0..af51acb3a46 100644 --- a/packages/firebase/storage/package.json +++ b/packages/firebase/storage/package.json @@ -1,6 +1,5 @@ { "name": "firebase/storage", "main": "dist/index.cjs.js", - "module": "dist/index.esm.js", - "typings": "dist/storage/index.d.ts" + "module": "dist/index.esm.js" } diff --git a/packages/firebase/tsconfig.json b/packages/firebase/tsconfig.json index 4079e6112f8..3484a18da7a 100644 --- a/packages/firebase/tsconfig.json +++ b/packages/firebase/tsconfig.json @@ -2,6 +2,8 @@ "extends": "../../config/tsconfig.base.json", "compilerOptions": { "outDir": "dist", + "declaration": false, + "allowSyntheticDefaultImports": true }, "exclude": [ "dist/**/*"