Sha256: fd9b7c5d4dd15f1578fd95c1621fcfec2a8dc988d23fff4c36edd5df152ac15c

Contents?: true

Size: 1.25 KB

Versions: 33

Compression:

Stored size: 1.25 KB

Contents

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = getModuleName;

function getModuleName(rootOpts, pluginOpts) {
  var _pluginOpts$moduleRoo, _rootOpts$moduleIds, _rootOpts$moduleRoot;

  const {
    filename,
    filenameRelative = filename,
    sourceRoot = (_pluginOpts$moduleRoo = pluginOpts.moduleRoot) != null ? _pluginOpts$moduleRoo : rootOpts.moduleRoot
  } = rootOpts;
  const {
    moduleId = rootOpts.moduleId,
    moduleIds = (_rootOpts$moduleIds = rootOpts.moduleIds) != null ? _rootOpts$moduleIds : !!moduleId,
    getModuleId = rootOpts.getModuleId,
    moduleRoot = (_rootOpts$moduleRoot = rootOpts.moduleRoot) != null ? _rootOpts$moduleRoot : sourceRoot
  } = pluginOpts;
  if (!moduleIds) return null;

  if (moduleId != null && !getModuleId) {
    return moduleId;
  }

  let moduleName = moduleRoot != null ? moduleRoot + "/" : "";

  if (filenameRelative) {
    const sourceRootReplacer = sourceRoot != null ? new RegExp("^" + sourceRoot + "/?") : "";
    moduleName += filenameRelative.replace(sourceRootReplacer, "").replace(/\.(\w*?)$/, "");
  }

  moduleName = moduleName.replace(/\\/g, "/");

  if (getModuleId) {
    return getModuleId(moduleName) || moduleName;
  } else {
    return moduleName;
  }
}

Version data entries

33 entries across 32 versions & 6 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/@babel/helper-module-transforms/lib/get-module-name.js
trusty-cms-5.0.7 node_modules/@babel/helper-module-transforms/lib/get-module-name.js
trusty-cms-5.0.6 node_modules/@babel/helper-module-transforms/lib/get-module-name.js
trusty-cms-5.0.5 node_modules/@babel/helper-module-transforms/lib/get-module-name.js
trusty-cms-5.0.4 node_modules/@babel/helper-module-transforms/lib/get-module-name.js
trusty-cms-5.0.3 node_modules/@babel/helper-module-transforms/lib/get-module-name.js
trusty-cms-5.0.2 node_modules/@babel/helper-module-transforms/lib/get-module-name.js
trusty-cms-5.0.1 node_modules/@babel/helper-module-transforms/lib/get-module-name.js
trusty-cms-4.3.5 node_modules/@babel/helper-module-transforms/lib/get-module-name.js
trusty-cms-5.0.0 node_modules/@babel/helper-module-transforms/lib/get-module-name.js
trusty-cms-4.3.4 node_modules/@babel/helper-module-transforms/lib/get-module-name.js
trusty-cms-4.3.3 node_modules/@babel/helper-module-transforms/lib/get-module-name.js
trusty-cms-4.3.2 node_modules/@babel/helper-module-transforms/lib/get-module-name.js
trusty-cms-4.3.1 node_modules/@babel/helper-module-transforms/lib/get-module-name.js
trusty-cms-4.3 node_modules/@babel/helper-module-transforms/lib/get-module-name.js
trusty-cms-4.2.3 node_modules/@babel/helper-module-transforms/lib/get-module-name.js
tang-0.2.1 spec/tang_app/node_modules/@babel/helper-module-transforms/lib/get-module-name.js
trusty-cms-4.2.2 node_modules/@babel/helper-module-transforms/lib/get-module-name.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/@babel/helper-module-transforms/lib/get-module-name.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/@babel/helper-module-transforms/lib/get-module-name.js