Permalink
Browse files

Support `false` mappings in `"browser"` fields

Summary:
This adds support for `false` values in `package.json` `"browser"` and `"react-native"` mappings.
All `false` values are not longer silently ignored, but redirected to an empty file.

Fixes #9854 #9518

Reviewed By: bestander

Differential Revision: D3876521

fbshipit-source-id: 96d1ba03518812bc88c51672c374956eabd40c9b
  • Loading branch information...
1 parent 0c157be commit 5710b230a2a0f2b29553fbf94af5147a2e030f44 @davidaurelio davidaurelio committed with Facebook Github Bot 7 Sep 16, 2016
@@ -17,6 +17,8 @@ const realPath = require('path');
const isAbsolutePath = require('absolute-path');
const getAssetDataFromName = require('../lib/getAssetDataFromName');
+const emptyModule = require.resolve('./assets/empty-module.js');
+
class ResolutionRequest {
constructor({
platform,
@@ -193,7 +195,7 @@ class ResolutionRequest {
if (recursive) {
// doesn't block the return of this function invocation, but defers
- // the resulution of collectionsInProgress.done.then()
+ // the resulution of collectionsInProgress.done.then(...)
dependencyModules
.forEach(dependency => collectedDependencies.get(dependency));
}
@@ -322,7 +324,7 @@ class ResolutionRequest {
return this._redirectRequire(fromModule, potentialModulePath).then(
realModuleName => {
if (realModuleName === false) {
- return null;
+ return this._loadAsFile(emptyModule, fromModule, toModuleName);
}
return this._tryResolve(
@@ -341,7 +343,7 @@ class ResolutionRequest {
realModuleName => {
// exclude
if (realModuleName === false) {
- return null;
+ return this._loadAsFile(emptyModule, fromModule, toModuleName);
}
if (isRelativeImport(realModuleName) || isAbsolutePath(realModuleName)) {
@@ -0,0 +1,8 @@
+ /**
+ * Copyright (c) 2015-present, Facebook, Inc.
+ * 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.
+ */

1 comment on commit 5710b23

@aleclarson
Contributor

👍

Please sign in to comment.