5
5
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
6
*/
7
7
8
- import path from 'node:path' ;
9
8
import process from 'node:process' ;
10
9
import { LWCServer , ServerConfig , startLwcDevServer , Workspace } from '@lwc/lwc-dev-server' ;
11
10
import { Lifecycle , Logger , SfProject } from '@salesforce/core' ;
12
11
import { SSLCertificateData } from '@salesforce/lwc-dev-mobile-core' ;
13
- import { globSync } from 'glob' ;
12
+ import { glob } from 'glob' ;
14
13
import {
15
14
ConfigUtils ,
16
15
LOCAL_DEV_SERVER_DEFAULT_HTTP_PORT ,
@@ -27,20 +26,10 @@ async function createLWCServerConfig(
27
26
workspace ?: Workspace
28
27
) : Promise < ServerConfig > {
29
28
const project = await SfProject . resolve ( ) ;
30
- const projectJson = await project . resolveProjectConfig ( ) ;
31
- const packageDirectories = projectJson . packageDirectories ;
32
- const namespacePaths : string [ ] = [ ] ;
29
+ const packageDirs = project . getPackageDirectories ( ) ;
33
30
34
- if ( ! packageDirectories || ! Array . isArray ( packageDirectories ) ) {
35
- throw new Error ( 'No package directories defined.' ) ;
36
- }
37
-
38
- for ( const dir of packageDirectories ) {
39
- if ( dir && typeof dir === 'object' && 'path' in dir && typeof dir . path === 'string' ) {
40
- const packageDirectory = path . resolve ( rootDir , dir . path ) ;
41
- namespacePaths . push ( ...globSync ( `${ packageDirectory } /*/*/lwc` ) ) ;
42
- }
43
- }
31
+ // e.g. the lwc folder in force-app/main/default/lwc
32
+ const namespacePaths = ( await Promise . all ( packageDirs . map ( ( dir ) => glob ( `${ dir . fullPath } /*/*/lwc` ) ) ) ) . flat ( ) ;
44
33
45
34
const ports = serverPorts ??
46
35
( await ConfigUtils . getLocalDevServerPorts ( ) ) ?? {
0 commit comments