Skip to content

[dart2js] Bundles targeting browser pay cost of Uri Windows handling for Node #54474

@parlough

Description

@parlough

Using any of Uri.directory, Uri.file, and uri.toFilePath without explicitly specifying windows: false every time results in all of the Uri code for handling Windows file paths being included due to special handling added for Node in 5a74d8a. This technically also results in an extra check that will always evaluate to false.

Usages of these constructors and functions are often indirect, such as through other packages, making this quite hard to avoid.

I feel this cost is likely not worth it for handling the node case, and my initial feeling is that it would actually be quite surprising for my Dart compiled to JS to behave differently on Node than in the browser. When I compile to JS (or Wasm) I
personally expect I'm opting in to consistent behavior in respect to my code no matter the platform.

Anyone requiring platform specific Uri file behavior on Node (or any other non-browser JS runtime) should probably explicitly give a value to the windows parameter or use Node's https://nodejs.org/api/url.html#urlpathtofileurlpath and https://nodejs.org/api/url.html#urlfileurltopathurl functions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.web-dart2js

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions