Skip to content

fix: Functions with @JS were being generated with @_expose(wasm "bjs_someFunctionName") rather than @_expose(wasm, "bjs_someFunctionName")#557

Closed
scottmarchant wants to merge 1 commit intoswiftwasm:mainfrom
PassiveLogic:fix/buildExposeAttributes
Closed

fix: Functions with @JS were being generated with @_expose(wasm "bjs_someFunctionName") rather than @_expose(wasm, "bjs_someFunctionName")#557
scottmarchant wants to merge 1 commit intoswiftwasm:mainfrom
PassiveLogic:fix/buildExposeAttributes

Conversation

@scottmarchant
Copy link
Contributor

Problem summary

A recent BridgeJS change caused generated swift interfacing code to use @_expose(wasm "bjs_someFunctionName"), rather than @_expose(wasm, "bjs_someFunctionName").

This change adds back the command, which is required to compile.

Details

For the following code:

@JS public func load() {}

A recent change caused the following swift code to be generated:

@_spi(BridgeJS) import JavaScriptKit

@_expose(wasm "bjs_load")
@_cdecl("bjs_load")
public func _bjs_load() -> Void {}

This fails to compile with an error like the following:

 8 | @_spi(BridgeJS) import JavaScriptKit
 9 | 
10 | @_expose(wasm "bjs_load")
   |  `- error: expected ')' in '_expose' attribute
11 | @_cdecl("bjs_load")
12 | public func _bjs_load() -> Void {

Instead, the generated code needs to add a comma separator:

@_spi(BridgeJS) import JavaScriptKit

@_expose(wasm, "bjs_load")
@_cdecl("bjs_load")
public func _bjs_load() -> Void {}

…_load")` rather than `@_expose(wasm, "bjs_load")`, which broke compilation for generated code.
@kateinoigakukun
Copy link
Member

Thanks! But closing in favor of #555 🙏

@scottmarchant
Copy link
Contributor Author

Thanks! But closing in favor of #555 🙏

Oh right, I didn't notice that one. Good call, #555 did a great job. Thanks for merging it!

@scottmarchant scottmarchant deleted the fix/buildExposeAttributes branch February 3, 2026 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants