Skip to content

file: URL separator deduplication API #552

@guybedford

Description

@guybedford

I would like to propose that file URLs include separator deduplication in the spec as a rule to match the file system identifiers themselves more closely.

The reason for this is that Node.js, Deno, and other platforms, build tools and tooling use file: URLs as their key in the module registry when loading ES modules. Whenever there are duplicate separators, this causes a double entry in the registry which can lead to duplicate module execution and a lack of code sharing.

These platforms and build tools are now the primary consumers of file: URLs since browsers no longer encourage the use case at all, therefore it is important that this spec can aim to meet their needs as primary consumers of this aspect of the spec going forward.

URL resolution already converts \ into /. This leaves only casing, percent encoding, query parameters and hashes as the comprehensive list of remaining non-unique components of the file URL representation's associated path representation.

I understand the main consideration for such a change is considering the potentially major change in browsers, but perhaps it would not be so difficult since browsers so carefully discourage file URLs and the issue is rather that until now there hasn't been pressure on this use case from these new file modules platform directions.

This would smooth a number of environment bugs that otherwise need custom code to handle.

In Node.js we effectively add this renormalization step to all module resolution usage of file URLs. Other cases of fileURL resolution would benefit.

References:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions