From b38e949d4aff8d684ecbf12e25e20d8dd9f95332 Mon Sep 17 00:00:00 2001 From: Chang-Hung Liang Date: Fri, 2 Feb 2024 13:28:49 +0800 Subject: [PATCH] Add comments and fix a path issue in build.js --- packages/cli/src/utils/build.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/utils/build.js b/packages/cli/src/utils/build.js index fccb01f7a..9fe235715 100644 --- a/packages/cli/src/utils/build.js +++ b/packages/cli/src/utils/build.js @@ -319,6 +319,8 @@ const maybeRunBuildScript = async (options = {}) => { } }; +// Get `workspaces` from root package.json and convert them to absolute paths. +// Returns an empty array if package.json can't be found. const listWorkspaces = (workspaceRoot) => { const packageJsonPath = path.join(workspaceRoot, 'package.json'); if (!fs.existsSync(packageJsonPath)) { @@ -333,7 +335,7 @@ const listWorkspaces = (workspaceRoot) => { } return (packageJson.workspaces || []).map((relpath) => - path.join(workspaceRoot, relpath) + path.resolve(workspaceRoot, relpath) ); }; @@ -395,6 +397,8 @@ const _buildFunc = async ({ fse.readlinkSync(src) ); for (const workspace of workspaces) { + // Use minimatch to do glob pattern match. If match, it means the + // symlink points to a workspace package, so we don't copy it. if (minimatch(realPath, workspace)) { return false; }