Skip to content

Commit a74a1d1

Browse files
authored
Functions compat package (#3739)
1 parent 6ef39d4 commit a74a1d1

File tree

16 files changed

+764
-0
lines changed

16 files changed

+764
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { name as analyticsName } from '../../../packages/analytics/package.json'
2121
import { name as authName } from '../../../packages/auth/package.json';
2222
import { name as databaseName } from '../../../packages/database/package.json';
2323
import { name as functionsName } from '../../../packages-exp/functions-exp/package.json';
24+
import { name as functionsCompatName } from '../../../packages-exp/functions-compat/package.json';
2425
import { name as installationsName } from '../../../packages/installations/package.json';
2526
import { name as messagingName } from '../../../packages/messaging/package.json';
2627
import { name as performanceName } from '../../../packages/performance/package.json';
@@ -43,6 +44,7 @@ export const PLATFORM_LOG_STRING = {
4344
[authName]: 'fire-auth',
4445
[databaseName]: 'fire-rtdb',
4546
[functionsName]: 'fire-fn',
47+
[functionsCompatName]: 'fire-fn-compat',
4648
[installationsName]: 'fire-iid',
4749
[messagingName]: 'fire-fcm',
4850
[performanceName]: 'fire-perf',
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/* eslint-disable @typescript-eslint/no-require-imports */
2+
/**
3+
* @license
4+
* Copyright 2020 Google LLC
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
const path = require('path');
19+
20+
module.exports = {
21+
extends: '../../config/.eslintrc.js',
22+
parserOptions: {
23+
project: 'tsconfig.json',
24+
// to make vscode-eslint work with monorepo
25+
// https://github.com/typescript-eslint/typescript-eslint/issues/251#issuecomment-463943250
26+
tsconfigRootDir: __dirname
27+
},
28+
rules: {
29+
'import/no-extraneous-dependencies': [
30+
'error',
31+
{
32+
'packageDir': [path.resolve(__dirname, '../../'), __dirname],
33+
devDependencies: true
34+
}
35+
]
36+
}
37+
};
Lines changed: 35 additions & 0 deletions
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;
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"name": "@firebase/functions-compat",
3+
"version": "0.0.800",
4+
"description": "",
5+
"private": true,
6+
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
7+
"main": "dist/index.node.cjs.js",
8+
"browser": "dist/index.esm5.js",
9+
"module": "dist/index.esm5.js",
10+
"esm2017": "dist/index.esm2017.js",
11+
"files": [
12+
"dist"
13+
],
14+
"license": "Apache-2.0",
15+
"peerDependencies": {
16+
"@firebase/app-compat": "0.x"
17+
},
18+
"devDependencies": {
19+
"@firebase/app-compat": "0.0.800",
20+
"rollup": "2.29.0",
21+
"@rollup/plugin-json": "4.1.0",
22+
"rollup-plugin-typescript2": "0.27.3",
23+
"typescript": "4.0.2"
24+
},
25+
"repository": {
26+
"directory": "packages-exp/functions-compat",
27+
"type": "git",
28+
"url": "https://github.com/firebase/firebase-js-sdk.git"
29+
},
30+
"bugs": {
31+
"url": "https://github.com/firebase/firebase-js-sdk/issues"
32+
},
33+
"scripts": {
34+
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
35+
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
36+
"build": "rollup -c",
37+
"build:deps": "lerna run --scope @firebase/functions-compat --include-dependencies build",
38+
"build:release": "rollup -c rollup.config.release.js",
39+
"dev": "rollup -c -w",
40+
"test": "run-p lint test:all",
41+
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test:all",
42+
"test:all": "run-p test:browser test:node",
43+
"test:browser": "karma start --single-run",
44+
"test:browser:debug": "karma start --browsers=Chrome --auto-watch",
45+
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'src/{,!(browser)/**/}*.test.ts' --file src/index.node.ts --config ../../config/mocharc.node.js",
46+
"test:emulator": "env FIREBASE_FUNCTIONS_HOST=http://localhost FIREBASE_FUNCTIONS_PORT=5005 run-p test:node",
47+
"prepare": "yarn build:release"
48+
},
49+
"typings": "dist/functions-compat-public.d.ts",
50+
"dependencies": {
51+
"@firebase/component": "0.1.20",
52+
"@firebase/functions-exp": "0.0.800",
53+
"@firebase/functions-types-exp": "0.0.800",
54+
"@firebase/messaging-types": "0.5.0",
55+
"@firebase/util": "0.3.3",
56+
"tslib": "^1.11.1"
57+
},
58+
"nyc": {
59+
"extension": [
60+
".ts"
61+
],
62+
"reportDir": "./coverage/node"
63+
}
64+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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 json from '@rollup/plugin-json';
19+
import typescriptPlugin from 'rollup-plugin-typescript2';
20+
import typescript from 'typescript';
21+
import pkg from './package.json';
22+
23+
const deps = Object.keys(
24+
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
25+
);
26+
27+
/**
28+
* ES5 Builds
29+
*/
30+
export function getEs5Builds(additionalTypescriptPlugins = {}) {
31+
const es5BuildPlugins = [
32+
typescriptPlugin({
33+
typescript,
34+
abortOnError: false,
35+
...additionalTypescriptPlugins
36+
}),
37+
json()
38+
];
39+
return [
40+
/**
41+
* Browser Builds
42+
*/
43+
{
44+
input: 'src/index.ts',
45+
output: [{ file: pkg.module, format: 'es', sourcemap: true }],
46+
plugins: es5BuildPlugins,
47+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
48+
},
49+
/**
50+
* Node.js Build
51+
*/
52+
{
53+
input: 'src/index.node.ts',
54+
output: [{ file: pkg.main, format: 'cjs', sourcemap: true }],
55+
plugins: es5BuildPlugins,
56+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
57+
}
58+
];
59+
}
60+
61+
/**
62+
* ES2017 Builds
63+
*/
64+
export function getEs2017Builds(additionalTypescriptPlugins = {}) {
65+
const es2017BuildPlugins = [
66+
typescriptPlugin({
67+
typescript,
68+
abortOnError: false,
69+
tsconfigOverride: {
70+
compilerOptions: {
71+
target: 'es2017'
72+
}
73+
},
74+
...additionalTypescriptPlugins
75+
}),
76+
json({ preferConst: true })
77+
];
78+
return [
79+
{
80+
/**
81+
* Browser Build
82+
*/
83+
input: 'src/index.ts',
84+
output: {
85+
file: pkg.esm2017,
86+
format: 'es',
87+
sourcemap: true
88+
},
89+
plugins: es2017BuildPlugins,
90+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
91+
}
92+
];
93+
}
94+
95+
export function getAllBuilds(additionalTypescriptPlugins = {}) {
96+
return [
97+
...getEs5Builds(additionalTypescriptPlugins),
98+
...getEs2017Builds(additionalTypescriptPlugins)
99+
];
100+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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 { getAllBuilds } from './rollup.config.base';
19+
20+
// eslint-disable-next-line import/no-default-export
21+
export default getAllBuilds({});
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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 { importPathTransformer } from '../../scripts/exp/ts-transform-import-path';
19+
import { getAllBuilds } from './rollup.config.base';
20+
21+
// eslint-disable-next-line import/no-default-export
22+
export default getAllBuilds({
23+
clean: true,
24+
transformers: [importPathTransformer]
25+
});

0 commit comments

Comments
 (0)