Sha256: fb866f72be9d96c26fe08312d0aeea3420a18edf1c2b45969361ac97ec4e1d2f

Contents?: true

Size: 883 Bytes

Versions: 11

Compression:

Stored size: 883 Bytes

Contents

import path from "path";

import { createRequire } from "module";
const require = createRequire(import.meta.url);

export default function (moduleName, dirname, absoluteRuntime) {
  if (absoluteRuntime === false) return moduleName;

  return resolveAbsoluteRuntime(
    moduleName,
    path.resolve(dirname, absoluteRuntime === true ? "." : absoluteRuntime),
  );
}

function resolveAbsoluteRuntime(moduleName: string, dirname: string) {
  try {
    return path
      .dirname(
        require.resolve(`${moduleName}/package.json`, { paths: [dirname] }),
      )
      .replace(/\\/g, "/");
  } catch (err) {
    if (err.code !== "MODULE_NOT_FOUND") throw err;

    throw Object.assign(
      new Error(`Failed to resolve "${moduleName}" relative to "${dirname}"`),
      {
        code: "BABEL_RUNTIME_NOT_FOUND",
        runtime: moduleName,
        dirname,
      },
    );
  }
}

Version data entries

11 entries across 10 versions & 3 rubygems

Version Path
disco_app-0.16.1 test/dummy/node_modules/@babel/plugin-transform-runtime/src/get-runtime-path/index.ts
disco_app-0.15.2 test/dummy/node_modules/@babel/plugin-transform-runtime/src/get-runtime-path/index.ts
disco_app-0.18.4 test/dummy/node_modules/@babel/plugin-transform-runtime/src/get-runtime-path/index.ts
disco_app-0.18.1 test/dummy/node_modules/@babel/plugin-transform-runtime/src/get-runtime-path/index.ts
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/@babel/plugin-transform-runtime/src/get-runtime-path/index.ts
disco_app-0.14.0 test/dummy/node_modules/@babel/plugin-transform-runtime/src/get-runtime-path/index.ts
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/@babel/plugin-transform-runtime/src/get-runtime-path/index.ts
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/@babel/plugin-transform-runtime/src/get-runtime-path/index.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/@babel/plugin-transform-runtime/src/get-runtime-path/index.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/@babel/plugin-transform-runtime/src/get-runtime-path/index.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/@babel/plugin-transform-runtime/src/get-runtime-path/index.js