resolve.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. "use strict";
  2. exports.__esModule = true;
  3. var _typeof2 = require("babel-runtime/helpers/typeof");
  4. var _typeof3 = _interopRequireDefault(_typeof2);
  5. exports.default = function (loc) {
  6. var relative = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : process.cwd();
  7. if ((typeof _module2.default === "undefined" ? "undefined" : (0, _typeof3.default)(_module2.default)) === "object") return null;
  8. var relativeMod = relativeModules[relative];
  9. if (!relativeMod) {
  10. relativeMod = new _module2.default();
  11. var filename = _path2.default.join(relative, ".babelrc");
  12. relativeMod.id = filename;
  13. relativeMod.filename = filename;
  14. relativeMod.paths = _module2.default._nodeModulePaths(relative);
  15. relativeModules[relative] = relativeMod;
  16. }
  17. try {
  18. return _module2.default._resolveFilename(loc, relativeMod);
  19. } catch (err) {
  20. return null;
  21. }
  22. };
  23. var _module = require("module");
  24. var _module2 = _interopRequireDefault(_module);
  25. var _path = require("path");
  26. var _path2 = _interopRequireDefault(_path);
  27. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  28. var relativeModules = {};
  29. module.exports = exports["default"];