Skip to content

Functions compat package #3739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/api-review/functions-exp.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function getFunctions(app: FirebaseApp, regionOrCustomDomain?: string): F
export function httpsCallable(functionsInstance: Functions, name: string, options?: HttpsCallableOptions): HttpsCallable;

// @public
export function useFunctionsEmulator(functionsInstance: Functions, origin: string): void;
export function useFunctionsEmulator(functionsInstance: Functions, host: string, port: number): void;


// (No @packageDocumentation comment for this package)
Expand Down
2 changes: 2 additions & 0 deletions packages-exp/app-exp/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { name as analyticsName } from '../../../packages/analytics/package.json'
import { name as authName } from '../../../packages/auth/package.json';
import { name as databaseName } from '../../../packages/database/package.json';
import { name as functionsName } from '../../../packages-exp/functions-exp/package.json';
import { name as functionsCompatName } from '../../../packages-exp/functions-compat/package.json';
import { name as installationsName } from '../../../packages/installations/package.json';
import { name as messagingName } from '../../../packages/messaging/package.json';
import { name as performanceName } from '../../../packages/performance/package.json';
Expand All @@ -43,6 +44,7 @@ export const PLATFORM_LOG_STRING = {
[authName]: 'fire-auth',
[databaseName]: 'fire-rtdb',
[functionsName]: 'fire-fn',
[functionsCompatName]: 'fire-fn-compat',
[installationsName]: 'fire-iid',
[messagingName]: 'fire-fcm',
[performanceName]: 'fire-perf',
Expand Down
37 changes: 37 additions & 0 deletions packages-exp/functions-compat/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* eslint-disable @typescript-eslint/no-require-imports */
/**
* @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.
*/
const path = require('path');

module.exports = {
extends: '../../config/.eslintrc.js',
parserOptions: {
project: 'tsconfig.json',
// to make vscode-eslint work with monorepo
// https://github.com/typescript-eslint/typescript-eslint/issues/251#issuecomment-463943250
tsconfigRootDir: __dirname
},
rules: {
'import/no-extraneous-dependencies': [
'error',
{
'packageDir': [path.resolve(__dirname, '../../'), __dirname],
devDependencies: true
}
]
}
};
35 changes: 35 additions & 0 deletions packages-exp/functions-compat/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* @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.
*/

const karmaBase = require('../../config/karma.base');

const files = ['test/**/*', 'src/**/*.test.ts'];

module.exports = function (config) {
const karmaConfig = Object.assign({}, karmaBase, {
// files to load into karma
files: files,
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
preprocessors: { '**/*.ts': ['webpack', 'sourcemap'] },
frameworks: ['mocha']
});

config.set(karmaConfig);
};

module.exports.files = files;
65 changes: 65 additions & 0 deletions packages-exp/functions-compat/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"name": "@firebase/functions-compat",
"version": "0.0.800",
"description": "",
"private": true,
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
"main": "dist/index.node.cjs.js",
"browser": "dist/index.esm5.js",
"module": "dist/index.esm5.js",
"esm2017": "dist/index.esm2017.js",
"files": [
"dist"
],
"license": "Apache-2.0",
"peerDependencies": {
"@firebase/app-compat": "0.x"
},
"devDependencies": {
"@firebase/app-compat": "0.0.800",
"@firebase/app-exp": "0.0.800",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

"rollup": "2.26.7",
"@rollup/plugin-json": "4.1.0",
"rollup-plugin-typescript2": "0.27.2",
"typescript": "4.0.2"
},
"repository": {
"directory": "packages-exp/functions-compat",
"type": "git",
"url": "https://github.com/firebase/firebase-js-sdk.git"
},
"bugs": {
"url": "https://github.com/firebase/firebase-js-sdk/issues"
},
"scripts": {
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
"build": "rollup -c",
"build:deps": "lerna run --scope @firebase/functions-compat --include-dependencies build",
"build:release": "rollup -c rollup.config.release.js",
"dev": "rollup -c -w",
"test": "run-p lint test:all",
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test:all",
"test:all": "run-p test:browser test:node",
"test:browser": "karma start --single-run",
"test:browser:debug": "karma start --browsers=Chrome --auto-watch",
"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",
"test:emulator": "env FIREBASE_FUNCTIONS_HOST=http://localhost FIREBASE_FUNCTIONS_PORT=5005 run-p test:node",
"prepare": "yarn build:release"
},
"typings": "dist/functions-compat-public.d.ts",
"dependencies": {
"@firebase/component": "0.1.20",
"@firebase/functions-exp": "0.0.800",
"@firebase/functions-types-exp": "0.0.800",
"@firebase/messaging-types": "0.5.0",
"@firebase/util": "0.3.3",
"tslib": "^1.11.1"
},
"nyc": {
"extension": [
".ts"
],
"reportDir": "./coverage/node"
}
}
100 changes: 100 additions & 0 deletions packages-exp/functions-compat/rollup.config.base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/**
* @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 json from 'rollup-plugin-json';
import typescriptPlugin from 'rollup-plugin-typescript2';
import typescript from 'typescript';
import pkg from './package.json';

const deps = Object.keys(
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
);

/**
* ES5 Builds
*/
export function getEs5Builds(additionalTypescriptPlugins = {}) {
const es5BuildPlugins = [
typescriptPlugin({
typescript,
abortOnError: false,
...additionalTypescriptPlugins
}),
json()
];
return [
/**
* Browser Builds
*/
{
input: 'src/index.ts',
output: [{ file: pkg.module, format: 'es', sourcemap: true }],
plugins: es5BuildPlugins,
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
},
/**
* Node.js Build
*/
{
input: 'src/index.node.ts',
output: [{ file: pkg.main, format: 'cjs', sourcemap: true }],
plugins: es5BuildPlugins,
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
}
];
}

/**
* ES2017 Builds
*/
export function getEs2017Builds(additionalTypescriptPlugins = {}) {
const es2017BuildPlugins = [
typescriptPlugin({
typescript,
abortOnError: false,
tsconfigOverride: {
compilerOptions: {
target: 'es2017'
}
},
...additionalTypescriptPlugins
}),
json({ preferConst: true })
];
return [
{
/**
* Browser Build
*/
input: 'src/index.ts',
output: {
file: pkg.esm2017,
format: 'es',
sourcemap: true
},
plugins: es2017BuildPlugins,
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
}
];
}

export function getAllBuilds(additionalTypescriptPlugins = {}) {
return [
...getEs5Builds(additionalTypescriptPlugins),
...getEs2017Builds(additionalTypescriptPlugins)
];
}
21 changes: 21 additions & 0 deletions packages-exp/functions-compat/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* @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 { getAllBuilds } from './rollup.config.base';

// eslint-disable-next-line import/no-default-export
export default getAllBuilds({});
25 changes: 25 additions & 0 deletions packages-exp/functions-compat/rollup.config.release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* @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 { importPathTransformer } from '../../scripts/exp/ts-transform-import-path';
import { getAllBuilds } from './rollup.config.base';

// eslint-disable-next-line import/no-default-export
export default getAllBuilds({
clean: true,
transformers: [importPathTransformer]
});
Loading