Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Add Wasm support #177

Closed
wants to merge 2 commits into from
Closed

Add Wasm support #177

wants to merge 2 commits into from

Conversation

h1376h
Copy link

@h1376h h1376h commented Aug 12, 2024

Since dart:html is not supported when compiling to Wasm, the correct alternative now is to use dart.library.js_interop to differentiate between native and web

Source:
https://dart.dev/interop/js-interop/package-web

  • Thanks for your contribution! Please replace this text with a description of what this PR is changing or adding and why, list any relevant issues, and review the contribution guidelines below.

  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.

h1376h and others added 2 commits August 12, 2024 17:39
Since dart:html is not supported when compiling to Wasm, the correct alternative now is to use dart.library.js_interop to differentiate between native and web

Source:
https://dart.dev/interop/js-interop/package-web
@kevmoo
Copy link
Contributor

kevmoo commented Aug 12, 2024

Actually, this is by design!

We can use the fast sinks in wasm because it has full 64bit numbers, unlike JS.

@kevmoo kevmoo closed this Aug 12, 2024
@kevmoo
Copy link
Contributor

kevmoo commented Aug 13, 2024

We should probably add a comment here to clarify!

@kevmoo
Copy link
Contributor

kevmoo commented Aug 13, 2024

Right @lrhn ?

@h1376h
Copy link
Author

h1376h commented Aug 13, 2024

Actually, this is by design!

We can use the fast sinks in wasm because it has full 64bit numbers, unlike JS.

The latest version of this package in pub.dev has wrong conditional imports, you fixed it 5 months ago with a PR #165 (by checking dart.library.html instead of dart.library.js so Wasm builds could use fast sinks).

import 'library_html_false.dart'
    if (dart.library.html) 'library_html_true.dart';
import 'library_js_false.dart' if (dart.library.js) 'library_js_true.dart';
import 'library_js_interop_false.dart'
    if (dart.library.js_interop) 'library_js_interop_true.dart';

In Wasm builds, library_html_false, library_js_interop_true and library_js_true would be chosed, so the current latest version on pub.dev is using the 32Bit implementation (slow sinks) on Wasm.

TLDR;
The package needs to be updated so it could have your fix from 5 months ago!

@kevmoo
Copy link
Contributor

kevmoo commented Aug 13, 2024

@h1376h – meaning you'd like me to publish?

@h1376h
Copy link
Author

h1376h commented Aug 13, 2024

@h1376h – meaning you'd like me to publish?

If fast sinks are faster than slow sinks, yeah! It would be great if that change could be published. Am currently testing both on Wasm to check the benchmarks.

@h1376h
Copy link
Author

h1376h commented Aug 13, 2024

dart-lang/core#250 Found some issues when testing fast sinks on Wasm

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants