Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dart:js from dart2wasm #55266

Closed
srujzs opened this issue Mar 21, 2024 · 12 comments · Fixed by dart-lang/crypto#181
Closed

Remove dart:js from dart2wasm #55266

srujzs opened this issue Mar 21, 2024 · 12 comments · Fixed by dart-lang/crypto#181
Labels
area-dart2wasm Issues for the dart2wasm compiler. area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. web-js-interop Issues that impact all js interop

Comments

@srujzs
Copy link
Contributor

srujzs commented Mar 21, 2024

This library was added to support allowInterop. All of the methods throw and importing dart:js returns a static error. However, doing conditional imports e.g. if (dart.library.js) succeeds in dart2wasm, because the library still exists in libraries.json. Since allowInterop is now no longer defined in dart:js, we should just remove this library altogether from the platform.

@srujzs srujzs added web-js-interop Issues that impact all js interop area-dart2wasm Issues for the dart2wasm compiler. labels Mar 21, 2024
@mkustermann
Copy link
Member

/cc @osa1 Could we disallow importing dart:js just like we (after cl/368343) disallow importing dart:ffi (until we remove dart:js entirely)?

@srujzs
Copy link
Contributor Author

srujzs commented May 29, 2024

There's already a static error we've added to disallow importing dart:js in dart2wasm:

if (_disallowedInteropLibrariesInDart2Wasm

@srujzs srujzs added the area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. label May 29, 2024
osa1 added a commit to osa1/sdk that referenced this issue May 30, 2024
@osa1
Copy link
Member

osa1 commented May 30, 2024

Do we need to make any changes in Flutter for this? I've created an SDK CL to remove dart:js from the platform: https://dart-review.googlesource.com/c/sdk/+/368642.

@mkustermann
Copy link
Member

Do we need to make any changes in Flutter for this? I've created an SDK CL to remove dart:js from the platform: https://dart-review.googlesource.com/c/sdk/+/368642.

Maybe this issue also includes dart:js_util (which we currently use internally in the implementation of dart:js_interop)

@srujzs
Copy link
Contributor Author

srujzs commented May 30, 2024

I don't think Flutter uses dart:js anywhere. I'm not sure why your CL results in package:js complaining about exporting dart:_js_annotations now. That should be tangential but I'll have to take a deeper look.

Maybe this issue also includes dart:js_util (which we currently use internally in the implementation of dart:js_interop)

There are a few migrations that need to happen in Flutter and elsewhere (as well as migrating our own implementation of dart:js_interop like you note) before package:js and dart:js_util can be removed from dart2wasm. I'd expect it to be harder than removing dart:js.

kevmoo added a commit to dart-lang/crypto that referenced this issue Aug 14, 2024
Preparing to publish 3.0.5

Revert "Switch sha512 to use fastpath with wasm (#165)"

This reverts commit 69d13c9.
@sigmundch
Copy link
Member

FYI - we run again into this issue. I've created https://dart-review.googlesource.com/c/sdk/+/380583 to attempt again. It's very similar to the change @osa1 created a while back, but I reduced the scope a bit to see if we can make it easier to land.

Do you recall @osa1 what issues you ran into (aside from the bot failures that the CL shows?)

Alternatively, we could use the "supports: false" line in the libraries.json to start incrementally (I'll prepare a change to do so for dart:js_util, since we still have cases where we load code from it).

@osa1
Copy link
Member

osa1 commented Aug 15, 2024

@sigmundch I don't remember what the problem was. I think I was busy with other things and didn't want to spent too much time on this at the time and stopped after seeing the test failures.

@srujzs
Copy link
Contributor Author

srujzs commented Aug 15, 2024

(I'll prepare a change to do so for dart:js_util, since we still have cases where we load code from it)

Just a heads up: we still have allowlisted code (the engine and package:test for example) that imports some members from dart:js_util running in dart2wasm that need to be migrated before we can remove that.

@simolus3
Copy link
Contributor

simolus3 commented Aug 17, 2024

Some Dart programs rely on detecting the compiler in conditional imports (to e.g. switch implementations depending on whether we have 64bit ints).
Dropping dart:js support from dart2wasm gives us a way to uniquely identify DDC and dart2js by checking for dart.library.js, which is great.

However, the 3.5 release announcement also described plans to eventually discontinue all of the legacy SDK web bindings (including dart:js) in favor of package:web and dart:js_interop. I'm worried that this will bring back the problem of not being able to identify dart2wasm in conditional imports - will this be considered or is there a proper way to set up conditional imports now that avoids this future problem?

@mkustermann
Copy link
Member

Some Dart programs rely on detecting the compiler in conditional imports (to e.g. switch implementations depending on whether we have 64bit ints).
Dropping dart:js support from dart2wasm gives us a way to uniquely identify DDC and dart2js by checking for dart.library.js, which is great.

However, the 3.5 release announcement also described plans to eventually discontinue all of the legacy SDK web bindings (including dart:js) in favor of package:web and dart:js_interop. I'm worried that this will bring back the problem of not being able to identify dart2wasm in conditional imports - will this be considered or is there a proper way to set up conditional imports now that avoids this future problem?

/cc @dart-lang/language-team Maybe it's time to allow more than dart.library.* in conditional imports ( #54785)?

auto-submit bot pushed a commit to flutter/cocoon that referenced this issue Aug 19, 2024
Bumps [crypto](https://github.com/dart-lang/crypto) from 3.0.3 to 3.0.5.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/dart-lang/crypto/releases">crypto's releases</a>.</em></p>
<blockquote>
<h2>package:crypto v3.0.5</h2>
<ul>
<li>Revert switch to enable fast &quot;sinks&quot; on Wasm because it breaks <code>dart2js</code> with
server mode.</li>
</ul>
<h2>package:crypto v3.0.4</h2>
<ul>
<li>Fix WebAssembly support.</li>
<li>Require Dart 3.4</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/dart-lang/crypto/blob/master/CHANGELOG.md">crypto's changelog</a>.</em></p>
<blockquote>
<h2>3.0.5</h2>
<ul>
<li>Revert switch to enable fast &quot;sinks&quot; on Wasm because it breaks <code>dart2js</code> with
server mode.</li>
</ul>
<h2>3.0.4</h2>
<ul>
<li>Fix WebAssembly support.</li>
<li>Require Dart 3.4</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/dart-lang/crypto/commit/eede7d6918c51159c1422b7449f40dbac660ee57"><code>eede7d6</code></a> Revert wasm using fast path due to dart-lang/sdk/issues/55266 (<a href="https://redirect.github.com/dart-lang/crypto/issues/181">#181</a>)</li>
<li><a href="https://github.com/dart-lang/crypto/commit/32001667aada397d96f4e8924adcddc6417c43e5"><code>3200166</code></a> Prepare to release v3.0.4 (<a href="https://redirect.github.com/dart-lang/crypto/issues/178">#178</a>)</li>
<li><a href="https://github.com/dart-lang/crypto/commit/1216790ba704a0ab194f9cd0da2d65e1767f3342"><code>1216790</code></a> Bump the github-actions group with 2 updates (<a href="https://redirect.github.com/dart-lang/crypto/issues/175">#175</a>)</li>
<li><a href="https://github.com/dart-lang/crypto/commit/813e35e913d12e16de67ac57523cd0ff4b07c012"><code>813e35e</code></a> Update min SDK, test wasm on 3.4 (<a href="https://redirect.github.com/dart-lang/crypto/issues/174">#174</a>)</li>
<li><a href="https://github.com/dart-lang/crypto/commit/7a9428a78962783f6081dc42465ed580cff225ca"><code>7a9428a</code></a> Bump lints dep (<a href="https://redirect.github.com/dart-lang/crypto/issues/172">#172</a>)</li>
<li><a href="https://github.com/dart-lang/crypto/commit/0a10171a7983cd84b318edf3086f751542500a13"><code>0a10171</code></a> Bump actions/checkout from 4.1.4 to 4.1.6 in the github-actions group (<a href="https://redirect.github.com/dart-lang/crypto/issues/171">#171</a>)</li>
<li><a href="https://github.com/dart-lang/crypto/commit/3f815aca8ad5020bb39be09ec9bfd75c36910809"><code>3f815ac</code></a> blast_repo fixes (<a href="https://redirect.github.com/dart-lang/crypto/issues/170">#170</a>)</li>
<li><a href="https://github.com/dart-lang/crypto/commit/fc5e7c8c1ffeaae7ab7e4aceef96235834060e3c"><code>fc5e7c8</code></a> Bump actions/checkout from 4.1.2 to 4.1.4 (<a href="https://redirect.github.com/dart-lang/crypto/issues/169">#169</a>)</li>
<li><a href="https://github.com/dart-lang/crypto/commit/28290623648058619aba8cd401f3b21adcf853d7"><code>2829062</code></a> Bump dart-lang/setup-dart from 1.6.2 to 1.6.4 (<a href="https://redirect.github.com/dart-lang/crypto/issues/168">#168</a>)</li>
<li><a href="https://github.com/dart-lang/crypto/commit/1c7fbadd92a44322ee1e89eec9747a24dc6c6746"><code>1c7fbad</code></a> Bump actions/checkout from 4.1.1 to 4.1.2 (<a href="https://redirect.github.com/dart-lang/crypto/issues/166">#166</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/dart-lang/crypto/compare/3.0.3...v3.0.5">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=crypto&package-manager=pub&previous-version=3.0.3&new-version=3.0.5)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

</details>
auto-submit bot pushed a commit to flutter/cocoon that referenced this issue Aug 19, 2024
Bumps [crypto](https://github.com/dart-lang/crypto) from 3.0.3 to 3.0.5.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/dart-lang/crypto/releases">crypto's releases</a>.</em></p>
<blockquote>
<h2>package:crypto v3.0.5</h2>
<ul>
<li>Revert switch to enable fast &quot;sinks&quot; on Wasm because it breaks <code>dart2js</code> with
server mode.</li>
</ul>
<h2>package:crypto v3.0.4</h2>
<ul>
<li>Fix WebAssembly support.</li>
<li>Require Dart 3.4</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/dart-lang/crypto/blob/master/CHANGELOG.md">crypto's changelog</a>.</em></p>
<blockquote>
<h2>3.0.5</h2>
<ul>
<li>Revert switch to enable fast &quot;sinks&quot; on Wasm because it breaks <code>dart2js</code> with
server mode.</li>
</ul>
<h2>3.0.4</h2>
<ul>
<li>Fix WebAssembly support.</li>
<li>Require Dart 3.4</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/dart-lang/crypto/commit/eede7d6918c51159c1422b7449f40dbac660ee57"><code>eede7d6</code></a> Revert wasm using fast path due to dart-lang/sdk/issues/55266 (<a href="https://redirect.github.com/dart-lang/crypto/issues/181">#181</a>)</li>
<li><a href="https://github.com/dart-lang/crypto/commit/32001667aada397d96f4e8924adcddc6417c43e5"><code>3200166</code></a> Prepare to release v3.0.4 (<a href="https://redirect.github.com/dart-lang/crypto/issues/178">#178</a>)</li>
<li><a href="https://github.com/dart-lang/crypto/commit/1216790ba704a0ab194f9cd0da2d65e1767f3342"><code>1216790</code></a> Bump the github-actions group with 2 updates (<a href="https://redirect.github.com/dart-lang/crypto/issues/175">#175</a>)</li>
<li><a href="https://github.com/dart-lang/crypto/commit/813e35e913d12e16de67ac57523cd0ff4b07c012"><code>813e35e</code></a> Update min SDK, test wasm on 3.4 (<a href="https://redirect.github.com/dart-lang/crypto/issues/174">#174</a>)</li>
<li><a href="https://github.com/dart-lang/crypto/commit/7a9428a78962783f6081dc42465ed580cff225ca"><code>7a9428a</code></a> Bump lints dep (<a href="https://redirect.github.com/dart-lang/crypto/issues/172">#172</a>)</li>
<li><a href="https://github.com/dart-lang/crypto/commit/0a10171a7983cd84b318edf3086f751542500a13"><code>0a10171</code></a> Bump actions/checkout from 4.1.4 to 4.1.6 in the github-actions group (<a href="https://redirect.github.com/dart-lang/crypto/issues/171">#171</a>)</li>
<li><a href="https://github.com/dart-lang/crypto/commit/3f815aca8ad5020bb39be09ec9bfd75c36910809"><code>3f815ac</code></a> blast_repo fixes (<a href="https://redirect.github.com/dart-lang/crypto/issues/170">#170</a>)</li>
<li><a href="https://github.com/dart-lang/crypto/commit/fc5e7c8c1ffeaae7ab7e4aceef96235834060e3c"><code>fc5e7c8</code></a> Bump actions/checkout from 4.1.2 to 4.1.4 (<a href="https://redirect.github.com/dart-lang/crypto/issues/169">#169</a>)</li>
<li><a href="https://github.com/dart-lang/crypto/commit/28290623648058619aba8cd401f3b21adcf853d7"><code>2829062</code></a> Bump dart-lang/setup-dart from 1.6.2 to 1.6.4 (<a href="https://redirect.github.com/dart-lang/crypto/issues/168">#168</a>)</li>
<li><a href="https://github.com/dart-lang/crypto/commit/1c7fbadd92a44322ee1e89eec9747a24dc6c6746"><code>1c7fbad</code></a> Bump actions/checkout from 4.1.1 to 4.1.2 (<a href="https://redirect.github.com/dart-lang/crypto/issues/166">#166</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/dart-lang/crypto/compare/3.0.3...v3.0.5">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=crypto&package-manager=pub&previous-version=3.0.3&new-version=3.0.5)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

</details>
@sigmundch
Copy link
Member

Good observation @simolus3, indeed!

@mkustermann - I agree, I made a similar suggestion in dart-lang/crypto#180 (comment) 😄 - We need to start using tests that directly correspond to what developers want to know. For example, if you want to condition on a platform, then use a variable that describes the platform, like dart.tool.dart2wasm, rather than an indirect observation, like whether a library is available.

copybara-service bot pushed a commit that referenced this issue Aug 19, 2024
Changes:
```
> git log --format="%C(auto) %h %s" 1216790..eede7d6
 https://dart.googlesource.com/crypto.git/+/eede7d6 Revert wasm using fast path due to /issues/55266 (181)
 https://dart.googlesource.com/crypto.git/+/3200166 Prepare to release v3.0.4 (178)

```

Diff: https://dart.googlesource.com/crypto.git/+/1216790ba704a0ab194f9cd0da2d65e1767f3342..eede7d6918c51159c1422b7449f40dbac660ee57/
Change-Id: I9e13bd707604831ca18aeb618d45c619b398a39f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381303
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
@natebosch
Copy link
Member

IIRC the bazel support is implemented as a fixed list of platforms and what variables they correspond to, so adding variables like dart.tool.dart2wasm might be aligned. Whatever we do with configurable imports we should plan to get input about the bazel implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-dart2wasm Issues for the dart2wasm compiler. area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. web-js-interop Issues that impact all js interop
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

7 participants