1 | "use strict";
|
---|
2 |
|
---|
3 | Object.defineProperty(exports, "__esModule", {
|
---|
4 | value: true
|
---|
5 | });
|
---|
6 | exports.default = _default;
|
---|
7 |
|
---|
8 | var _path = require("path");
|
---|
9 |
|
---|
10 | var _module = require("module");
|
---|
11 |
|
---|
12 | function _default(moduleName, dirname, absoluteRuntime) {
|
---|
13 | if (absoluteRuntime === false) return moduleName;
|
---|
14 | return resolveAbsoluteRuntime(moduleName, _path.resolve(dirname, absoluteRuntime === true ? "." : absoluteRuntime));
|
---|
15 | }
|
---|
16 |
|
---|
17 | function resolveAbsoluteRuntime(moduleName, dirname) {
|
---|
18 | try {
|
---|
19 | return _path.dirname((((v, w) => (v = v.split("."), w = w.split("."), +v[0] > +w[0] || v[0] == w[0] && +v[1] >= +w[1]))(process.versions.node, "8.9") ? require.resolve : (r, {
|
---|
20 | paths: [b]
|
---|
21 | }, M = require("module")) => {
|
---|
22 | let f = M._findPath(r, M._nodeModulePaths(b).concat(b));
|
---|
23 |
|
---|
24 | if (f) return f;
|
---|
25 | f = new Error(`Cannot resolve module '${r}'`);
|
---|
26 | f.code = "MODULE_NOT_FOUND";
|
---|
27 | throw f;
|
---|
28 | })(`${moduleName}/package.json`, {
|
---|
29 | paths: [dirname]
|
---|
30 | })).replace(/\\/g, "/");
|
---|
31 | } catch (err) {
|
---|
32 | if (err.code !== "MODULE_NOT_FOUND") throw err;
|
---|
33 | throw Object.assign(new Error(`Failed to resolve "${moduleName}" relative to "${dirname}"`), {
|
---|
34 | code: "BABEL_RUNTIME_NOT_FOUND",
|
---|
35 | runtime: moduleName,
|
---|
36 | dirname
|
---|
37 | });
|
---|
38 | }
|
---|
39 | } |
---|