Skip to content

Commit 8767c12

Browse files
committed
Standardize replace plugin usage
1 parent 3d474ac commit 8767c12

File tree

12 files changed

+83
-17
lines changed

12 files changed

+83
-17
lines changed

packages/app/declarations.d.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @license
3+
* Copyright 2019 Google Inc.
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+
/** Will be replaced by Rollup */
19+
declare const __JSCORE_VERSION__: string;

packages/app/rollup.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ const es5BuildPlugins = [
3434
typescript
3535
}),
3636
replace({
37-
delimiters: ['${', '}'],
37+
delimiters: ['__', '__'],
3838
values: {
39-
JSCORE_VERSION: firebasePkg.version
39+
JSCORE_VERSION: JSON.stringify(firebasePkg.version)
4040
}
4141
})
4242
];
@@ -99,9 +99,9 @@ const es2017BuildPlugins = [
9999
}
100100
}),
101101
replace({
102-
delimiters: ['${', '}'],
102+
delimiters: ['__', '__'],
103103
values: {
104-
JSCORE_VERSION: firebasePkg.version
104+
JSCORE_VERSION: JSON.stringify(firebasePkg.version)
105105
}
106106
})
107107
];

packages/app/src/firebaseNamespaceCore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export function createFirebaseNamespaceCore(
6262
initializeApp: initializeApp,
6363
app: app as any,
6464
apps: null as any,
65-
SDK_VERSION: '${JSCORE_VERSION}',
65+
SDK_VERSION: __JSCORE_VERSION__,
6666
INTERNAL: {
6767
registerService,
6868
removeApp,

packages/app/src/lite/firebaseNamespaceLite.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { createFirebaseNamespaceCore } from '../firebaseNamespaceCore';
2828
export function createFirebaseNamespaceLite(): FirebaseNamespace {
2929
const namespace = createFirebaseNamespaceCore(FirebaseAppLiteImpl);
3030

31-
namespace.SDK_VERSION = '${JSCORE_VERSION}_LITE';
31+
namespace.SDK_VERSION = `${__JSCORE_VERSION__}_LITE`;
3232

3333
const registerService = (namespace as _FirebaseNamespace).INTERNAL
3434
.registerService;

packages/installations/rollup.config.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ const deps = Object.keys({ ...pkg.peerDependencies, ...pkg.dependencies });
2828
const es5BuildPlugins = [
2929
typescriptPlugin({ typescript }),
3030
replace({
31-
__VERSION__: pkg.version
31+
delimiters: ['__', '__'],
32+
values: {
33+
VERSION: JSON.stringify(pkg.version)
34+
}
3235
})
3336
];
3437

@@ -57,7 +60,10 @@ const es2017BuildPlugins = [
5760
}
5861
}),
5962
replace({
60-
__VERSION__: pkg.version
63+
delimiters: ['__', '__'],
64+
values: {
65+
VERSION: JSON.stringify(pkg.version)
66+
}
6167
})
6268
];
6369

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @license
3+
* Copyright 2019 Google Inc.
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+
/** Will be replaced by Rollup */
19+
declare const __VERSION__: string;

packages/installations/src/util/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
export const PENDING_TIMEOUT_MS = 10000;
1919

20-
export const PACKAGE_VERSION = 'w:__VERSION__'; // Will be replaced by Rollup
20+
export const PACKAGE_VERSION = `w:${__VERSION__}`;
2121
export const INTERNAL_AUTH_VERSION = 'FIS_v2';
2222

2323
export const INSTALLATIONS_API_URL =

packages/installations/test-app/rollup.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ export default [
4141
tsconfigOverride: { compilerOptions: { declaration: false } }
4242
}),
4343
replace({
44-
__VERSION__: pkg.version
44+
delimiters: ['__', '__'],
45+
values: {
46+
VERSION: pkg.version
47+
}
4548
}),
4649
resolve(),
4750
commonjs(),
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @license
3+
* Copyright 2019 Google Inc.
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+
/** Will be replaced by Rollup */
19+
declare const __PERF_SDK_VERSION__: string;

packages/performance/rollup.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ const es5BuildPlugins = [
3131
typescript
3232
}),
3333
replace({
34-
delimiters: ['<', '>'],
34+
delimiters: ['__', '__'],
3535
values: {
36-
PERF_SDK_VERSION: pkg.version
36+
PERF_SDK_VERSION: JSON.stringify(pkg.version)
3737
}
3838
})
3939
];
@@ -64,9 +64,9 @@ const es2017BuildPlugins = [
6464
}
6565
}),
6666
replace({
67-
delimiters: ['<', '>'],
67+
delimiters: ['__', '__'],
6868
values: {
69-
PERF_SDK_VERSION: pkg.version
69+
PERF_SDK_VERSION: JSON.stringify(pkg.version)
7070
}
7171
})
7272
];

packages/performance/src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
export const SDK_VERSION = '<PERF_SDK_VERSION>';
17+
export const SDK_VERSION = __PERF_SDK_VERSION__;
1818
/** The prefix for start User Timing marks used for creating Traces. */
1919
export const TRACE_START_MARK_PREFIX = 'FB-PERF-TRACE-START';
2020
/** The prefix for stop User Timing marks used for creating Traces. */

packages/performance/src/services/perf_logger.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe('Performance Monitoring > perf_logger', () => {
8383
const START_TIME = 12345;
8484
const DURATION = 321;
8585
const EXPECTED_TRACE_MESSAGE = `{"application_info":{"google_app_id":"${APP_ID}",\
86-
"app_instance_id":"${IID}","web_app_info":{"sdk_version":"<PERF_SDK_VERSION>",\
86+
"app_instance_id":"${IID}","web_app_info":{"sdk_version":"${__PERF_SDK_VERSION__}",\
8787
"page_url":"${PAGE_URL}","service_worker_status":${SERVICE_WORKER_STATUS},\
8888
"visibility_state":${VISIBILITY_STATE},"effective_connection_type":${EFFECTIVE_CONNECTION_TYPE}},\
8989
"application_process_state":0},"trace_metric":{"name":"${TRACE_NAME}","is_auto":false,\
@@ -137,7 +137,7 @@ describe('Performance Monitoring > perf_logger', () => {
137137
1000
138138
);
139139
const EXPECTED_NETWORK_MESSAGE = `{"application_info":{"google_app_id":"${APP_ID}",\
140-
"app_instance_id":"${IID}","web_app_info":{"sdk_version":"<PERF_SDK_VERSION>",\
140+
"app_instance_id":"${IID}","web_app_info":{"sdk_version":"${__PERF_SDK_VERSION__}",\
141141
"page_url":"${PAGE_URL}","service_worker_status":${SERVICE_WORKER_STATUS},\
142142
"visibility_state":${VISIBILITY_STATE},"effective_connection_type":${EFFECTIVE_CONNECTION_TYPE}},\
143143
"application_process_state":0},\

0 commit comments

Comments
 (0)