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

fix(esbuild): sourcemaps in transform result can be a string #377

Merged
merged 2 commits into from Mar 29, 2024

Conversation

snowystinger
Copy link
Contributor

πŸ”— Linked issue

Brought up over here devongovett/unplugin-parcel-macros#4

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

The type cast to any on

map = result.map as any
was hiding a bug where the result could be a string. When it was, you'd get an error such as Cannot create property 'sourcesContent' on string '{"version":3,"sources":["test.js"]

I'm not quite sure how to write a test for this, though, as I'm not entirely sure how this actually occurs other than possibly when passed across languages, ie rust to js. Any pointers are welcome.
I'd thought to change

map: s.generateMap({
by wrapping it in a JSON.stringify, but that didn't work.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@snowystinger snowystinger changed the title Fix esbuild when transform result is a string Fix esbuild sourcemaps when transform result is a string Mar 27, 2024
@antfu antfu changed the title Fix esbuild sourcemaps when transform result is a string fix(esbuild): sourcemaps when transform result is a string Mar 28, 2024
@antfu antfu changed the title fix(esbuild): sourcemaps when transform result is a string fix(esbuild): sourcemaps in transform result can be a string Mar 28, 2024
@antfu antfu merged commit 4382fa2 into unjs:main Mar 29, 2024
10 checks passed
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

Successfully merging this pull request may close these issues.

None yet

2 participants