Skip to content

Commit bd8494b

Browse files
PackageToJS: Share the linked JS modules with the aggregated glue
The per-runner `bridge-js.js` copied to the base output directory for test preludes imports its JavaScript modules relative to itself, so copy the `bridge-js-modules` directory next to it.
1 parent 35088fc commit bd8494b

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

Plugins/PackageToJS/Sources/PackageToJSPlugin.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -373,13 +373,15 @@ struct PackageToJSPlugin: CommandPlugin {
373373
// BridgeJS emits an aggregated `bridge-js.js` (generated from every test
374374
// target's skeletons, so identical across runners). Test preludes import it from
375375
// the base output directory, so surface a copy there when packaging into a
376-
// per-runner subdirectory.
376+
// per-runner subdirectory. The glue imports the JavaScript modules it was linked
377+
// against by a path relative to itself, so carry those over as well.
377378
if outputDir != baseOutputDir {
378-
let runnerBridge = outputDir.appending(path: "bridge-js.js")
379-
if FileManager.default.fileExists(atPath: runnerBridge.path) {
380-
let baseBridge = baseOutputDir.appending(path: "bridge-js.js")
381-
try? FileManager.default.removeItem(at: baseBridge)
382-
try FileManager.default.copyItem(at: runnerBridge, to: baseBridge)
379+
for entry in ["bridge-js.js", "bridge-js-modules"] {
380+
let packaged = outputDir.appending(path: entry)
381+
guard FileManager.default.fileExists(atPath: packaged.path) else { continue }
382+
let shared = baseOutputDir.appending(path: entry)
383+
try? FileManager.default.removeItem(at: shared)
384+
try FileManager.default.copyItem(at: packaged, to: shared)
383385
}
384386
}
385387

0 commit comments

Comments
 (0)