Skip to content

Import package version from package.json #1764

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 4 commits into from
May 10, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"rollup": "1.11.0",
"rollup-plugin-replace": "2.2.0",
"rollup-plugin-typescript2": "0.21.0",
"rollup-plugin-json": "4.0.0",
"sinon": "7.3.2",
"source-map-loader": "0.2.4",
"ts-loader": "5.4.5",
Expand All @@ -67,7 +68,7 @@
"bugs": {
"url": "https://github.com/firebase/firebase-js-sdk/issues"
},
"typings": "dist/index.d.ts",
"typings": "dist/app/index.d.ts",
"nyc": {
"extension": [
".ts"
Expand Down
18 changes: 4 additions & 14 deletions packages/app/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@
*/

import typescriptPlugin from 'rollup-plugin-typescript2';
import replace from 'rollup-plugin-replace';
import json from 'rollup-plugin-json';
import typescript from 'typescript';
import pkg from './package.json';

import firebasePkg from '../firebase/package.json';

const deps = Object.keys(
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
);
Expand All @@ -33,12 +31,7 @@ const es5BuildPlugins = [
typescriptPlugin({
typescript
}),
replace({
delimiters: ['${', '}'],
values: {
JSCORE_VERSION: firebasePkg.version
}
})
json()
];

const es5Builds = [
Expand Down Expand Up @@ -98,11 +91,8 @@ const es2017BuildPlugins = [
}
}
}),
replace({
delimiters: ['${', '}'],
values: {
JSCORE_VERSION: firebasePkg.version
}
json({
preferConst: true
})
];

Expand Down
3 changes: 2 additions & 1 deletion packages/app/src/firebaseNamespaceCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { FirebaseAppImpl } from './firebaseApp';
import { error, AppError } from './errors';
import { FirebaseAppLiteImpl } from './lite/firebaseAppLite';
import { DEFAULT_ENTRY_NAME } from './constants';
import { version } from '../../firebase/package.json';

function contains(obj: object, key: string) {
return Object.prototype.hasOwnProperty.call(obj, key);
Expand Down Expand Up @@ -62,7 +63,7 @@ export function createFirebaseNamespaceCore(
initializeApp: initializeApp,
app: app as any,
apps: null as any,
SDK_VERSION: '${JSCORE_VERSION}',
SDK_VERSION: version,
INTERNAL: {
registerService,
removeApp,
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/lite/firebaseNamespaceLite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { createFirebaseNamespaceCore } from '../firebaseNamespaceCore';
export function createFirebaseNamespaceLite(): FirebaseNamespace {
const namespace = createFirebaseNamespaceCore(FirebaseAppLiteImpl);

namespace.SDK_VERSION = '${JSCORE_VERSION}_LITE';
namespace.SDK_VERSION = `${namespace.SDK_VERSION}_LITE`;

const registerService = (namespace as _FirebaseNamespace).INTERNAL
.registerService;
Expand Down
3 changes: 2 additions & 1 deletion packages/app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "../../config/tsconfig.base.json",
"compilerOptions": {
"outDir": "dist"
"outDir": "dist",
"resolveJsonModule": true
},
"exclude": [
"dist/**/*"
Expand Down
4 changes: 2 additions & 2 deletions packages/installations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"esm2017": "dist/index.esm2017.js",
"types": "dist/index.d.ts",
"types": "dist/src/index.d.ts",
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
"license": "Apache-2.0",
"scripts": {
Expand Down Expand Up @@ -32,8 +32,8 @@
"mocha": "6.1.4",
"rollup": "1.11.0",
"rollup-plugin-commonjs": "9.3.4",
"rollup-plugin-json": "4.0.0",
"rollup-plugin-node-resolve": "4.2.3",
"rollup-plugin-replace": "2.2.0",
"rollup-plugin-typescript2": "0.21.0",
"rollup-plugin-uglify": "6.0.2",
"sinon": "7.3.2",
Expand Down
13 changes: 3 additions & 10 deletions packages/installations/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* limitations under the License.
*/

import json from 'rollup-plugin-json';
import typescriptPlugin from 'rollup-plugin-typescript2';
import replace from 'rollup-plugin-replace';
import pkg from './package.json';
import typescript from 'typescript';

Expand All @@ -25,12 +25,7 @@ const deps = Object.keys({ ...pkg.peerDependencies, ...pkg.dependencies });
/**
* ES5 Builds
*/
const es5BuildPlugins = [
typescriptPlugin({ typescript }),
replace({
__VERSION__: pkg.version
})
];
const es5BuildPlugins = [typescriptPlugin({ typescript }), json()];

const es5Builds = [
{
Expand All @@ -56,9 +51,7 @@ const es2017BuildPlugins = [
}
}
}),
replace({
__VERSION__: pkg.version
})
json({ preferConst: true })
];

const es2017Builds = [
Expand Down
4 changes: 3 additions & 1 deletion packages/installations/src/util/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
* limitations under the License.
*/

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

export const PENDING_TIMEOUT_MS = 10000;

export const PACKAGE_VERSION = 'w:__VERSION__'; // Will be replaced by Rollup
export const PACKAGE_VERSION = `w:${version}`;
export const INTERNAL_AUTH_VERSION = 'FIS_v2';

export const INSTALLATIONS_API_URL =
Expand Down
7 changes: 2 additions & 5 deletions packages/installations/test-app/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
import typescriptPlugin from 'rollup-plugin-typescript2';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import replace from 'rollup-plugin-replace';
import json from 'rollup-plugin-json';
import { uglify } from 'rollup-plugin-uglify';
import pkg from '../package.json';
import typescript from 'typescript';

/**
Expand All @@ -40,9 +39,7 @@ export default [
typescript,
tsconfigOverride: { compilerOptions: { declaration: false } }
}),
replace({
__VERSION__: pkg.version
}),
json(),
resolve(),
commonjs(),
uglify()
Expand Down
1 change: 1 addition & 0 deletions packages/installations/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"lib": ["es2017", "dom"],
"downlevelIteration": true,
"resolveJsonModule": true,

"strict": true,
"noUnusedLocals": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/performance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"chai": "4.2.0",
"mocha": "6.1.4",
"rollup": "1.11.0",
"rollup-plugin-replace": "2.2.0",
"rollup-plugin-json": "4.0.0",
"rollup-plugin-typescript2": "0.21.0",
"sinon": "7.3.2",
"sinon-chai": "3.3.0",
Expand Down
21 changes: 3 additions & 18 deletions packages/performance/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

import json from 'rollup-plugin-json';
import typescriptPlugin from 'rollup-plugin-typescript2';
import replace from 'rollup-plugin-replace';
import typescript from 'typescript';
import pkg from './package.json';

Expand All @@ -26,17 +26,7 @@ const deps = Object.keys(
/**
* ES5 Builds
*/
const es5BuildPlugins = [
typescriptPlugin({
typescript
}),
replace({
delimiters: ['<', '>'],
values: {
PERF_SDK_VERSION: pkg.version
}
})
];
const es5BuildPlugins = [typescriptPlugin({ typescript }), json()];

const es5Builds = [
{
Expand All @@ -63,12 +53,7 @@ const es2017BuildPlugins = [
}
}
}),
replace({
delimiters: ['<', '>'],
values: {
PERF_SDK_VERSION: pkg.version
}
})
json({ preferConst: true })
];

const es2017Builds = [
Expand Down
4 changes: 3 additions & 1 deletion packages/performance/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
* limitations under the License.
*/

export const SDK_VERSION = '<PERF_SDK_VERSION>';
import { version } from '../package.json';

export const SDK_VERSION = version;
/** The prefix for start User Timing marks used for creating Traces. */
export const TRACE_START_MARK_PREFIX = 'FB-PERF-TRACE-START';
/** The prefix for stop User Timing marks used for creating Traces. */
Expand Down
5 changes: 3 additions & 2 deletions packages/performance/src/services/perf_logger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { Api, setupApi } from './api_service';
import { SettingsService } from './settings_service';
import { FirebaseApp } from '@firebase/app-types';
import * as initializationService from './initialization_service';
import { SDK_VERSION } from '../constants';
import * as attributeUtils from '../utils/attributes_utils';
import { createNetworkRequestEntry } from '../resources/network_request';
import '../../test/setup';
Expand Down Expand Up @@ -83,7 +84,7 @@ describe('Performance Monitoring > perf_logger', () => {
const START_TIME = 12345;
const DURATION = 321;
const EXPECTED_TRACE_MESSAGE = `{"application_info":{"google_app_id":"${APP_ID}",\
"app_instance_id":"${IID}","web_app_info":{"sdk_version":"<PERF_SDK_VERSION>",\
"app_instance_id":"${IID}","web_app_info":{"sdk_version":"${SDK_VERSION}",\
"page_url":"${PAGE_URL}","service_worker_status":${SERVICE_WORKER_STATUS},\
"visibility_state":${VISIBILITY_STATE},"effective_connection_type":${EFFECTIVE_CONNECTION_TYPE}},\
"application_process_state":0},"trace_metric":{"name":"${TRACE_NAME}","is_auto":false,\
Expand Down Expand Up @@ -137,7 +138,7 @@ describe('Performance Monitoring > perf_logger', () => {
1000
);
const EXPECTED_NETWORK_MESSAGE = `{"application_info":{"google_app_id":"${APP_ID}",\
"app_instance_id":"${IID}","web_app_info":{"sdk_version":"<PERF_SDK_VERSION>",\
"app_instance_id":"${IID}","web_app_info":{"sdk_version":"${SDK_VERSION}",\
"page_url":"${PAGE_URL}","service_worker_status":${SERVICE_WORKER_STATUS},\
"visibility_state":${VISIBILITY_STATE},"effective_connection_type":${EFFECTIVE_CONNECTION_TYPE}},\
"application_process_state":0},\
Expand Down
7 changes: 3 additions & 4 deletions packages/performance/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
"extends": "../../config/tsconfig.base.json",
"compilerOptions": {
"outDir": "dist",
"resolveJsonModule": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"exclude": [
"dist/**/*"
]
}
"exclude": ["dist/**/*"]
}
9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12027,6 +12027,13 @@ [email protected]:
dependencies:
fs-extra "^5.0.0"

[email protected]:
version "4.0.0"
resolved "https://registry.npmjs.org/rollup-plugin-json/-/rollup-plugin-json-4.0.0.tgz#a18da0a4b30bf5ca1ee76ddb1422afbb84ae2b9e"
integrity sha512-hgb8N7Cgfw5SZAkb3jf0QXii6QX/FOkiIq2M7BAQIEydjHvTyxXHQiIzZaTFgx1GK0cRCHOCBHIyEkkLdWKxow==
dependencies:
rollup-pluginutils "^2.5.0"

[email protected]:
version "0.8.1"
resolved "https://registry.npmjs.org/rollup-plugin-license/-/rollup-plugin-license-0.8.1.tgz#cdcfee2a32f27790e5019a2a7abd9234476ac589"
Expand Down Expand Up @@ -12102,7 +12109,7 @@ [email protected], rollup-pluginutils@^2.0.1:
estree-walker "^0.6.0"
micromatch "^3.1.10"

rollup-pluginutils@^2.6.0:
rollup-pluginutils@^2.5.0, rollup-pluginutils@^2.6.0:
version "2.6.0"
resolved "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.6.0.tgz#203706edd43dfafeaebc355d7351119402fc83ad"
integrity sha512-aGQwspEF8oPKvg37u3p7h0cYNwmJR1sCBMZGZ5b9qy8HGtETknqjzcxrDRrcAnJNXN18lBH4Q9vZYth/p4n8jQ==
Expand Down