@teambit/dependency-resolver 1.0.337 → 1.0.339
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.
- package/artifacts/__bit_junit.xml +24 -24
- package/artifacts/preview/teambit_dependencies_dependency_resolver-preview.js +1 -1
- package/artifacts/schema.json +1146 -858
- package/dist/dependency-resolver.main.runtime.d.ts +6 -1
- package/dist/dependency-resolver.main.runtime.js +24 -6
- package/dist/dependency-resolver.main.runtime.js.map +1 -1
- package/dist/{preview-1721099996991.js → preview-1721223204715.js} +2 -2
- package/package.json +18 -18
|
@@ -221,7 +221,12 @@ export declare class DependencyResolverMain {
|
|
|
221
221
|
getPackageName(component: Component): string;
|
|
222
222
|
getDepResolverData(component: Component): DependencyResolverComponentData | undefined;
|
|
223
223
|
calcPackageName(component: Component): string;
|
|
224
|
-
|
|
224
|
+
getRuntimeModulePathInWorkspace(component: Component, opts: {
|
|
225
|
+
workspacePath: string;
|
|
226
|
+
rootComponentsPath: string;
|
|
227
|
+
}): string;
|
|
228
|
+
getRuntimeModulePathInCapsules(component: Component): string;
|
|
229
|
+
_getRuntimeModulePath(component: Component, rootComponentsRelativePath?: string): string;
|
|
225
230
|
/**
|
|
226
231
|
* returns the package path in the /node_modules/ folder
|
|
227
232
|
* 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
|
|
48
|
-
const data = require("@teambit/
|
|
49
|
-
|
|
47
|
+
function _workspace() {
|
|
48
|
+
const data = require("@teambit/workspace.root-components");
|
|
49
|
+
_workspace = function () {
|
|
50
50
|
return data;
|
|
51
51
|
};
|
|
52
52
|
return data;
|
|
@@ -632,17 +632,35 @@ class DependencyResolverMain {
|
|
|
632
632
|
return (0, _pkgModules().componentIdToPackageName)(component.state._consumer);
|
|
633
633
|
}
|
|
634
634
|
|
|
635
|
+
/*
|
|
636
|
+
* Returns the location where the component is installed with its peer dependencies inside a workspace.
|
|
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
|
+
*/
|
|
639
|
+
getRuntimeModulePathInWorkspace(component, opts) {
|
|
640
|
+
const rootComponentsRelativePath = (0, _path().relative)(opts.workspacePath, opts.rootComponentsPath);
|
|
641
|
+
return this._getRuntimeModulePath(component, rootComponentsRelativePath);
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/*
|
|
645
|
+
* Returns the location where the component is installed with its peer dependencies inside capsules.
|
|
646
|
+
* This is used in cases you want to actually run the components and make sure all the dependencies (especially peers) are resolved correctly
|
|
647
|
+
*/
|
|
648
|
+
getRuntimeModulePathInCapsules(component) {
|
|
649
|
+
return this._getRuntimeModulePath(component);
|
|
650
|
+
}
|
|
651
|
+
|
|
635
652
|
/*
|
|
636
653
|
* Returns the location where the component is installed with its peer dependencies
|
|
637
654
|
* This is used in cases you want to actually run the components and make sure all the dependencies (especially peers) are resolved correctly
|
|
638
655
|
*/
|
|
639
|
-
|
|
656
|
+
_getRuntimeModulePath(component, rootComponentsRelativePath) {
|
|
640
657
|
if (!this.hasRootComponents()) {
|
|
641
658
|
const modulePath = this.getModulePath(component);
|
|
642
659
|
return modulePath;
|
|
643
660
|
}
|
|
644
661
|
const pkgName = this.getPackageName(component);
|
|
645
|
-
const
|
|
662
|
+
const getRelativeRootComponentDir = _workspace().getRootComponentDir.bind(null, rootComponentsRelativePath ?? '');
|
|
663
|
+
const selfRootDir = getRelativeRootComponentDir(rootComponentsRelativePath == null ? component.id.toString() : component.id.toStringWithoutVersion());
|
|
646
664
|
// In case the component is it's own root we want to load it from it's own root folder
|
|
647
665
|
if (_fsExtra().default.pathExistsSync(selfRootDir)) {
|
|
648
666
|
const innerDir = (0, _path().join)(selfRootDir, 'node_modules', pkgName);
|
|
@@ -652,7 +670,7 @@ class DependencyResolverMain {
|
|
|
652
670
|
return this.getModulePath(component);
|
|
653
671
|
}
|
|
654
672
|
const envId = this.envs.getEnvId(component);
|
|
655
|
-
const dirInEnvRoot = (0, _path().join)(
|
|
673
|
+
const dirInEnvRoot = (0, _path().join)(getRelativeRootComponentDir(envId), 'node_modules', pkgName);
|
|
656
674
|
if (_fsExtra().default.pathExistsSync(dirInEnvRoot)) return dirInEnvRoot;
|
|
657
675
|
return this.getModulePath(component);
|
|
658
676
|
}
|