Skip to content

Open up Input for custom extensions. - #34

Merged
sjrd merged 1 commit into
scala-js:mainfrom
sjrd:open-input
May 2, 2026
Merged

Open up Input for custom extensions.#34
sjrd merged 1 commit into
scala-js:mainfrom
sjrd:open-input

Conversation

@sjrd

@sjrd sjrd commented Apr 22, 2026

Copy link
Copy Markdown
Member

It was always meant to be extended in the future. The constructor was private, though, which prevent third-parties from extending it. There is no real reason to prevent that, so we actually open it up.

We explicitly validate that JSEnvs throw an
UnsupportedInputException for Inputs that they cannot handle, with a new test in the test kit. They were already supposed to do that, but we could not test it before because the tests themselves could not create an unknown Input.


/cc @tanishiking

With this extension, we will be able to experiment with Wasm inputs in separate repos, until we nail down their semantics for eventual standardization here.

@sjrd
sjrd requested a review from gzm0 April 22, 2026 09:41

@tanishiking tanishiking left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, I could locally confirm we can implement scala-js-env-wasmtime that defines custom final case class WasmComponent(component: Path) extends Input, and use that Input downstream 👍
LGTM from my side.

@gzm0

gzm0 commented May 2, 2026

Copy link
Copy Markdown
Contributor

There is no real reason to prevent that, so we actually open it up.

I can see one reason: Allowing third party libraries to extend Input removes (comprehensive) standardization of input types. However, that is arguably a weak argument. So I think we should go ahead with this.

@gzm0 gzm0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just a simplification in the test.

Comment on lines +190 to +193
if (withCom)
kit.startWithCom(Seq(input))
else
kit.start(Seq(input))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (withCom)
kit.startWithCom(Seq(input))
else
kit.start(Seq(input))
withRun(Seq(input))(identity)

It was always meant to be extended in the future. The constructor
was private, though, which prevent third-parties from extending it.
There is no real reason to prevent that, so we actually open it up.

We explicitly validate that `JSEnv`s throw an
`UnsupportedInputException` for `Input`s that they cannot handle,
with a new test in the test kit. They were already supposed to do
that, but we could not test it before because the tests themselves
could not create an unknown `Input`.
@sjrd
sjrd merged commit c90afeb into scala-js:main May 2, 2026
15 checks passed
@sjrd
sjrd deleted the open-input branch May 2, 2026 15:28
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.

3 participants