@travetto/manifest 3.4.0-rc.3 → 3.4.0

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/root-index.ts +12 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/manifest",
3
- "version": "3.4.0-rc.3",
3
+ "version": "3.4.0",
4
4
  "description": "Support for project indexing, manifesting, along with file watching",
5
5
  "keywords": [
6
6
  "path",
package/src/root-index.ts CHANGED
@@ -102,6 +102,18 @@ class $RootIndex extends ManifestIndex {
102
102
  const id = clsId === undefined ? '' : typeof clsId === 'string' ? clsId : clsId.Ⲑid;
103
103
  return this.#metadata.get(id);
104
104
  }
105
+
106
+ /**
107
+ * Resolve module path to folder, with support for main module and monorepo support
108
+ */
109
+ resolveModulePath(modulePath: string): string {
110
+ const main = this.manifest.mainModule;
111
+ const workspace = this.manifest.workspacePath;
112
+ const [base, sub] = modulePath
113
+ .replace(/^(@@?)(#|$)/g, (_, v, r) => `${v === '@' ? main : workspace}${r}`)
114
+ .split('#');
115
+ return path.resolve(this.hasModule(base) ? this.getModule(base)!.sourcePath : base, sub ?? '.');
116
+ }
105
117
  }
106
118
 
107
119
  let index: $RootIndex | undefined;