@@ -77,7 +77,7 @@ namespace Moduless
77
77
function getGraphFromDependencies ( projectPath : string )
78
78
{
79
79
const graph = new ProjectGraph ( projectPath ) ;
80
- const out : { project : Project ; export : object ; } [ ] = [ ] ;
80
+ const out : { project : Project ; exported : object ; } [ ] = [ ] ;
81
81
82
82
for ( const project of graph . eachProject ( ) )
83
83
{
@@ -89,10 +89,9 @@ namespace Moduless
89
89
90
90
try
91
91
{
92
- const exp = require ( project . outFile ) ;
93
-
94
- if ( exp && typeof exp === "object" && ! Array . isArray ( exp ) )
95
- out . push ( { project, export : exp } ) ;
92
+ const ex = require ( project . outFile ) ;
93
+ if ( ex && typeof ex === "object" && ! Array . isArray ( ex ) )
94
+ out . push ( { project, exported : ex } ) ;
96
95
}
97
96
catch ( e )
98
97
{
@@ -116,6 +115,24 @@ namespace Moduless
116
115
if ( ! startingProject )
117
116
throw new Error ( "No projects found at location: " + target . projectPath ) ;
118
117
118
+ // Globalize the exports of all projects.
119
+ for ( const { project, exported } of graph )
120
+ {
121
+ for ( const [ name , value ] of Object . entries ( exported ) )
122
+ {
123
+ if ( name in globalThis )
124
+ {
125
+ console . warn (
126
+ `Skipping adding ${ name } from ${ project . projectPath } to global scope ` +
127
+ `because another member with this name is already defined globally.` ) ;
128
+
129
+ continue ;
130
+ }
131
+
132
+ ( globalThis as any ) [ name ] = value ;
133
+ }
134
+ }
135
+
119
136
const tryResolveNamepace = ( root : object ) =>
120
137
{
121
138
let current : any = root ;
@@ -132,7 +149,7 @@ namespace Moduless
132
149
} ;
133
150
134
151
const namespaceObject =
135
- tryResolveNamepace ( startingProject . export ) ||
152
+ tryResolveNamepace ( startingProject . exported ) ||
136
153
globalThis ;
137
154
138
155
const covers = ( ( ) =>
0 commit comments