Skip to content

Commit 632b888

Browse files
Simplify
1 parent 0fe7877 commit 632b888

File tree

4 files changed

+22
-24
lines changed

4 files changed

+22
-24
lines changed

config/webpack.test.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ const path = require('path');
1919
const webpack = require('webpack');
2020

2121
/**
22-
* A regular expression used to replace Firestore's platform specific modules,
23-
* which are located under 'packages/firestore/src/platform/'.
22+
* A regular expression used to replace Firestore's and Storage's platform-
23+
* specific modules, which are located under
24+
* 'packages/(component)/src/platform/'.
2425
*/
25-
const FIRESTORE_PLATFORM_RE = /^(.*)\/platform\/([^.\/]*)(\.ts)?$/;
26+
const PLATFORM_RE = /^(.*)\/platform\/([^.\/]*)(\.ts)?$/;
2627

2728
module.exports = {
2829
mode: 'development',
@@ -100,16 +101,13 @@ module.exports = {
100101
symlinks: false
101102
},
102103
plugins: [
103-
new webpack.NormalModuleReplacementPlugin(
104-
FIRESTORE_PLATFORM_RE,
105-
resource => {
106-
const targetPlatform = process.env.TEST_PLATFORM || 'browser';
107-
resource.request = resource.request.replace(
108-
FIRESTORE_PLATFORM_RE,
109-
`$1/platform/${targetPlatform}/$2.ts`
110-
);
111-
}
112-
),
104+
new webpack.NormalModuleReplacementPlugin(PLATFORM_RE, resource => {
105+
const targetPlatform = process.env.TEST_PLATFORM || 'browser';
106+
resource.request = resource.request.replace(
107+
PLATFORM_RE,
108+
`$1/platform/${targetPlatform}/$2.ts`
109+
);
110+
}),
113111
new webpack.EnvironmentPlugin([
114112
'RTDB_EMULATOR_PORT',
115113
'RTDB_EMULATOR_NAMESPACE'

packages/storage/karma.conf.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ module.exports = function (config) {
3131
};
3232

3333
function getTestFiles(argv) {
34-
process.env.TEST_PLATFORM = 'browser';
3534
let unitTestFiles = ['test/unit/*'];
3635
let integrationTestFiles = [];
3736
if (argv.exp) {

packages/storage/src/platform/base64.ts

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

18-
// This file is only used under ts-node.
19-
// eslint-disable-next-line @typescript-eslint/no-require-imports
20-
const platform = require(`./${process.env.TEST_PLATFORM ?? 'node'}/base64`);
18+
import {
19+
decodeUint8Array as nodeDecodeUint8Array,
20+
decodeBase64 as nodeDecodeBase64
21+
} from './node/base64';
2122

2223
/** Converts a Base64 encoded string to a binary string. */
2324
export function decodeBase64(encoded: string): string {
24-
return platform.decodeBase64(encoded);
25+
// This file is only used under ts-node.
26+
return nodeDecodeBase64(encoded);
2527
}
2628

2729
/** Converts a Uint8Array to a string. */
2830
export function decodeUint8Array(data: Uint8Array): string {
29-
return platform.decodeUint8Array(data);
31+
// This file is only used under ts-node.
32+
return nodeDecodeUint8Array(data);
3033
}

packages/storage/src/platform/connection.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@
1515
* limitations under the License.
1616
*/
1717
import { Connection } from '../implementation/connection';
18-
19-
// This file is only used under ts-node.
20-
// eslint-disable-next-line @typescript-eslint/no-require-imports
21-
const platform = require(`./${process.env.TEST_PLATFORM ?? 'node'}/connection`);
18+
import { newConnection as nodeNewConnection } from './node/connection';
2219

2320
export function newConnection(): Connection {
24-
return platform.newConnection();
21+
// This file is only used under ts-node.
22+
return nodeNewConnection();
2523
}

0 commit comments

Comments
 (0)