The `sources` field in the sourcemap seems invalid
darrachequesne opened this issue · 5 comments
Hi! It seems the sources
field in the sourcemap base64-arraybuffer.es5.js.map
is invalid:
{"version":3,"file":"base64-arraybuffer.es5.js","sources":["../../src/index.ts"],"sourcesContent":[null],"names":[], ...
It should be ../src/index.ts
I think.
node_modules/
└── base64-arraybuffer
├── dist
│ ├── base64-arraybuffer.es5.js
│ ├── base64-arraybuffer.es5.js.map
│ ...
├── package.json
├── README.md
└── rollup.config.ts
Not sure why though.
Related: socketio/socket.io-client#1520
+1 This is extremely important
But the does the Source FIle even make sense, because index.ts
is not included anyways
It seems to be a known issue: rollup/rollup#4248
As a workaround, you can use the sourcemapPathTransform
option in rollup.config.js
:
export default {
input: `src/index.ts`,
output: [
{
file: pkg.main,
name: pkg.name,
format: 'umd',
banner,
sourcemap: true,
sourcemapPathTransform: (sourcePath) => {
return sourcePath.substring('../'.length);
},
},
[...]
}
This produces "sources":["../src/index.ts"]
instead of "sources":["../../src/index.ts"]
.
Update: this does not work, as src/index.ts
is not included in the published package (as noted in the previous comment).
If anyone is interested, we went ahead and forked the project: https://github.com/socketio/base64-arraybuffer
It is published as @socket.io/base64-arraybuffer@1.0.2
, included in engine.io-parser@5.0.3
(and thus in latest socket.io-client
, as it is a transitive dependency).
There are two additional commits:
We will revert back to the original package once the changes are merged here. Thanks!
Sorry for the delay. This has been fixed in 1.0.2
It seems there is still an issue with the sourcemap file in version 1.0.2
. There is no warning anymore (yay 🎉), but it seems the sourcemap isn't properly loaded.
With base64-arraybuffer@1.0.2
:
With @socket.io/base64-arraybuffer@1.0.2
:
It seems the sourcesContent
field is ignored in the sourcemap:
{"version":3,"file":"base64-arraybuffer.es5.js","sources":["../../src/index.ts"],"sourcesContent":["const chars = 'ABCDEFGHIJKLMNOPQR...
Though that may be a bug from the source-map-loader
plugin.