Skip to content
This repository was archived by the owner on Jul 12, 2024. It is now read-only.

Implement support for the remaining top-level exports. #96

Merged
merged 1 commit into from
Apr 13, 2024

Conversation

sjrd
Copy link
Collaborator

@sjrd sjrd commented Apr 11, 2024

No description provided.

@sjrd sjrd requested a review from tanishiking April 11, 2024 18:17
@sjrd sjrd force-pushed the finish-top-level-exports branch 2 times, most recently from 01593b1 to fc238e1 Compare April 12, 2024 08:22
Copy link
Owner

@tanishiking tanishiking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, it looks good to me 👍

  • One comment on adding code comment on genDelayedTopLevelExport
  • Comment on test-exports.mjs

@@ -987,6 +988,19 @@ class WasmBuilder {
ctx.addExport(exprt)
}

private def genDelayedTopLevelExport(exportedName: String)(implicit ctx: WasmContext): Unit = {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private def genDelayedTopLevelExport(exportedName: String)(implicit ctx: WasmContext): Unit = {
/** Generates a delayed top-level export, that is a global variable that is initially set to a
* null reference and be later assigned a value in start function.
*/
private def genDelayedTopLevelExport(exportedName: String)(implicit ctx: WasmContext): Unit = {

Can you add a little bit of explanation?

@JSExportTopLevel("SimpleObject")
object SimpleObject extends js.Object {
val bar: String = "the bar field"
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to keep Sample.scala and run.mjs as it is.
What do you think about having these JSExportTopLevels in Test scope of sample project like SampleTest.scala and run test-exports.mjs using the ./sample/target/scala-2.12/sample-test-fastopt/main.mjs instead?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can merge this PR with this, and fix it later of course ;)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, you're right. That wasn't a great idea. Using the Test scope doesn't work because it would launch the test bridge as part of its start function, and we don't want that either.

I instead added a bit more infrastructure in tests/test so that we can test the resulting module exports of a test in test-suite. Is that better?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I instead added a bit more infrastructure in tests/test so that we can test the resulting module exports of a test in test-suite. Is that better?

Yeah, this is awesome, thanks!

@sjrd sjrd force-pushed the finish-top-level-exports branch from fc238e1 to 42137f1 Compare April 12, 2024 08:57
@sjrd sjrd requested a review from tanishiking April 12, 2024 09:04
@tanishiking tanishiking merged commit 0f44ca0 into tanishiking:main Apr 13, 2024
1 check passed
@sjrd sjrd deleted the finish-top-level-exports branch April 13, 2024 05:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants