@travetto/manifest 4.0.0-rc.3 → 4.0.0-rc.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/manifest",
3
- "version": "4.0.0-rc.3",
3
+ "version": "4.0.0-rc.4",
4
4
  "description": "Support for project indexing, manifesting, along with file watching",
5
5
  "keywords": [
6
6
  "path",
@@ -31,32 +31,52 @@ export class PackageModuleVisitor {
31
31
  #cache: Record<string, PackageModule> = {};
32
32
  #workspaceModules: Map<string, string>;
33
33
 
34
+ /**
35
+ * Get monorepo root includes
36
+ */
37
+ #getMonoRootIncludes(parent: Req): Req[] {
38
+ if (!(this.ctx.workspace.mono && !this.ctx.main.folder)) { // If not mono root, bail
39
+ return [];
40
+ }
41
+
42
+ return [...this.#workspaceModules.values()]
43
+ .map(loc => this.#create(loc, { main: true, workspace: true, roleRoot: true, parent: parent.value }));
44
+ }
45
+
46
+ /**
47
+ * Determine default includes
48
+ */
49
+ #getIncludes(parent: Req): Req[] {
50
+ if (this.ctx.workspace.mono && !this.ctx.main.folder) { // If mono and not at mono root, bail
51
+ return [];
52
+ }
53
+
54
+ const root = PackageUtil.readPackage(this.ctx.workspace.path);
55
+ if (root.travetto?.build?.includes) {
56
+ return Object.entries(root.travetto.build.includes).map(([name, type]) =>
57
+ this.#create(PackageUtil.resolvePackagePath(name), { main: type === 'main', workspace: true, parent: parent.value })
58
+ );
59
+ } else {
60
+ return [...this.#workspaceModules.values()]
61
+ .filter((loc) => PackageUtil.readPackage(loc).travetto?.workspaceInclude)
62
+ .map(loc => this.#create(loc, { workspace: true, parent: parent.value }));
63
+ }
64
+ }
65
+
34
66
  /**
35
67
  * Initialize visitor, and provide global dependencies
36
68
  */
37
69
  async init(): Promise<Iterable<Req>> {
38
70
  const mainReq = this.#create(this.#mainSourcePath, { main: true, workspace: true, roleRoot: true, prod: true });
39
- const globals = [mainReq];
40
71
  this.#workspaceModules = new Map(
41
72
  (await PackageUtil.resolveWorkspaces(this.ctx)).map(x => [x.name, x.path])
42
73
  );
43
74
 
44
- // Treat all workspace modules as main modules
45
- if (this.ctx.workspace.mono && !this.ctx.main.folder) {
46
- for (const [, loc] of this.#workspaceModules) {
47
- globals.push(this.#create(loc, { main: true, workspace: true, roleRoot: true, parent: mainReq.value }));
48
- }
49
- } else {
50
- // If we have 'withModules' at workspace root
51
- const root = PackageUtil.readPackage(this.ctx.workspace.path);
52
- for (const [name, type] of Object.entries(root.travetto?.build?.withModules ?? {})) {
53
- globals.push(this.#create(PackageUtil.resolvePackagePath(name),
54
- { main: type === 'main', workspace: true, parent: mainReq.value }
55
- ));
56
- }
57
- }
58
-
59
- return globals;
75
+ return [
76
+ mainReq,
77
+ ...this.#getMonoRootIncludes(mainReq),
78
+ ...this.#getIncludes(mainReq)
79
+ ];
60
80
  }
61
81
 
62
82
  /**
@@ -41,9 +41,10 @@ export type Package = {
41
41
  outputs?: string[];
42
42
  };
43
43
  defaultEnv?: string;
44
+ workspaceInclude?: boolean;
44
45
  build?: Partial<ManifestContext['build']> & {
45
46
  isolated?: boolean;
46
- withModules?: Record<string, 'main' | true>;
47
+ includes?: Record<string, 'main' | true>;
47
48
  watchIgnores?: string[];
48
49
  };
49
50
  };