diff --git a/.circleci/config.yml b/.circleci/config.yml index 598d020..5999382 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,6 +17,9 @@ jobs: - run: name: dependency audit command: ./scripts/better-audit.sh + - run: + name: packaging test + command: ./scripts/packaging-test.sh - store_test_results: path: reports/junit/ - store_artifacts: diff --git a/CHANGELOG.md b/CHANGELOG.md index cadd07c..cf15c17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,19 +3,7 @@ All notable changes to the LaunchDarkly Client-side SDK for React will be documented in this file. For the source code for versions 2.13.0 and earlier, see the corresponding tags in the [js-client-sdk](https://github.com/launchdarkly/js-client-sdk) repository; this code was previously in a monorepo package there. See also the [JavaScript SDK changelog](https://github.com/launchdarkly/js-client-sdk/blob/master/CHANGELOG.md), since the React SDK inherits all of the underlying functionality of the JavaScript SDK; this file covers only changes that are specific to the React interface. This project adheres to [Semantic Versioning](http://semver.org). ## [2.16.0] - 2019-12-16 -### Added: -- Configuration property `eventCapacity`: the maximum number of analytics events (not counting evaluation counters) that can be held at once, to prevent the SDK from consuming unexpected amounts of memory in case an application generates events unusually rapidly. In JavaScript code this would not normally be an issue, since the SDK flushes events every two seconds by default, but you may wish to increase this value if you will intentionally be generating a high volume of custom or identify events. The default value is 100. -- Configuration properties `wrapperName` and `wrapperVersion`: used by the React SDK to identify a JS SDK instance that is being used with a wrapper API. - -### Changed: -- The SDK now logs a warning if any configuration property has an inappropriate type, such as `baseUri:3` or `sendEvents:"no"` (normally not possible in TypeScript, but could happen if an arbitrary object is cast to `LDOptions`). For boolean properties, the SDK will still interpret the value in terms of truthiness, which was the previous behavior. For all other types, since there's no such commonly accepted way to coerce the type, it will fall back to the default setting for that property; previously, the behavior was undefined but most such mistakes would have caused the SDK to throw an exception at some later point. - -### Fixed: -- When calling `identify`, the current user (as reported by `getUser()`) was being updated before the SDK had received the new flag values for that user, causing the client to be temporarily in an inconsistent state where flag evaluations would be associated with the wrong user in analytics events. Now, the current-user state will stay in sync with the flags and change only when they have finished changing. (Thanks, [edvinerikson](https://github.com/launchdarkly/js-sdk-common/pull/3)!) - -### Deprecated: -- The `samplingInterval` configuration property was deprecated in the code in the previous minor version release, and in the changelog, but the deprecation notice was accidentally omitted from the documentation comments. It is hereby deprecated again. - +***This release was broken and has been removed.*** ## [2.15.1] - 2019-11-14 ### Fixed: diff --git a/scripts/packaging-test.sh b/scripts/packaging-test.sh new file mode 100755 index 0000000..b59260d --- /dev/null +++ b/scripts/packaging-test.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +npm pack +TARBALL=$(ls *.tgz) +trap "rm ${TARBALL}" EXIT + +tar tfz ${TARBALL} | grep '^package/lib/.*\.js$' || (echo "tarball contained no .js files"; exit 1) +tar tfz ${TARBALL} | grep '^package/lib/.*\.d\.ts$' || (echo "tarball contained no .d.ts files"; exit 1) + +echo "tarball contained .js and .d.ts files in package/lib/ - OK" diff --git a/src/initLDClient.test.ts b/src/initLDClient.test.ts index 13f7008..716e105 100644 --- a/src/initLDClient.test.ts +++ b/src/initLDClient.test.ts @@ -10,13 +10,12 @@ jest.mock('launchdarkly-js-client-sdk', () => { import { initialize, LDClient, LDOptions, LDUser } from 'launchdarkly-js-client-sdk'; import { defaultReactOptions, LDReactOptions } from './types'; import initLDClient from './initLDClient'; -import * as packageJson from '../package.json'; const ldClientInitialize = initialize as jest.Mock; const clientSideID = 'deadbeef'; const defaultUser: LDUser = { key: 'abcdef' }; -const options: LDOptions = { bootstrap: 'localStorage', wrapperName: 'React', wrapperVersion: packageJson.version }; +const options: LDOptions = { bootstrap: 'localStorage', wrapperName: 'React' }; const flags = { 'test-flag': false, 'another-test-flag': true }; describe('initLDClient', () => { @@ -42,11 +41,7 @@ describe('initLDClient', () => { const anonUser: LDUser = { anonymous: true }; await initLDClient(clientSideID); - expect(ldClientInitialize.mock.calls[0]).toEqual([ - clientSideID, - anonUser, - { wrapperName: 'React', wrapperVersion: packageJson.version }, - ]); + expect(ldClientInitialize.mock.calls[0]).toEqual([clientSideID, anonUser, { wrapperName: 'React' }]); expect(mockLDClient.variation).toHaveBeenCalledTimes(0); }); diff --git a/src/initLDClient.ts b/src/initLDClient.ts index a1b0e55..ad0af9d 100644 --- a/src/initLDClient.ts +++ b/src/initLDClient.ts @@ -1,7 +1,6 @@ import { initialize as ldClientInitialize, LDClient, LDFlagSet, LDOptions, LDUser } from 'launchdarkly-js-client-sdk'; import { AllFlagsLDClient, defaultReactOptions, LDReactOptions } from './types'; import { camelCaseKeys } from './utils'; -import * as packageJson from '../package.json'; /** * Internal function to initialize the `LDClient`. @@ -21,7 +20,7 @@ const initLDClient = async ( options?: LDOptions, targetFlags?: LDFlagSet, ): Promise => { - const allOptions = { wrapperName: 'React', wrapperVersion: packageJson.version, ...options }; + const allOptions = { wrapperName: 'React', ...options }; const ldClient = ldClientInitialize(clientSideID, user, allOptions); return new Promise(resolve => { diff --git a/tsconfig.json b/tsconfig.json index b339c62..8ca8c65 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,8 +10,7 @@ "noImplicitAny": true, "strictNullChecks": true, "jsx": "react", - "esModuleInterop": true, - "resolveJsonModule": true, + "esModuleInterop": true }, "files": [ "./node_modules/@testing-library/jest-dom/extend-expect.d.ts"