Skip to content

Commit 9fe680c

Browse files
committed
fix: use api for packageDirs
1 parent 234f64c commit 9fe680c

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

src/lwc-dev-server/index.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77

8-
import path from 'node:path';
98
import process from 'node:process';
109
import { LWCServer, ServerConfig, startLwcDevServer, Workspace } from '@lwc/lwc-dev-server';
1110
import { Lifecycle, Logger, SfProject } from '@salesforce/core';
1211
import { SSLCertificateData } from '@salesforce/lwc-dev-mobile-core';
13-
import { globSync } from 'glob';
12+
import { glob } from 'glob';
1413
import {
1514
ConfigUtils,
1615
LOCAL_DEV_SERVER_DEFAULT_HTTP_PORT,
@@ -27,20 +26,10 @@ async function createLWCServerConfig(
2726
workspace?: Workspace
2827
): Promise<ServerConfig> {
2928
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();
3330

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();
4433

4534
const ports = serverPorts ??
4635
(await ConfigUtils.getLocalDevServerPorts()) ?? {

0 commit comments

Comments
 (0)