Skip to content

Commit d8ff60a

Browse files
committed
Fix esbuild scanner error by adding outdir parameter and filtering virtual modules.
1 parent fb0ebd8 commit d8ff60a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

.notes/justin/worklogs/2025-09-21-fix-esbuild-scanner-error.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,6 @@ A recent update to `vite` (from `7.1.5` to `7.1.6`) brought in a newer version o
7575

7676
Two fixes were applied to the scanner configuration:
7777

78-
1. **Added `outdir` parameter**: The `esbuild` configuration now includes a path to a temporary system directory. Because the scanner is still configured with `write: false`, no files are actually written to disk. This satisfies the new requirement from `esbuild`.
78+
1. **Added `outdir` parameter**: The `esbuild` configuration now includes a path to the project's intermediate builds directory. Because the scanner is still configured with `write: false`, no files are actually written to disk. This satisfies the new requirement from `esbuild` while avoiding potential collisions between multiple projects.
7979

8080
2. **Filter virtual modules**: Entry points containing `virtual:` are now filtered out before being passed to esbuild, since virtual modules don't contain actual source code that can be scanned for directives.

sdk/src/vite/runDirectivesScan.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import { Environment, ResolvedConfig } from "vite";
44
import fsp from "node:fs/promises";
55
import { hasDirective } from "./hasDirective.mjs";
66
import path from "node:path";
7-
import os from "node:os";
87
import debug from "debug";
98
import { getViteEsbuild } from "./getViteEsbuild.mjs";
109
import { normalizeModulePath } from "../lib/normalizeModulePath.mjs";
10+
import { INTERMEDIATES_OUTPUT_DIR } from "../lib/constants.mjs";
1111
import { externalModules } from "./constants.mjs";
1212
import {
1313
createViteAwareResolver,
@@ -326,7 +326,7 @@ export const runDirectivesScan = async ({
326326
entryPoints: absoluteEntries,
327327
bundle: true,
328328
write: false,
329-
outdir: path.join(os.tmpdir(), "rwsdk-directive-scan"),
329+
outdir: path.join(INTERMEDIATES_OUTPUT_DIR, "directive-scan"),
330330
platform: "node",
331331
format: "esm",
332332
logLevel: "silent",

0 commit comments

Comments
 (0)