diff --git a/Sources/Build/BuildPlan.swift b/Sources/Build/BuildPlan.swift index f8716c60afe..85c5a813de8 100644 --- a/Sources/Build/BuildPlan.swift +++ b/Sources/Build/BuildPlan.swift @@ -658,13 +658,26 @@ public final class SwiftTargetBuildDescription { // Do nothing if we're not generating a bundle. guard let bundlePath = self.bundlePath else { return } + let mainPathSubstitution: String + if buildParameters.triple.isWASI() { + // We prefer compile-time evaluation of the bundle path here for WASI. There's no benefit in evaluating this at runtime, + // especially as Bundle support in WASI Foundation is partial. We expect all resource paths to evaluate to + // `/\(resourceBundleName)/\(resourcePath)`, which allows us to pass this path to JS APIs like `fetch` directly, or to + // `