Permalink
Browse files

kill `shouldThrowOnUnresolvedErrors` option

Summary: Removes the `shouldThrowOnUnresolvedErrors` option, as now it is only ever `() => true`

Reviewed By: davidaurelio

Differential Revision: D4237711

fbshipit-source-id: 9460f0f0c50dc0d08d17cb7bdeb995825f7051f3
  • Loading branch information...
cpojer authored and Facebook Github Bot committed Nov 30, 2016
1 parent 4902a03 commit b1fd7bd6413220a91e81efd18fa8544ee03b1403
@@ -37,7 +37,6 @@ type ResolveOptions = {|
|};
const platforms = new Set(defaults.platforms);
const returnTrue = () => true;
exports.createResolveFn = function(options: ResolveOptions): ResolveFn {
const {
@@ -87,7 +86,6 @@ exports.createResolveFn = function(options: ResolveOptions): ResolveFn {
platform,
platforms,
preferNativePlatform: true,
shouldThrowOnUnresolvedErrors: returnTrue,
});
}
@@ -98,7 +98,6 @@ class Resolver {
preferNativePlatform: true,
watch: opts.watch,
cache: opts.cache,
shouldThrowOnUnresolvedErrors: () => true,
transformCode: opts.transformCode,
transformCacheKey: opts.transformCacheKey,
extraNodeModules: opts.extraNodeModules,
@@ -27,8 +27,6 @@ import type Module from '../Module';
import type ModuleCache from '../ModuleCache';
import type ResolutionResponse from './ResolutionResponse';
const emptyModule = require.resolve('./assets/empty-module.js');
type DirExistsFn = (filePath: string) => boolean;
type Options = {
@@ -43,7 +41,6 @@ type Options = {
platform: string,
platforms: Set<string>,
preferNativePlatform: boolean,
shouldThrowOnUnresolvedErrors: () => boolean,
};
class ResolutionRequest {
@@ -58,7 +55,7 @@ class ResolutionRequest {
_platform: string;
_platforms: Set<string>;
_preferNativePlatform: boolean;
_shouldThrowOnUnresolvedErrors: () => boolean;
static emptyModule: string;
constructor({
dirExists,
@@ -71,7 +68,6 @@ class ResolutionRequest {
platform,
platforms,
preferNativePlatform,
shouldThrowOnUnresolvedErrors,
}: Options) {
this._dirExists = dirExists;
this._entryPath = entryPath;
@@ -83,7 +79,6 @@ class ResolutionRequest {
this._platform = platform;
this._platforms = platforms;
this._preferNativePlatform = preferNativePlatform;
this._shouldThrowOnUnresolvedErrors = shouldThrowOnUnresolvedErrors;
this._resetResolutionCache();
}
@@ -109,38 +104,16 @@ class ResolutionRequest {
return result;
};
const forgive = (error) => {
if (
error.type !== 'UnableToResolveError' ||
this._shouldThrowOnUnresolvedErrors(this._entryPath, this._platform)
) {
throw error;
}
debug(
'Unable to resolve module %s from %s',
toModuleName,
fromModule.path
);
return null;
};
if (!this._helpers.isNodeModulesDir(fromModule.path)
&& !(isRelativeImport(toModuleName) || isAbsolutePath(toModuleName))) {
return this._tryResolve(
() => this._resolveHasteDependency(fromModule, toModuleName),
() => this._resolveNodeDependency(fromModule, toModuleName)
).then(
cacheResult,
forgive,
);
).then(cacheResult);
}
return this._resolveNodeDependency(fromModule, toModuleName)
.then(
cacheResult,
forgive,
);
.then(cacheResult);
}
getOrderedDependencies({
@@ -311,7 +284,11 @@ class ResolutionRequest {
return this._redirectRequire(fromModule, potentialModulePath).then(
realModuleName => {
if (realModuleName === false) {
return this._loadAsFile(emptyModule, fromModule, toModuleName);
return this._loadAsFile(
ResolutionRequest.emptyModule,
fromModule,
toModuleName,
);
}
return this._tryResolve(
@@ -330,7 +307,11 @@ class ResolutionRequest {
realModuleName => {
// exclude
if (realModuleName === false) {
return this._loadAsFile(emptyModule, fromModule, toModuleName);
return this._loadAsFile(
ResolutionRequest.emptyModule,
fromModule,
toModuleName,
);
}
if (isRelativeImport(realModuleName) || isAbsolutePath(realModuleName)) {
@@ -526,4 +507,6 @@ function isRelativeImport(filePath) {
return /^[.][.]?(?:[/]|$)/.test(filePath);
}
ResolutionRequest.emptyModule = require.resolve('./assets/empty-module.js');
module.exports = ResolutionRequest;
Oops, something went wrong.

0 comments on commit b1fd7bd

Please sign in to comment.