-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed as duplicate of#1745
Labels
Description
When an input file has a sourcemap with a http:
URL in the "sources"
section, esbuild mangles it.
index.js
import "./foo/index.js";
foo/index.js
// index.js
throw new Error();
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiaHR0cHM6Ly9leGFtcGxlLmNvbS9pbmRleC5qcyJdLAogICJzb3VyY2VzQ29udGVudCI6IFsidGhyb3cgbmV3IEVycm9yKCk7Il0sCiAgIm1hcHBpbmdzIjogIjtBQUFBLE1BQU0sSUFBSTsiLAogICJuYW1lcyI6IFtdCn0K
The source map of the above file looks like this:
{
"version": 3,
"sources": ["https://example.com/index.js"],
"sourcesContent": ["throw new Error();"],
"mappings": ";AAAA,MAAM,IAAI;",
"names": []
}
Then run:
esbuild --bundle --format=esm --sourcemap=inline index.js > index.dist.js
This generates the following file:
// foo/index.js
throw new Error();
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiZm9vL2h0dHBzOi9leGFtcGxlLmNvbS9pbmRleC5qcyJdLAogICJzb3VyY2VzQ29udGVudCI6IFsidGhyb3cgbmV3IEVycm9yKCk7Il0sCiAgIm1hcHBpbmdzIjogIjtBQUFBLE1BQU0sSUFBSSxNQUFBOyIsCiAgIm5hbWVzIjogW10KfQo=
This contains the following source map:
{
"version": 3,
"sources": ["foo/https:/example.com/index.js"],
"sourcesContent": ["throw new Error();"],
"mappings": ";AAAA,MAAM,IAAI,MAAA;",
"names": []
}
You can see that the sources URL here is foo/https:/example.com/index.js
even though it should be https://example.com/index.js
.
Possibly related #1745