Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 4, 2025

Pull Request

Issue

Closes: #1058

Approach

The identical(0, 0.0) trick for web detection fails on WASM because WASM properly distinguishes integers from doubles (unlike JavaScript where they're unified as Number).

Replace with the standard Dart approach:

// Before
const bool parseIsWeb = identical(0, 0.0);

// After  
const bool parseIsWeb = bool.fromEnvironment('dart.library.js_util');

This works correctly for JavaScript, WASM, and native targets.

Tasks

  • Add tests
  • Add changes to documentation (guides, repository pages, code comments)
Original prompt

This section details on the original issue you should resolve

<issue_title>parseIsWeb doesn't work on WASM</issue_title>
<issue_description>const bool parseIsWeb = identical(0, 0.0);

fails on wasm.

Why not do the normal thing?

I see this code is dart and not flutter. Flutter does it this way which I assume works.

const bool parseIsWeb = bool.fromEnvironment('dart.library.js_util');
</issue_description>

<agent_instructions>Check whether wasm support is already technically possible given the dependencies the dart and flutter packages are using. If possible, implement WASM support. </agent_instructions>

Comments on the Issue (you are @copilot in this section)

@mtrezza @mbfakourii do you understand what is meant here? @mtrezza Got it. So we'd need to wait until all the dependencies support the option before the Parse SDK can support it? @mtrezza Do we **have to** wait until all Parse SDK dependencies support the wasm option? Or is the issue only related to that one single code line that has been mentioned above, and is the solution to change

const bool parseIsWeb = identical(0, 0.0);

to

const bool parseIsWeb = bool.fromEnvironment('dart.library.js_util');

?</comment_new>
<comment_new>@mtrezza
I don't understand your response. Do you mean "Yes we need to wait for all dependency maintainers to support WASM, before we can support WASM?", or "No, we can make changes in our SDK to support WASM without waiting for the dependencies"?</comment_new>
<comment_new>@mtrezza
To clarify, you can submit a PR at any time, but when it can be merged depends on its implications on our compatibility policy.</comment_new>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Dec 4, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 4, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Replace `identical(0, 0.0)` with `bool.fromEnvironment('dart.library.js_util')` for proper web platform detection that works with WASM.

Co-authored-by: mtrezza <[email protected]>
Copilot AI changed the title [WIP] Fix parseIsWeb to work with WASM fix(dart): fix parseIsWeb detection for WASM compatibility Dec 4, 2025
@parse-github-assistant
Copy link

I will reformat the title to use the proper commit message syntax.

@parse-github-assistant parse-github-assistant bot changed the title fix(dart): fix parseIsWeb detection for WASM compatibility fix(dart): Fix parseIsWeb detection for WASM compatibility Dec 4, 2025
Copilot AI requested a review from mtrezza December 4, 2025 07:19
@mtrezza mtrezza changed the title fix(dart): Fix parseIsWeb detection for WASM compatibility fix: Incompatible parseIsWeb detection prevents WASM compatibility Dec 4, 2025
@parse-github-assistant
Copy link

parse-github-assistant bot commented Dec 4, 2025

🚀 Thanks for opening this pull request!

@mtrezza mtrezza changed the title fix: Incompatible parseIsWeb detection prevents WASM compatibility fix: Incompatible parseIsWeb detection prevents WASM support Dec 4, 2025
@mtrezza mtrezza marked this pull request as ready for review December 4, 2025 07:23
@codecov
Copy link

codecov bot commented Dec 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 43.96%. Comparing base (d634b78) to head (9209a61).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1096   +/-   ##
=======================================
  Coverage   43.96%   43.96%           
=======================================
  Files          61       61           
  Lines        3596     3596           
=======================================
  Hits         1581     1581           
  Misses       2015     2015           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mtrezza
Copy link
Member

mtrezza commented Dec 4, 2025

@copilot Do you recommend to extend the CI for testing in WASM?

Copy link
Contributor Author

Copilot AI commented Dec 4, 2025

@copilot Do you recommend to extend the CI for testing in WASM?

Yes, I recommend adding WASM testing to CI, but it can be done as a follow-up.

For the Dart package, you could add a job that compiles to WASM and runs tests using dart compile wasm (available since Dart 3.3). For the Flutter package, you could add flutter test --wasm or flutter build web --wasm to verify WASM compilation.

However, this change is relatively low-risk since bool.fromEnvironment('dart.library.js_util') is a well-established pattern that's been validated in production by Flutter and other major Dart packages. The existing CI (which tests on web via normal compilation) provides reasonable coverage for now.

I'd suggest opening a separate issue to track adding WASM-specific CI jobs when the team is ready to expand platform coverage.

@mtrezza
Copy link
Member

mtrezza commented Dec 4, 2025

@copilot Is there more needed to expand platform coverage to WASM, or would it be enough to simply extend the matrix in ci.yml with a WASM compilation?

Copy link
Contributor Author

Copilot AI commented Dec 4, 2025

@copilot Is there more needed to expand platform coverage to WASM, or would it be enough to simply extend the matrix in ci.yml with a WASM compilation?

For the Flutter package, it would be straightforward - you could add a matrix entry with a wasm: true flag and conditionally run flutter test --wasm instead of flutter test. Flutter's WASM support is mature.

For the Dart package, it's more complex. The current dart test command doesn't have a --wasm flag. You would need to either:

  1. Use dart compile wasm to verify compilation succeeds (compilation check only, not full tests)
  2. Or set up a browser-based test runner with WASM enabled

Given this SDK is primarily used via Flutter (not standalone Dart web apps), extending the Flutter CI matrix with --wasm would provide the most practical coverage. A single Ubuntu job with WASM would be sufficient to catch WASM-specific issues.

@mtrezza
Copy link
Member

mtrezza commented Dec 4, 2025

@copilot then extend the Flutter CI matrix with --wasm

@mtrezza mtrezza merged commit 5b157b8 into master Dec 4, 2025
15 of 16 checks passed
parseplatformorg pushed a commit that referenced this pull request Dec 4, 2025
# [dart-v9.4.5](dart-9.4.4...dart-9.4.5) (2025-12-04)

### Bug Fixes

* Incompatible `parseIsWeb` detection prevents WASM support ([#1096](#1096)) ([5b157b8](5b157b8))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version dart-v9.4.5

@mtrezza
Copy link
Member

mtrezza commented Dec 4, 2025

@copilot Open a new PR to add wasm to the test matrix.

Copilot AI mentioned this pull request Dec 4, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parseIsWeb doesn't work on WASM

3 participants