Skip to content

Commit

Permalink
Remove knowledge of fbjs from the packager
Browse files Browse the repository at this point in the history
Summary:
As spicyj mentioned in commit 6a838a4, the ideal state of affairs when it comes to consuming `react` and `fbjs` from NPM is for the packager not to have knowledge of either package. This PR addresses the `fbjs` part of that, and relies on facebook/fbjs#95. **DO NOT MERGE** until facebook#95 (or a variation) is in `fbjs` and is released to npm.

This PR does several things:

1. Adds stub modules within RN that expose `fbjs` modules to be required using Haste. After discussing a few ideas with spicyj, this seemed like a good option to keep internal FB devs happy (and not make them change the way they write JS), but allow for removing packager complexity and fit in better with the NPM ecosystem. Note -- it skips stubbing `fetch`, `ExecutionEnvironment`, and `ErrorUtils`, due to the fact that these need to have Native specific implementations, and there's no reason for those implementations to exist in `fbjs`.
2. Removes the modules that were previously being used in lieu of their `fbjs` eq
Closes facebook#5084

Reviewed By: bestander

Differential Revision: D2803288

Pulled By: davidaurelio

fb-gh-sync-id: fd257958ee2f8696eebe9048c1e7628c168bf4a2
shipit-source-id: fd257958ee2f8696eebe9048c1e7628c168bf4a2
  • Loading branch information
skevy authored and pglotov committed Mar 15, 2016
1 parent 465201f commit 2ad628c
Show file tree
Hide file tree
Showing 63 changed files with 848 additions and 892 deletions.
4 changes: 0 additions & 4 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@

# Ignore react and fbjs where there are overlaps, but don't ignore
# anything that react-native relies on
.*/node_modules/fbjs/lib/Map.js
.*/node_modules/fbjs/lib/Promise.js
.*/node_modules/fbjs/lib/fetch.js
.*/node_modules/fbjs/lib/ExecutionEnvironment.js
.*/node_modules/fbjs/lib/isEmpty.js
.*/node_modules/fbjs/lib/crc32.js
.*/node_modules/fbjs/lib/ErrorUtils.js

# Flow has a built-in definition for the 'react' module which we prefer to use
Expand Down
1 change: 1 addition & 0 deletions Libraries/Interaction/__tests__/InteractionManager-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

jest
.autoMockOff()
.mock('ErrorUtils')
.mock('BatchedBridge');

function expectToBeCalledOnce(fn) {
Expand Down
36 changes: 8 additions & 28 deletions Libraries/Promise.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
/**
* Copyright (c) 2016-present, Facebook, Inc.
* All rights reserved.
*
* Copyright 2013-2014 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* 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.
*
* @providesModule Promise
*
* This module wraps and augments the minimally ES6-compliant Promise
* implementation provided by the promise npm package.
* @flow
*/

'use strict';

global.setImmediate = require('setImmediate');
var Promise = require('promise/setimmediate/es6-extensions');
require('promise/setimmediate/done');
const Promise = require('fbjs/lib/Promise'); // this will require Promise.native.js

if (__DEV__) {
require('promise/setimmediate/rejection-tracking').enable({
allRejections: true,
Expand All @@ -46,12 +34,4 @@ if (__DEV__) {
});
}

/**
* Handle either fulfillment or rejection with the same callback.
*/
Promise.prototype.finally = function(onSettled) {
return this.then(onSettled, onSettled);
};


module.exports = Promise;
Loading

0 comments on commit 2ad628c

Please sign in to comment.