Skip to content

Commit 7459712

Browse files
committed
add firebase compat
1 parent a23564f commit 7459712

File tree

16 files changed

+521
-35
lines changed

16 files changed

+521
-35
lines changed

.changeset/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"@firebase/app-types-exp",
1818
"@firebase/functions-exp",
1919
"@firebase/functions-types-exp",
20-
"firebase-exp"
20+
"firebase-exp",
21+
"@firebase/app-compat"
2122
],
2223
"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
2324
"onlyUpdatePeerDependentsWhenOutOfRange": true,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"scripts": {
2424
"dev": "lerna run --parallel --scope @firebase/* --scope firebase --scope rxfire dev",
2525
"build": "lerna run --scope @firebase/app-exp build:deps && lerna run --scope @firebase/* --scope firebase --scope rxfire --ignore @firebase/app-exp build",
26-
"build:exp": "lerna run --scope @firebase/*-exp --scope firebase-exp build",
26+
"build:exp": "lerna run --scope @firebase/*-exp --scope @firebase/*-compat --scope firebase-exp build",
2727
"build:release": "lerna run --scope @firebase/app-exp build:deps && lerna run --scope @firebase/* --scope firebase --scope rxfire --ignore @firebase/*-exp prepare",
2828
"build:exp:release": "yarn --cwd packages/app build:deps && lerna run --scope @firebase/*-exp --scope firebase-exp prepare && yarn --cwd packages-exp/app-exp typings:public",
2929
"link:packages": "lerna exec --scope @firebase/* --scope firebase --scope rxfire -- yarn link",

packages-exp/app-compat/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.0.800",
44
"description": "The primary entrypoint to the Firebase JS SDK",
55
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
6+
"private": true,
67
"main": "dist/index.cjs.js",
78
"browser": "dist/index.esm5.js",
89
"module": "dist/index.esm5.js",

packages-exp/app-exp/src/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717

1818
import { name as appName } from '../package.json';
19+
import { name as appCompatName } from '../../app-compat/package.json';
1920
import { name as analyticsName } from '../../../packages/analytics/package.json';
2021
import { name as authName } from '../../../packages/auth/package.json';
2122
import { name as databaseName } from '../../../packages/database/package.json';
@@ -37,6 +38,7 @@ export const DEFAULT_ENTRY_NAME = '[DEFAULT]';
3738

3839
export const PLATFORM_LOG_STRING = {
3940
[appName]: 'fire-core',
41+
[appCompatName]: 'fire-core-compat',
4042
[analyticsName]: 'fire-analytics',
4143
[authName]: 'fire-auth',
4244
[databaseName]: 'fire-rtdb',
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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 firebase from '@firebase/app-compat';
19+
import { name, version } from '../../package.json';
20+
21+
firebase.registerVersion(name, version, 'app-compat-cdn');
22+
23+
export default firebase;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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 firebase from '@firebase/app-compat';
19+
import { name, version } from '../../package.json';
20+
21+
firebase.registerVersion(name, version, 'app-compat');
22+
23+
export default firebase;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "firebase-exp/compat/app",
3+
"main": "dist/index.cjs.js",
4+
"browser": "dist/index.esm.js",
5+
"module": "dist/index.esm.js",
6+
"typings": "dist/compat/app/index.d.ts"
7+
}
8+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* @license
3+
* Copyright 2017 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+
console.warn(`
19+
It looks like you're using the development build of the Firebase JS SDK.
20+
When deploying Firebase apps to production, it is advisable to only import
21+
the individual SDK components you intend to use.
22+
23+
For the CDN builds, these are available in the following manner
24+
(replace <PACKAGE> with the name of a component - i.e. auth, database, etc):
25+
26+
https://www.gstatic.com/firebasejs/5.0.0/firebase-<PACKAGE>.js
27+
`);
28+
29+
import '@firebase/polyfill';
30+
import firebase from './app';
31+
import { name, version } from '../package.json';
32+
33+
// import './auth';
34+
// import './database';
35+
// import './firestore';
36+
// import './functions';
37+
// import './messaging';
38+
// import './storage';
39+
// import './performance';
40+
// import './analytics';
41+
// import './remote-config';
42+
43+
firebase.registerVersion(name, version, 'compat-cdn');
44+
45+
export default firebase;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* @license
3+
* Copyright 2017 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 firebase from './app';
19+
import { name, version } from '../package.json';
20+
21+
// import './auth';
22+
// import './database';
23+
// import './firestore';
24+
// import './functions';
25+
26+
firebase.registerVersion(name, version, 'compat-node');
27+
28+
export default firebase;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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 firebase from './app';
19+
// import './performance';
20+
import { name, version } from '../package.json';
21+
22+
firebase.registerVersion(name, version, 'compat-lite');
23+
24+
export default firebase;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* @license
3+
* Copyright 2017 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 firebase from './app';
19+
import { name, version } from '../package.json';
20+
21+
// import './auth';
22+
// import './database';
23+
// // TODO(b/158625454): Storage doesn't actually work by default in RN (it uses
24+
// // `atob`). We should provide a RN build that works out of the box.
25+
// import './storage';
26+
// import './firestore';
27+
28+
firebase.registerVersion(name, version, 'compat-rn');
29+
30+
export default firebase;
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* @license
3+
* Copyright 2017 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+
console.warn(`
19+
It looks like you're using the development build of the Firebase JS SDK.
20+
When deploying Firebase apps to production, it is advisable to only import
21+
the individual SDK components you intend to use.
22+
23+
For the module builds, these are available in the following manner
24+
(replace <PACKAGE> with the name of a component - i.e. auth, database, etc):
25+
26+
CommonJS Modules:
27+
const firebase = require('firebase/app');
28+
require('firebase/<PACKAGE>');
29+
30+
ES Modules:
31+
import firebase from 'firebase/app';
32+
import 'firebase/<PACKAGE>';
33+
34+
Typescript:
35+
import * as firebase from 'firebase/app';
36+
import 'firebase/<PACKAGE>';
37+
`);
38+
39+
import firebase from './app';
40+
import { name, version } from '../package.json';
41+
42+
// import './auth';
43+
// import './database';
44+
// import './firestore';
45+
// import './functions';
46+
// import './messaging';
47+
// import './storage';
48+
// import './performance';
49+
// import './analytics';
50+
// import './remote-config';
51+
52+
firebase.registerVersion(name, version, 'compat');
53+
54+
export default firebase;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "firebase-exp/compat",
3+
"main": "dist/index.node.cjs.js",
4+
"browser": "dist/index.esm.js",
5+
"module": "dist/index.esm.js",
6+
"react-native": "dist/index.rn.cjs.js",
7+
"typings": "index.d.ts",
8+
"components": [
9+
"app"
10+
]
11+
}

0 commit comments

Comments
 (0)