Skip to content

Commit 177f74f

Browse files
Added isEmpty to ExportedSkeleton and now omit exported skeletons entirely when they contain no declarations (Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift, Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift). This prevents empty exported blocks from being emitted.
Updated snapshots to match the new behavior (exported blocks disappear when empty), including the imported-only scenarios such as `CrossFileSkipsEmptyImportedFiles`. Tests/snapshots run: - `UPDATE_SNAPSHOTS=1 swift test --package-path ./Plugins/BridgeJS` - `swift test --package-path ./Plugins/BridgeJS` If you’d like runtime coverage too, run `make unittest SWIFT_SDK_ID=DEVELOPMENT-SNAPSHOT-2025-11-03-a-wasm32-unknown-wasip1`.
1 parent 123cc3f commit 177f74f

File tree

8 files changed

+6
-109
lines changed

8 files changed

+6
-109
lines changed

Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ public final class SwiftToSkeleton {
9191
return module
9292
}()
9393

94-
return BridgeJSSkeleton(moduleName: moduleName, exported: exported, imported: importedSkeleton)
94+
let exportedSkeleton: ExportedSkeleton? = exported.isEmpty ? nil : exported
95+
return BridgeJSSkeleton(moduleName: moduleName, exported: exportedSkeleton, imported: importedSkeleton)
9596
}
9697

9798
func lookupType(for type: TypeSyntax, errors: inout [DiagnosticError]) -> BridgeType? {

Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,10 @@ public struct ExportedSkeleton: Codable {
602602
self.protocols.append(contentsOf: other.protocols)
603603
assert(self.exposeToGlobal == other.exposeToGlobal)
604604
}
605+
606+
public var isEmpty: Bool {
607+
functions.isEmpty && classes.isEmpty && enums.isEmpty && structs.isEmpty && protocols.isEmpty
608+
}
605609
}
606610

607611
// MARK: - Imported Skeleton

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/CrossFileSkipsEmptyImportedFiles.json

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,4 @@
11
{
2-
"exported" : {
3-
"classes" : [
4-
5-
],
6-
"enums" : [
7-
8-
],
9-
"exposeToGlobal" : false,
10-
"functions" : [
11-
12-
],
13-
"protocols" : [
14-
15-
],
16-
"structs" : [
17-
18-
]
19-
},
202
"imported" : {
213
"children" : [
224
{

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/GlobalGetter.json

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,4 @@
11
{
2-
"exported" : {
3-
"classes" : [
4-
5-
],
6-
"enums" : [
7-
8-
],
9-
"exposeToGlobal" : false,
10-
"functions" : [
11-
12-
],
13-
"protocols" : [
14-
15-
],
16-
"structs" : [
17-
18-
]
19-
},
202
"imported" : {
213
"children" : [
224
{

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/GlobalThisImports.json

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,4 @@
11
{
2-
"exported" : {
3-
"classes" : [
4-
5-
],
6-
"enums" : [
7-
8-
],
9-
"exposeToGlobal" : false,
10-
"functions" : [
11-
12-
],
13-
"protocols" : [
14-
15-
],
16-
"structs" : [
17-
18-
]
19-
},
202
"imported" : {
213
"children" : [
224
{

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/InvalidPropertyNames.json

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,4 @@
11
{
2-
"exported" : {
3-
"classes" : [
4-
5-
],
6-
"enums" : [
7-
8-
],
9-
"exposeToGlobal" : false,
10-
"functions" : [
11-
12-
],
13-
"protocols" : [
14-
15-
],
16-
"structs" : [
17-
18-
]
19-
},
202
"imported" : {
213
"children" : [
224
{

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/JSClass.json

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,4 @@
11
{
2-
"exported" : {
3-
"classes" : [
4-
5-
],
6-
"enums" : [
7-
8-
],
9-
"exposeToGlobal" : false,
10-
"functions" : [
11-
12-
],
13-
"protocols" : [
14-
15-
],
16-
"structs" : [
17-
18-
]
19-
},
202
"imported" : {
213
"children" : [
224
{

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosureImports.json

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,4 @@
11
{
2-
"exported" : {
3-
"classes" : [
4-
5-
],
6-
"enums" : [
7-
8-
],
9-
"exposeToGlobal" : false,
10-
"functions" : [
11-
12-
],
13-
"protocols" : [
14-
15-
],
16-
"structs" : [
17-
18-
]
19-
},
202
"imported" : {
213
"children" : [
224
{

0 commit comments

Comments
 (0)