Skip to content

Commit ef1a7d9

Browse files
author
alikn
authored
Create compat package form performance exp (#4522)
* add performance compact package * update dependencies of performance-compact * apply comments * update performance-compat package to remove performance-types-exp as a dependency * Create orange-countries-accept.md * remove changeset as it is not used for exp and compat packages
1 parent 35fdb93 commit ef1a7d9

14 files changed

+568
-0
lines changed

.changeset/config.json

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"@firebase/installations-compat",
2525
"@firebase/messaging-exp",
2626
"@firebase/performance-exp",
27+
"@firebase/performance-compat",
2728
"@firebase/remote-config-exp",
2829
"@firebase/remote-config-compat",
2930
"firebase-exp",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
module.exports = {
19+
extends: '../../config/.eslintrc.js',
20+
parserOptions: {
21+
project: 'tsconfig.json',
22+
// to make vscode-eslint work with monorepo
23+
// https://github.com/typescript-eslint/typescript-eslint/issues/251#issuecomment-463943250
24+
tsconfigRootDir: __dirname
25+
}
26+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# @firebase/performance-compat
2+
3+
This is the compat package that recreates the v8 APIs.
4+
5+
**This package is not intended for direct usage, and should only be used via the officially supported [firebase](https://www.npmjs.com/package/firebase) package.**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
const karmaBase = require('../../config/karma.base');
19+
20+
const files = ['test/**/*', 'src/**/*.test.ts'];
21+
22+
module.exports = function (config) {
23+
const karmaConfig = Object.assign({}, karmaBase, {
24+
// files to load into karma
25+
files: files,
26+
// frameworks to use
27+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
28+
preprocessors: { '**/*.ts': ['webpack', 'sourcemap'] },
29+
frameworks: ['mocha']
30+
});
31+
32+
config.set(karmaConfig);
33+
};
34+
35+
module.exports.files = files;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"name": "@firebase/performance-compat",
3+
"version": "0.0.900",
4+
"description": "The compatibility package of Firebase Performance",
5+
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
6+
"private": true,
7+
"main": "dist/index.cjs.js",
8+
"browser": "dist/index.esm5.js",
9+
"module": "dist/index.esm5.js",
10+
"esm2017": "dist/index.esm2017.js",
11+
"files": ["dist"],
12+
"scripts": {
13+
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
14+
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
15+
"build": "rollup -c",
16+
"build:release": "rollup -c rollup.config.release.js",
17+
"build:deps": "lerna run --scope @firebase/performance-compat --include-dependencies build",
18+
"dev": "rollup -c -w",
19+
"test": "run-p lint test:all",
20+
"test:all": "run-p test:browser",
21+
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test:all",
22+
"test:browser": "karma start --single-run",
23+
"test:browser:debug": "karma start --browsers Chrome --auto-watch",
24+
"prettier": "prettier --write '{src,test}/**/*.{js,ts}'"
25+
},
26+
"license": "Apache-2.0",
27+
"peerDependencies": {
28+
"@firebase/app-compat": "0.x",
29+
"@firebase/app-types": "0.x"
30+
},
31+
"dependencies": {
32+
"@firebase/performance-exp": "0.0.900",
33+
"@firebase/util": "0.4.0",
34+
"@firebase/logger": "0.2.6",
35+
"@firebase/component": "0.2.1",
36+
"tslib": "^2.0.0"
37+
},
38+
"devDependencies": {
39+
"rollup": "2.35.1",
40+
"@rollup/plugin-json": "4.1.0",
41+
"rollup-plugin-replace": "2.2.0",
42+
"rollup-plugin-typescript2": "0.29.0",
43+
"typescript": "4.2.2",
44+
"@firebase/app-compat": "0.0.900"
45+
},
46+
"repository": {
47+
"directory": "packages-exp/performance-compat",
48+
"type": "git",
49+
"url": "https://github.com/firebase/firebase-js-sdk.git"
50+
},
51+
"bugs": {
52+
"url": "https://github.com/firebase/firebase-js-sdk/issues"
53+
},
54+
"typings": "dist/src/index.d.ts",
55+
"nyc": {
56+
"extension": [
57+
".ts"
58+
],
59+
"reportDir": "./coverage/node"
60+
}
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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 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+
23+
/**
24+
* ES5 Builds
25+
*/
26+
const es5BuildPlugins = [
27+
typescriptPlugin({
28+
typescript
29+
}),
30+
json()
31+
];
32+
33+
const es5Builds = es5BuildsNoPlugin.map(build => ({
34+
...build,
35+
plugins: es5BuildPlugins
36+
}));
37+
38+
/**
39+
* ES2017 Builds
40+
*/
41+
const es2017BuildPlugins = [
42+
typescriptPlugin({
43+
typescript,
44+
tsconfigOverride: {
45+
compilerOptions: {
46+
target: 'es2017'
47+
}
48+
}
49+
}),
50+
json({
51+
preferConst: true
52+
})
53+
];
54+
55+
const es2017Builds = es2017BuildsNoPlugin.map(build => ({
56+
...build,
57+
plugins: es2017BuildPlugins
58+
}));
59+
60+
export default [...es5Builds, ...es2017Builds];
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+
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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, { _FirebaseNamespace } from '@firebase/app-compat';
19+
import {
20+
Component,
21+
ComponentContainer,
22+
ComponentType
23+
} from '@firebase/component';
24+
import { PerformanceCompatImpl } from './performance';
25+
import { name as packageName, version } from '../package.json';
26+
import { FirebasePerformance as FirebasePerformanceCompat } from '@firebase/performance-types';
27+
28+
// TODO: move it to the future performance-compat-types package
29+
declare module '@firebase/component' {
30+
interface NameServiceMapping {
31+
'performance-compat': FirebasePerformanceCompat;
32+
}
33+
}
34+
35+
function registerPerformanceCompat(firebaseInstance: _FirebaseNamespace): void {
36+
firebaseInstance.INTERNAL.registerComponent(
37+
new Component(
38+
'performance-compat',
39+
performanceFactory,
40+
ComponentType.PUBLIC
41+
)
42+
);
43+
44+
firebaseInstance.registerVersion(packageName, version);
45+
}
46+
47+
function performanceFactory(
48+
container: ComponentContainer
49+
): PerformanceCompatImpl {
50+
const app = container.getProvider('app-compat').getImmediate();
51+
// The following call will always succeed.
52+
const performance = container.getProvider('performance-exp').getImmediate();
53+
54+
return new PerformanceCompatImpl(app, performance);
55+
}
56+
57+
registerPerformanceCompat(firebase as _FirebaseNamespace);

0 commit comments

Comments
 (0)