Skip to content

Commit

Permalink
Use module.require to avoid webpack complaints about unmet dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamn committed Jul 5, 2018
1 parent 8c97e45 commit d45ebad
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions lib/local.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
"use strict";

var fakeNullFiber = function Fiber(){};
var fakeNullFiber = new (function Fiber(){});
var localKey = "_optimism_local";

function getCurrentFiber() {
return fakeNullFiber;
}

try {
var fiberPath = require.resolve("fibers");
} catch (e) {}

if (fiberPath) {
var Fiber = require(fiberPath);

// If we were able to require("fibers"), redefine the getCurrentFiber
// function so that it has a chance to return Fiber.current.
getCurrentFiber = function () {
return Fiber.current || fakeNullFiber;
};
if (typeof module === "object") {
try {
var Fiber = module.require("fibers");
// If we were able to require fibers, redefine the getCurrentFiber
// function so that it has a chance to return Fiber.current.
getCurrentFiber = function () {
return Fiber.current || fakeNullFiber;
};
} catch (e) {}
}

// Returns an object unique to Fiber.current, if fibers are enabled.
Expand Down

0 comments on commit d45ebad

Please sign in to comment.