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

Generate stand-alone source maps #123

Open
code-later opened this issue Sep 23, 2019 · 3 comments
Open

Generate stand-alone source maps #123

code-later opened this issue Sep 23, 2019 · 3 comments

Comments

@code-later
Copy link

Dear faucet-pipeline team,

while using faucet-pipeline works like a charm and really goes out of your way, I recently stumbled across a feature I would like to see added: Currently there is an option to generate inline source maps. This works great for development but if you use an error tracking service (i.e. Rollbar) the source maps must be provided separately: https://docs.rollbar.com/docs/source-maps.

Thus it would be great to have an option to generate the source maps into dedicated file(s). Of course they must be uploaded as well, but this should not be of any concern to faucet-pipeline I guess.

@FND
Copy link
Contributor

FND commented Sep 23, 2019

Hey Dirk, thanks for providing some context here.

I assume your concern is primarily about JavaScript source maps? Since I don't use (am philosophically opposed to 👴 ) source maps myself, I never fully grokked how our implementation actually works in detail. So I'm not really sure what needs to be done to support stand-alone source maps, but I can (grudgingly 😉 ) try to provide some guidance for anyone interested in implementing this:

Support for source maps was introduced in 61f8576, and it looks like Rollup supports what you want. So I'm guessing it should be possible to extend our implementation by massaging faucet's sourcemaps option - perhaps similar to the way compacting works: cce6245 (--sourcemaps to activate, optional sourcemaps configuration in bundle configuration for customization). HTH.

@code-later
Copy link
Author

Thanks @FND for the feedback and even more the guidance. I'll give it a try and have a look on how to add this to faucet-pipeline.

@FND FND transferred this issue from faucet-pipeline/faucet-pipeline-core Oct 21, 2019
@FND
Copy link
Contributor

FND commented Oct 21, 2019

FWIW, having encountered externalized source maps elsewhere recently, I've realized that it might be simpler than I'd expected: The actual source map's JSON data remains identical AFAICT, the respective file is referenced as //# sourceMappingURL=bundle.js.map from within the bundle - so we'd just need to write the same data to a separate file (${bundle.filepath}.map) and replace the Base64-encoded data URI with this reference.

Having said that, this might require a little bit of re-architecting:

code: map ? `${code}\n${SMPREFIX}${map.toUrl()}\n` : code,

The generateBundle function there (intentionally) doesn't have access to assetManager.writeFile, so we'd probably wanna extend the return value to { code, map, … } to eventually (via BasicBundle and Bundle - yes, this is a little convoluted, because reasons) write a source-map file alongside the actual bundle:
return ({ code, error }) => {

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

No branches or pull requests

2 participants