Skip to content

The sources field in the sourcemap seems invalid #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
darrachequesne opened this issue Jan 3, 2022 · 5 comments
Closed

The sources field in the sourcemap seems invalid #32

darrachequesne opened this issue Jan 3, 2022 · 5 comments

Comments

@darrachequesne
Copy link

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

@kaaax0815
Copy link

kaaax0815 commented Jan 6, 2022

+1 This is extremely important
But the does the Source FIle even make sense, because index.ts is not included anyways

@darrachequesne
Copy link
Author

darrachequesne commented Jan 16, 2022

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).

darrachequesne added a commit to socketio/base64-arraybuffer that referenced this issue Jan 17, 2022
This commit contains two changes:

- the `src/index.ts` file is now included in the published package
- the path in the sourcemap files is now valid

Interestingly, the path is already valid in the `dist/lib/index.js.map`
file, due to the additional `lib/` directory.

Related: niklasvh#32
darrachequesne added a commit to socketio/engine.io-parser that referenced this issue Jan 17, 2022
@darrachequesne
Copy link
Author

If anyone is interested, we went ahead and forked the project: https://github.com/socketio/base64-arraybuffer

It is published as @socket.io/[email protected], included in [email protected] (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!

@niklasvh
Copy link
Owner

Sorry for the delay. This has been fixed in 1.0.2

@darrachequesne
Copy link
Author

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 [email protected]:

Screenshot from 2022-01-23 07-39-11

With @socket.io/[email protected]:

Screenshot from 2022-01-23 07-41-45

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants