Skip to content

Commit 2da2375

Browse files
parloughCommit Queue
authored and
Commit Queue
committed
[js_runtime/js_dev_runtime] Don't consider running on Windows when compiled for web
This bool is used to check if certain Uri functions should default to Windows behavior on Node. If running on the web, these checks will always be false though, so add a check to enable tree shaking to remove unused Windows functionality. Fixes #54474 Change-Id: I1ef830f7b14af928a16a875d50cf6ab0db727dfc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345100 Reviewed-by: Sigmund Cherem <[email protected]> Reviewed-by: Nate Bosch <[email protected]> Reviewed-by: Mayank Patke <[email protected]> Commit-Queue: Mayank Patke <[email protected]> Auto-Submit: Parker Lougheed <[email protected]>
1 parent aa6b647 commit 2da2375

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart

+2-7
Original file line numberDiff line numberDiff line change
@@ -884,14 +884,9 @@ class Uri {
884884

885885
@patch
886886
class _Uri {
887+
// DDC is only used when targeting the browser, so this is always false.
887888
@patch
888-
static bool get _isWindows => _isWindowsCached;
889-
890-
static final bool _isWindowsCached = JS(
891-
'bool',
892-
'typeof process != "undefined" && '
893-
'Object.prototype.toString.call(process) == "[object process]" && '
894-
'process.platform == "win32"');
889+
static bool get _isWindows => false;
895890

896891
// Matches a String that _uriEncodes to itself regardless of the kind of
897892
// component. This corresponds to [_unreservedTable], i.e. characters that

sdk/lib/_internal/js_runtime/lib/core_patch.dart

+10-5
Original file line numberDiff line numberDiff line change
@@ -822,11 +822,16 @@ class _Uri {
822822
@patch
823823
static bool get _isWindows => _isWindowsCached;
824824

825-
static final bool _isWindowsCached = JS(
826-
'bool',
827-
'typeof process != "undefined" && '
828-
'Object.prototype.toString.call(process) == "[object process]" && '
829-
'process.platform == "win32"');
825+
// Consider the possibility of using Windows behavior if app is
826+
// compiled with `--server-mode` and running on Node or a similar platform.
827+
static final bool _isWindowsCached =
828+
!const bool.fromEnvironment('dart.library.html') &&
829+
JS<bool>(
830+
'bool',
831+
'typeof process != "undefined" && '
832+
'Object.prototype.toString.call(process) == "[object process]" && '
833+
'process.platform == "win32"',
834+
);
830835

831836
// Matches a String that _uriEncodes to itself regardless of the kind of
832837
// component. This corresponds to [_unreservedTable], i.e. characters that

0 commit comments

Comments
 (0)