Skip to content
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

Option sourcemap: 'inline' not working #495

Closed
fox1t opened this issue Dec 14, 2021 · 4 comments
Closed

Option sourcemap: 'inline' not working #495

fox1t opened this issue Dec 14, 2021 · 4 comments
Labels

Comments

@fox1t
Copy link

fox1t commented Dec 14, 2021

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

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@egoist
Copy link
Owner

egoist commented Dec 14, 2021

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

@fox1t
Copy link
Author

fox1t commented Dec 14, 2021

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

  • entry is mapped to tsConfig.fileNames
  • outDir is tsConfig.outDir
  • sourcemap: is either tsConfig.sourcemap or tsConfig.inlineSourceMap
  • target is tsConfig.compilerOptions.target

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

@egoist
Copy link
Owner

egoist commented Dec 14, 2021

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

tsup/src/plugin.ts

Lines 160 to 174 in d428ce7

await outputFile(
info.path,
info.type === 'chunk'
? info.code + getSourcemapComment(!!info.map, info.path, isCSS(file.path))
: info.contents,
{ mode: info.type === 'chunk' ? info.mode : undefined }
)
if (info.type === 'chunk' && info.map) {
const map =
typeof info.map === 'string' ? JSON.parse(info.map) : info.map
// map.sources = map.sources?.map((name: string) =>
// path.relative(path.dirname(info.path), name)
// )
await outputFile(`${info.path}.map`, JSON.stringify(map))
}
, currently we perform some extra operations on the sourcemap output by esbuild and manually write it to disk

@egoist egoist closed this as completed in 0826b35 Dec 15, 2021
@github-actions
Copy link

🎉 This issue has been resolved in version 5.11.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

2 participants