Skip to content

Commit

Permalink
Move to new ld client package, import package via ember-auto import (#…
Browse files Browse the repository at this point in the history
…133)

* Move to new ld client package, import package via ember-auto import

* bump yarn version

Co-authored-by: Jared Galanis <[email protected]>

* Update addon/services/launch-darkly-client-remote.js

Co-authored-by: Chris Manson <[email protected]>

* update client to use new import style
- removes dead code path for LDClient on window
- uses imported initialize directly rather than calling it on the client

* remove .yarnrc.yml

* update to latest LD JS sdk

* bump auto import version to latest release

* remove unnecessary change to .gitignore

Co-authored-by: Jared Galanis <[email protected]>
Co-authored-by: Chris Manson <[email protected]>
Co-authored-by: Jared Galanis <[email protected]>
  • Loading branch information
4 people authored Sep 5, 2020
1 parent 2b17cb6 commit 8f5563b
Show file tree
Hide file tree
Showing 4 changed files with 2,814 additions and 53 deletions.
11 changes: 2 additions & 9 deletions addon/services/launch-darkly-client-remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getOwner } from '@ember/application';
import { assert, warn } from '@ember/debug';
import { run } from '@ember/runloop';
import Evented from '@ember/object/evented';
import { initialize } from 'launchdarkly-js-client-sdk';

import RSVP from 'rsvp';

Expand Down Expand Up @@ -38,14 +39,6 @@ export default Service.extend(Evented, {
return RSVP.resolve();
}

if (!window.LDClient) {
warn('Launch Darkly JS client not found. Defaulting all feature flags to "false"', false, { id: 'ember-launch-darkly.client-not-found' });

this.set('_client', NullClient);

return RSVP.resolve();
}

return this._initialize(clientSideId, user, streaming);
},

Expand All @@ -69,7 +62,7 @@ export default Service.extend(Evented, {

_initialize(id, user, streamingOptions) {
return new RSVP.Promise((resolve, reject) => {
let client = window.LDClient.initialize(id, user);
let client = initialize(id, user);

client.on('ready', () => {
this.set('_client', client);
Expand Down
10 changes: 0 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ module.exports = {
included() {
this._super.included.apply(this, arguments);

this.import('vendor/ldclient.js');

if (this._shouldIncludePolyfill()) {
this.import('vendor/eventsource.js');
}
Expand All @@ -35,21 +33,13 @@ module.exports = {
treeForVendor(vendorTree) {
let trees = vendorTree ? [vendorTree] : [];

trees.push(this._launchDarklyTree());

if (this._shouldIncludePolyfill()) {
trees.push(this._eventSourceTree());
}

return new MergeTrees(trees);
},

_launchDarklyTree() {
return new Funnel(path.dirname(require.resolve('ldclient-js/dist/ldclient.js')), {
files: ['ldclient.js'],
});
},

_eventSourceTree() {
return new Funnel(path.dirname(require.resolve('event-source-polyfill/eventsource.js')), {
files: ['eventsource.js'],
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
"test-node": "./node_modules/mocha/bin/mocha nodetests/**/*-test.js"
},
"dependencies": {
"ember-auto-import": "^1.6.0",
"ember-cli-babel": "^7.7.3",
"ember-test-waiters": "^1.1.1",
"event-source-polyfill": "^0.0.9",
"ldclient-js": "1.7.4"
"launchdarkly-js-client-sdk": "^2.18.0"
},
"devDependencies": {
"@ember/optional-features": "^0.7.0",
Expand Down
Loading

0 comments on commit 8f5563b

Please sign in to comment.