@teambit/dependency-resolver 1.0.347 → 1.0.349

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -221,7 +221,11 @@ export declare class DependencyResolverMain {
221
221
  getPackageName(component: Component): string;
222
222
  getDepResolverData(component: Component): DependencyResolverComponentData | undefined;
223
223
  calcPackageName(component: Component): string;
224
- getRuntimeModulePath(component: Component, isInWorkspace?: boolean): string;
224
+ getRuntimeModulePath(component: Component, options: {
225
+ workspacePath: string;
226
+ rootComponentsPath: string;
227
+ isInWorkspace?: boolean;
228
+ }): string;
225
229
  /**
226
230
  * returns the package path in the /node_modules/ folder
227
231
  * In case you call this in order to run the code from the path, please refer to the `getRuntimeModulePath` API
@@ -44,9 +44,9 @@ function _bit() {
44
44
  };
45
45
  return data;
46
46
  }
47
- function _bitRoots() {
48
- const data = require("@teambit/bit-roots");
49
- _bitRoots = function () {
47
+ function _workspace() {
48
+ const data = require("@teambit/workspace.root-components");
49
+ _workspace = function () {
50
50
  return data;
51
51
  };
52
52
  return data;
@@ -636,13 +636,15 @@ class DependencyResolverMain {
636
636
  * Returns the location where the component is installed with its peer dependencies
637
637
  * This is used in cases you want to actually run the components and make sure all the dependencies (especially peers) are resolved correctly
638
638
  */
639
- getRuntimeModulePath(component, isInWorkspace = false) {
639
+ getRuntimeModulePath(component, options) {
640
640
  if (!this.hasRootComponents()) {
641
641
  const modulePath = this.getModulePath(component);
642
642
  return modulePath;
643
643
  }
644
644
  const pkgName = this.getPackageName(component);
645
- const selfRootDir = (0, _bitRoots().getRelativeRootComponentDir)(!isInWorkspace ? component.id.toString() : component.id.toStringWithoutVersion());
645
+ const rootComponentsRelativePath = (0, _path().relative)(options.workspacePath, options.rootComponentsPath);
646
+ const getRelativeRootComponentDir = _workspace().getRootComponentDir.bind(null, rootComponentsRelativePath ?? '');
647
+ const selfRootDir = getRelativeRootComponentDir(options.isInWorkspace ? component.id.toStringWithoutVersion() : component.id.toString());
646
648
  // In case the component is it's own root we want to load it from it's own root folder
647
649
  if (_fsExtra().default.pathExistsSync(selfRootDir)) {
648
650
  const innerDir = (0, _path().join)(selfRootDir, 'node_modules', pkgName);
@@ -652,7 +654,7 @@ class DependencyResolverMain {
652
654
  return this.getModulePath(component);
653
655
  }
654
656
  const envId = this.envs.getEnvId(component);
655
- const dirInEnvRoot = (0, _path().join)((0, _bitRoots().getRelativeRootComponentDir)(envId), 'node_modules', pkgName);
657
+ const dirInEnvRoot = (0, _path().join)(getRelativeRootComponentDir(envId), 'node_modules', pkgName);
656
658
  if (_fsExtra().default.pathExistsSync(dirInEnvRoot)) return dirInEnvRoot;
657
659
  return this.getModulePath(component);
658
660
  }