Skip to content

Split database and database-compat #5276

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 17 commits into from
Aug 20, 2021
Merged
2 changes: 1 addition & 1 deletion packages-exp/app-exp/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { name as appCheckName } from '../../../packages-exp/app-check-exp/packag
import { name as authName } from '../../../packages-exp/auth-exp/package.json';
import { name as authCompatName } from '../../../packages-exp/auth-compat-exp/package.json';
import { name as databaseName } from '../../../packages/database/package.json';
import { name as databaseCompatName } from '../../../packages/database/compat/package.json';
import { name as databaseCompatName } from '../../../packages/database-compat/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-exp/installations-exp/package.json';
Expand Down
64 changes: 64 additions & 0 deletions packages/database-compat/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* @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.
*/

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: {
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'no-restricted-properties': 'off',
'no-restricted-globals': 'off',
'no-throw-literal': 'off',
'id-blacklist': 'off',
'import/order': [
'error',
{
'groups': [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index'
],
'newlines-between': 'always',
'alphabetize': { 'order': 'asc', 'caseInsensitive': true }
}
]
},
overrides: [
{
files: ['**/*.d.ts'],
rules: {
'@typescript-eslint/no-explicit-any': 'off'
}
},
{
files: ['scripts/*.ts'],
rules: {
'import/no-extraneous-dependencies': 'off'
}
}
]
};
5 changes: 5 additions & 0 deletions packages/database-compat/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# @firebase/database

This is the Firebase Realtime Database component of the Firebase JS SDK.

**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.**
36 changes: 36 additions & 0 deletions packages/database-compat/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* @license
* Copyright 2017 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 karma = require('karma');
const path = require('path');
const karmaBase = require('../../config/karma.base');

const files = [`test/**/*.test.ts`];

module.exports = function (config) {
const karmaConfig = Object.assign({}, karmaBase, {
// files to load into karma
files: files,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: This can be simplified.

// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha']
});

config.set(karmaConfig);
};

module.exports.files = files;
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import path from 'path';
import { getImportPathTransformer } from '../../scripts/exp/ts-transform-import-path';

import compatPkg from './compat/package.json';
import pkg from './package.json';
import pkg from '../database/package.json';

const deps = [
...Object.keys(Object.assign({}, pkg.peerDependencies, pkg.dependencies)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ import * as types from '@firebase/database-types';
import { CONSTANTS, isNodeSdk } from '@firebase/util';
import { Client } from 'faye-websocket';

import { enableLogging } from '../exp/index';
import { Database } from '../src/api/Database';
import * as INTERNAL from '../src/api/internal';
import { DataSnapshot, Query, Reference } from '../src/api/Reference';
import * as TEST_ACCESS from '../src/api/test_access';
import { setSDKVersion } from '../src/core/version';
import { setWebSocketImpl } from '../src/realtime/WebSocketConnection';
import { enableLogging } from '../../database/exp/index';
import { Database } from '../../database/src/api/Database';
import * as INTERNAL from '../../database/src/api/internal';
import { DataSnapshot, Query, Reference } from '../../database/src/api/Reference';
import * as TEST_ACCESS from '../../database/src/api/test_access';
import { setSDKVersion } from '../../database/src/core/version';
import { setWebSocketImpl } from '../../database/src/realtime/WebSocketConnection';

import { name, version } from './package.json';
import { name, version } from '../package.json';

setWebSocketImpl(Client);

Expand Down Expand Up @@ -136,7 +136,7 @@ try {
// Types to export for the admin SDK
export { Database, Query, Reference, enableLogging, ServerValue };

export { OnDisconnect } from '../src/api/onDisconnect';
export { OnDisconnect } from '../../database/src/api/onDisconnect';

declare module '@firebase/app-compat' {
interface FirebaseNamespace {
Expand All @@ -151,4 +151,4 @@ declare module '@firebase/app-compat' {
database?(): types.FirebaseDatabase;
}
}
export { DataSnapshot } from '../src/api/Reference';
export { DataSnapshot } from '../../database/src/api/Reference';
11 changes: 11 additions & 0 deletions packages/database-compat/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../config/tsconfig.base.json",
"compilerOptions": {
"outDir": "dist",
"strict": false,
"downlevelIteration": true
},
"exclude": [
"dist/**/*"
]
}
10 changes: 0 additions & 10 deletions packages/database/.npmignore

This file was deleted.

8 changes: 7 additions & 1 deletion packages/database/api-extractor.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"extends": "../../config/api-extractor.json",
// Point it to your entry point d.ts file.
"mainEntryPointFilePath": "<projectFolder>/dist/exp/index.d.ts"
"mainEntryPointFilePath": "<projectFolder>/dist/src/index.d.ts",
"apiReport": {
/**
* apiReport is handled by repo-scripts/prune-dts/extract-public-api.ts
*/
"enabled": false
}
}
9 changes: 0 additions & 9 deletions packages/database/exp/package.json

This file was deleted.

12 changes: 5 additions & 7 deletions packages/database/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@
"description": "",
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
"main": "dist/index.node.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"esm2017": "dist/index.esm2017.js",
"browser": "dist/index.esm2017.js",
"module": "dist/index.esm2017.js",
"esm5": "dist/index.esm5.js",
"files": [
"dist"
],
"scripts": {
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
"prettier": "prettier --write '*.js' '*.ts' '@(exp|src|test)/**/*.ts'",
"build": "run-p build:classic build:exp && yarn build:compat",
"build:classic": "rollup -c rollup.config.js",
"build:exp": "rollup -c rollup.config.exp.js && yarn api-report",
"build": "rollup -c rollup.config.js && yarn api-report",
"build:compat": "rollup -c rollup.config.compat.js && yarn add-compat-overloads",
"build:exp:release": "yarn build:exp && yarn build:compat",
"build:deps": "lerna run --scope @firebase/'{app,database}' --include-dependencies build",
Expand All @@ -27,7 +25,7 @@
"test:browser": "karma start --single-run",
"test:node": "TS_NODE_FILES=true TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --file index.node.ts --config ../../config/mocharc.node.js",
"test:emulator": "ts-node --compiler-options='{\"module\":\"commonjs\"}' ../../scripts/emulator-testing/database-test-runner.ts",
"api-report": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' ts-node ../../repo-scripts/prune-dts/extract-public-api.ts --package database --packageRoot . --typescriptDts ./dist/exp/exp/index.d.ts --rollupDts ./dist/exp/private.d.ts --untrimmedRollupDts ./dist/exp/internal.d.ts --publicDts ./dist/exp/index.d.ts && yarn api-report:api-json",
"api-report": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' ts-node ../../repo-scripts/prune-dts/extract-public-api.ts --package database --packageRoot . --typescriptDts ./dist/src/index.d.ts --rollupDts ./dist/private.d.ts --untrimmedRollupDts ./dist/internal.d.ts --publicDts ./dist/index.d.ts && yarn api-report:api-json",
"api-report:api-json": "rm -rf temp && api-extractor run --local --verbose",
"predoc": "node ../../scripts/exp/remove-exp.js temp",
"doc": "api-documenter markdown --input temp --output docs",
Expand Down
127 changes: 0 additions & 127 deletions packages/database/rollup.config.exp.js

This file was deleted.

Loading