Skip to content

Fix 'events' resolution issue #240

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 1 commit into from
Mar 24, 2016
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
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ gulp.task('compile', function() {

gulp.task('browserify', function() {
var stream = browserify({
builtins: { _process: true },
builtins: ['_process', 'events'],
entries: 'lib/browser/Parse.js',
standalone: 'Parse'
})
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
},
"dependencies": {
"babel-runtime": "^5.8.20",
"events": "^1.1.0",
"ws": "^1.0.1",
"xmlhttprequest": "^1.7.0"
},
Expand Down
16 changes: 16 additions & 0 deletions src/EventEmitter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Copyright (c) 2015-present, Parse, LLC.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* This is a simple wrapper to unify EventEmitter implementations across platforms.
*/

if (process.env.PARSE_BUILD === 'react-native') {
module.exports = require('EventEmitter');
} else {
module.exports = require('events').EventEmitter;
}
4 changes: 2 additions & 2 deletions src/LiveQueryClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
*/

import events from 'events';
import EventEmitter from './EventEmitter';
import ParsePromise from './ParsePromise';
import ParseObject from './ParseObject';
import LiveQuerySubscription from './LiveQuerySubscription';
Expand Down Expand Up @@ -122,7 +122,7 @@ let generateInterval = (k) => {
*
*
*/
export default class LiveQueryClient extends events.EventEmitter {
export default class LiveQueryClient extends EventEmitter {
attempts: number;
id: number;
requestId: number;
Expand Down
4 changes: 2 additions & 2 deletions src/LiveQuerySubscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
*/

import events from 'events';
import EventEmitter from './EventEmitter';
import CoreManager from './CoreManager';

/**
Expand Down Expand Up @@ -90,7 +90,7 @@ import CoreManager from './CoreManager';
*
*
*/
export default class Subscription extends events.EventEmitter {
export default class Subscription extends EventEmitter {
constructor(id, query, sessionToken) {
super();
this.id = id;
Expand Down
4 changes: 2 additions & 2 deletions src/ParseLiveQuery.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import events from 'events';
import EventEmitter from './EventEmitter';
import LiveQueryClient from './LiveQueryClient';
import CoreManager from './CoreManager';

Expand Down Expand Up @@ -41,7 +41,7 @@ function close() {
* @static
*
*/
let LiveQuery = new events.EventEmitter();
let LiveQuery = new EventEmitter();

/**
* After open is called, the LiveQuery will try to send a connect request
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/LiveQueryClient-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jest.dontMock('../decode');
jest.dontMock('../encode');
jest.dontMock('../equals');
jest.dontMock('../escape');
jest.dontMock('../EventEmitter');
jest.dontMock('../ObjectStateMutations');
jest.dontMock('../parseDate');
jest.dontMock('../ParseError');
Expand Down