Closed snowystinger closed 3 months ago
Brought up over here https://github.com/devongovett/unplugin-parcel-macros/issues/4
The type cast to any on https://github.com/unjs/unplugin/blob/867b71d8f52a6fe8b32b0de801cdf3351da6ff79/src/esbuild/index.ts#L288 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"]
type
any
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 https://github.com/unjs/unplugin/blob/867b71d8f52a6fe8b32b0de801cdf3351da6ff79/test/fixtures/transform/unplugin.js#L35 by wrapping it in a JSON.stringify, but that didn't work.
π Linked issue
Brought up over here https://github.com/devongovett/unplugin-parcel-macros/issues/4
β Type of change
π Description
The
type
cast toany
on https://github.com/unjs/unplugin/blob/867b71d8f52a6fe8b32b0de801cdf3351da6ff79/src/esbuild/index.ts#L288 was hiding a bug where the result could be a string. When it was, you'd get an error such asCannot 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 https://github.com/unjs/unplugin/blob/867b71d8f52a6fe8b32b0de801cdf3351da6ff79/test/fixtures/transform/unplugin.js#L35 by wrapping it in a JSON.stringify, but that didn't work.
π Checklist