Skip to content

Commit 24389cd

Browse files
Don't use index.ts
1 parent 51486fa commit 24389cd

File tree

9 files changed

+98
-60
lines changed

9 files changed

+98
-60
lines changed

packages/firestore/exp/index.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { version } from '../package.json';
19-
import { _registerComponent, registerVersion } from '@firebase/app-exp';
20-
import { Component, ComponentType } from '@firebase/component';
21-
import { Firestore } from './src/api/database';
18+
import './register';
2219

2320
export { FieldPath, documentId } from '../lite/src/api/field_path';
2421

@@ -103,22 +100,3 @@ export { GeoPoint } from '../src/api/geo_point';
103100
export { Timestamp } from '../src/api/timestamp';
104101

105102
export { refEqual, queryEqual } from '../lite/src/api/reference';
106-
107-
export function registerFirestore(): void {
108-
_registerComponent(
109-
new Component(
110-
'firestore-exp',
111-
container => {
112-
const app = container.getProvider('app-exp').getImmediate()!;
113-
return ((app, auth) => new Firestore(app, auth))(
114-
app,
115-
container.getProvider('auth-internal')
116-
);
117-
},
118-
ComponentType.PUBLIC
119-
)
120-
);
121-
registerVersion('firestore-exp', version, 'node');
122-
}
123-
124-
registerFirestore();

packages/firestore/exp/register.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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 { _registerComponent, registerVersion } from '@firebase/app-exp';
19+
import { Component, ComponentType } from '@firebase/component';
20+
21+
import { Firestore } from './src/api/database';
22+
import { version } from '../package.json';
23+
24+
export function registerFirestore(): void {
25+
_registerComponent(
26+
new Component(
27+
'firestore-exp',
28+
container => {
29+
const app = container.getProvider('app-exp').getImmediate()!;
30+
return ((app, auth) => new Firestore(app, auth))(
31+
app,
32+
container.getProvider('auth-internal')
33+
);
34+
},
35+
ComponentType.PUBLIC
36+
)
37+
);
38+
registerVersion('firestore-exp', version, 'node');
39+
}
40+
41+
registerFirestore();

packages/firestore/exp/test/bootstrap.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import '../';
18+
import '../register';
1919

2020
/**
2121
* This will include all of the test files and compile them as needed
@@ -29,7 +29,7 @@ import '../';
2929
const testsContext = (require as any).context(
3030
'../../test/integration/api',
3131
true,
32-
/^*\.test$/
32+
/^.*\.test\.ts$/
3333
);
3434
const browserTests = testsContext.keys();
3535
browserTests.forEach(testsContext);

packages/firestore/karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = function (config) {
2626
preprocessors: {
2727
'exp/test/**/*.ts': ['webpack', 'sourcemap'],
2828
'lite/test/**/*.ts': ['webpack', 'sourcemap'],
29-
'test/**/*.ts': ['webpack', 'sourcemap'],
29+
'test/**/*.ts': ['webpack', 'sourcemap']
3030
},
3131

3232
// frameworks to use

packages/firestore/lite/index.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { registerVersion, _registerComponent } from '@firebase/app-exp';
19-
import { Firestore } from './src/api/database';
20-
import { version } from '../package.json';
21-
import { Component, ComponentType } from '@firebase/component';
18+
import './register';
2219

2320
export {
2421
Firestore as FirebaseFirestore,
@@ -86,22 +83,3 @@ export { Blob } from '../src/api/blob';
8683
export { GeoPoint } from '../src/api/geo_point';
8784

8885
export { Timestamp } from '../src/api/timestamp';
89-
90-
export function registerFirestore(): void {
91-
_registerComponent(
92-
new Component(
93-
'firestore/lite',
94-
container => {
95-
const app = container.getProvider('app-exp').getImmediate()!;
96-
return ((app, auth) => new Firestore(app, auth))(
97-
app,
98-
container.getProvider('auth-internal')
99-
);
100-
},
101-
ComponentType.PUBLIC
102-
)
103-
);
104-
registerVersion('firestore-lite', version, 'node');
105-
}
106-
107-
registerFirestore();

packages/firestore/lite/register.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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 { _registerComponent, registerVersion } from '@firebase/app-exp';
19+
import { Component, ComponentType } from '@firebase/component';
20+
21+
import { Firestore } from './src/api/database';
22+
import { version } from '../package.json';
23+
24+
export function registerFirestore(): void {
25+
_registerComponent(
26+
new Component(
27+
'firestore/lite',
28+
container => {
29+
const app = container.getProvider('app-exp').getImmediate()!;
30+
return ((app, auth) => new Firestore(app, auth))(
31+
app,
32+
container.getProvider('auth-internal')
33+
);
34+
},
35+
ComponentType.PUBLIC
36+
)
37+
);
38+
registerVersion('firestore-lite', version, 'node');
39+
}
40+
41+
registerFirestore();

packages/firestore/lite/src/api/reference.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,11 @@ export function parent<T>(
526526
if (parentPath.isEmpty()) {
527527
return null;
528528
} else {
529-
return new DocumentReference(child.firestore, /* converter= */ null, parentPath);
529+
return new DocumentReference(
530+
child.firestore,
531+
/* converter= */ null,
532+
parentPath
533+
);
530534
}
531535
} else {
532536
const doc = cast<DocumentReference<T>>(child, DocumentReference);

packages/firestore/lite/test/bootstrap.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import '../';
18+
import '../register';
1919

2020
/**
2121
* This will include all of the test files and compile them as needed
@@ -26,6 +26,6 @@ import '../';
2626

2727
// 'context()' definition requires additional dependency on webpack-env package.
2828
// eslint-disable-next-line @typescript-eslint/no-explicit-any
29-
const testsContext = (require as any).context('.', true, /^.*\.test$/);
29+
const testsContext = (require as any).context('.', true, /^.*\.test.*$/);
3030
const browserTests = testsContext.keys();
3131
browserTests.forEach(testsContext);

packages/firestore/scripts/build-bundle.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ const typescriptPlugin = require('rollup-plugin-typescript2');
2222
const alias = require('@rollup/plugin-alias');
2323
const json = require('rollup-plugin-json');
2424

25-
import {
26-
removeAssertTransformer,
27-
resolveNodeExterns,
28-
generateAliasConfig
29-
} from '../rollup.shared';
25+
const util = require('../rollup.shared');
3026

3127
const argv = yargs.options({
3228
input: {
@@ -52,18 +48,18 @@ async function buildBundle(input: string, output: string): Promise<void> {
5248
const bundle = await rollup({
5349
input,
5450
plugins: [
55-
alias(generateAliasConfig('node')),
51+
alias(util.generateAliasConfig('node')),
5652
typescriptPlugin({
5753
tsconfigOverride: {
5854
compilerOptions: {
5955
target: 'es2017'
6056
}
6157
},
62-
transformers: removeAssertTransformer
58+
transformers: util.removeAssertTransformer
6359
}),
6460
json({ preferConst: true })
6561
],
66-
external: resolveNodeExterns
62+
external: util.resolveNodeExterns
6763
});
6864
await bundle.write({ file: output, format: 'es' });
6965
}

0 commit comments

Comments
 (0)