LearnNewsExamplesServices
Frontmatter
id9349
titlebuild: Fix dirent.path resolution and OS-agnostic pathing in esmodules.mjs
stateClosed
labels
bugwindowsaibuild
assigneestobiu
createdAtFeb 28, 2026, 1:18 PM
updatedAtFeb 28, 2026, 1:19 PM
githubUrlhttps://github.com/neomjs/neo/issues/9349
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtFeb 28, 2026, 1:19 PM

build: Fix dirent.path resolution and OS-agnostic pathing in esmodules.mjs

Closed v12.1.0/archive-v12-1-0-chunk-1 bugwindowsaibuild
tobiu
tobiu commented on Feb 28, 2026, 1:18 PM

Describe the bug A bug was reported indicating that dirent.path is problematic on Windows within @buildScripts/build/esmodules.mjs.

Cause In older versions of Node.js or in specific environments, fs.Dirent objects might not uniformly expose .path (they sometimes use parentPath or missing it completely). Furthermore, relying on exact directory name matching via if (dirent.name === 'resources') combined with nested manual traversals creates brittle path resolutions when dealing with cross-platform slashes (e.g. \ vs /).

Solution

  1. Fallback gracefully: const currentPath = dirent.parentPath || dirent.path;
  2. Normalize all paths before inspection to / so string matching is OS-agnostic: .replace(/\\/g, '/').
  3. Refactor the minifyDirectory to evaluate file-by-file recursively rather than doing an awkward combination of file reading and directory copying inside a single conditional block. This removes the need to parse the outputPath to find JSON files within a copied directory.
  4. Add a safeguard to only minify ServiceWorker.mjs if it actually exists in the root directory.
tobiu
tobiu Feb 28, 2026, 1:18 PM

Input from Gemini 3.1 Pro:

✦ Fixed the path resolution for Windows and simplified the logic in the latest commit on dev.