egoist / tsup

The simplest and fastest way to bundle your TypeScript libraries.
https://tsup.egoist.dev
MIT License
9k stars 217 forks source link

Option `sourcemap: 'inline'` not working #495

Closed fox1t closed 2 years ago

fox1t commented 2 years ago

Hi! As per documentation it should be possible to pass inline as sourcemap option. In reality, passing it is treated the same as passing any other value thanks to this line: https://github.com/egoist/tsup/blob/dev/src/esbuild/index.ts#L134

Moreover, the relative test is wrong too and doesn't catch this error. We can see that it is checking for the presence of at https://github.com/egoist/tsup/blob/dev/test/index.test.ts#L188 instead of the more safe //# sourceMappingURL=data:

I've already had a fix, and I can open a PR, but there is just one last thing that bothers me. esbuild documentation says that external shouldn't add //# sourceMappingURL= at the end of the file, but running this test and checking the output, shows a different story. Any clues?

And this is why the inline test is passing even if the option is not working at the moment.

...
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
//# sourceMappingURL=input.js.map

Upvote & Fund

Fund with Polar

egoist commented 2 years ago

inline sourcemap was removed and the docs should be updated, any specific reason you need inline sourcemap?

fox1t commented 2 years ago

I am developing a custom tsup configuration that takes some paramters that tsup care about directly from the tsconfig.json. In particular:

Should we remove the inline option test too? Out of curiosity, why it was removed?

egoist commented 2 years ago

just did a bit research, there're indeed use cases for inline sourcemap (like developing browser extensions), we should bring it back, but it should be added in https://github.com/egoist/tsup/blob/d428ce7be1341fe7c8d6f745eaa0676f9eeeea89/src/plugin.ts#L160-L174, currently we perform some extra operations on the sourcemap output by esbuild and manually write it to disk

github-actions[bot] commented 2 years ago

:tada: This issue has been resolved in version 5.11.5 :tada:

The release is available on:

Your semantic-release bot :package::rocket: