Skip to content

Inconsistent Sourcemap sources Behavior with file:// URLs vs. Absolute Paths in v0.25.0 #4075

@alan-agius4

Description

@alan-agius4

Since version 0.25.0, there appears to be inconsistent behavior in how sourcemaps handle sources when using a file:// URL versus an absolute path.

Observed Behavior

  1. With a URL source: The sources array contains URL paths file:///out/src/styles.scss
    {
      "version": 3,
      "sources": ["src/styles.scss"],
      "sourcesContent": ["/* You can add global styles to this file, and also import other style files */\n* {\n  color: red\n}\n"],
      "mappings": "AACA,EACE,MAAA",
      "names": []
    }
  2. With an absolute file path: The source array contains absolute paths /out/src/styles.scss
{
  "version": 3,
  "sources": ["/out/src/styles.scss"],
  "sourcesContent": ["/* You can add global styles to this file, and also import other style files */\n* {\n  color: red\n}\n"],
  "mappings": "AACA,EACE,MAAA",
  "names": []
}

Reproduction: https://esbuild.github.io/try/#YgAwLjI1LjAAewogIG1pbmlmeTogdHJ1ZSwKICBidW5kbGU6IHRydWUsCiAgc291cmNlbWFwOiAiZXh0ZXJuYWwiLAogIG91dGRpcjogIi9vdXQiCn0AZQBzdHlsZXMuY3NzAC8qIFlvdSBjYW4gYWRkIGdsb2JhbCBzdHlsZXMgdG8gdGhpcyBmaWxlLCBhbmQgYWxzbyBpbXBvcnQgb3RoZXIgc3R5bGUgZmlsZXMgKi8KKiB7CiAgY29sb3I6IHJlZDsKfQoKLyojIHNvdXJjZU1hcHBpbmdVUkw9ZGF0YTphcHBsaWNhdGlvbi9qc29uO2NoYXJzZXQ9dXRmLTgsJTdCJTIydmVyc2lvbiUyMjozLCUyMnNvdXJjZVJvb3QlMjI6JTIyJTIyLCUyMnNvdXJjZXMlMjI6JTVCJTIyZmlsZTovLy9vdXQvc3JjL3N0eWxlcy5zY3NzJTIyJTVELCUyMm5hbWVzJTIyOiU1QiU1RCwlMjJtYXBwaW5ncyUyMjolMjJBQUFBO0FBQ0E7RUFDRSUyMiwlMjJmaWxlJTIyOiUyMm91dCUyMiwlMjJzb3VyY2VzQ29udGVudCUyMjolNUIlMjIvKiUyMFlvdSUyMGNhbiUyMGFkZCUyMGdsb2JhbCUyMHN0eWxlcyUyMHRvJTIwdGhpcyUyMGZpbGUsJTIwYW5kJTIwYWxzbyUyMGltcG9ydCUyMG90aGVyJTIwc3R5bGUlMjBmaWxlcyUyMCUyQS8lNUNuKiUyMCU3QiU1Q24lMjAlMjBjb2xvcjolMjByZWQlNUNuJTdEJTVDbiUyMiU1RCU3RCAqLwoAZQBzdHlsZXMyLmNzcwAvKiBZb3UgY2FuIGFkZCBnbG9iYWwgc3R5bGVzIHRvIHRoaXMgZmlsZSwgYW5kIGFsc28gaW1wb3J0IG90aGVyIHN0eWxlIGZpbGVzICovCiogewogIGNvbG9yOiByZWQ7Cn0KCi8qIyBzb3VyY2VNYXBwaW5nVVJMPWRhdGE6YXBwbGljYXRpb24vanNvbjtjaGFyc2V0PXV0Zi04LCU3QiUyMnZlcnNpb24lMjI6MywlMjJzb3VyY2VSb290JTIyOiUyMiUyMiwlMjJzb3VyY2VzJTIyOiU1QiUyMi9vdXQvc3JjL3N0eWxlcy5zY3NzJTIyJTVELCUyMm5hbWVzJTIyOiU1QiU1RCwlMjJtYXBwaW5ncyUyMjolMjJBQUFBO0FBQ0E7RUFDRSUyMiwlMjJmaWxlJTIyOiUyMm91dCUyMiwlMjJzb3VyY2VzQ29udGVudCUyMjolNUIlMjIvKiUyMFlvdSUyMGNhbiUyMGFkZCUyMGdsb2JhbCUyMHN0eWxlcyUyMHRvJTIwdGhpcyUyMGZpbGUsJTIwYW5kJTIwYWxzbyUyMGltcG9ydCUyMG90aGVyJTIwc3R5bGUlMjBmaWxlcyUyMCUyQS8lNUNuKiUyMCU3QiU1Q24lMjAlMjBjb2xvcjolMjByZWQlNUNuJTdEJTVDbiUyMiU1RCU3RCAqLwo

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions