Menci / vite-plugin-top-level-await

Transform code to support top-level await in normal browsers for Vite.
MIT License
266 stars 15 forks source link

Generate sourceMappingURL into javascript file #41

Closed kemotx90 closed 3 months ago

kemotx90 commented 10 months ago

this fix configure the auto-generate sourceMappingURL in every build javscript file

34

Menci commented 10 months ago

I think they're not requesting source map of this library, they're requesting source map of the built assets.

kemotx90 commented 9 months ago

with this configuration source map are added during build process

muhammadhafizmm commented 5 months ago

@Menci I guess the problem is here https://github.com/Menci/vite-plugin-top-level-await/blob/800ce00bc65798f1502543abaa5a89e720aa4cd1/src/index.ts#L134-L144 you re-write the code with the transform one and forget to put the sourceMap comment after the code.

the easiest way for this is you can adding this 2 line code in here if we generate the chunk of the code.

const sourceMapPath = file.fileName.split('assets/')[1];
const sourceMapComment = `//# sourceMappingURL=${sourceMapPath}.map`;
file.code += `\n${sourceMapComment}`;
Menci commented 3 months ago

This PR is enabling source map for this plugin's building, not for Vite building with this plugin running. So, it has nothing to do with that issue.

@muhammadhafizmm I don't think the original source map will work with my transpiled source code...