-
Notifications
You must be signed in to change notification settings - Fork 34
Description
There are certain situations where the user might prefer to completely inline their sourcemap rather than store it in an external file. For example, there's a longstanding Chrome bug where it can't load sourcemaps from the chrome-extension:// protocol, so you're forced to inline.
I made a proof of concept showing how this lib could add inline support via source-map.js:
// add this for inline support
if (this.someNewSwitch) {
const dataUrlPrelude = 'data:application/json;charset=utf-8;base64,';
const base64Content = Buffer.from(JSON.stringify(sourceMap.content)).toString('base64');
sourceMap.mapURL = `${dataUrlPrelude}${base64Content}`;
}
// right before this existing code
if (sourceMap.mapCommentType === 'line') {
stream.write('//# sourceMappingURL=' + sourceMap.mapURL + '\n');
} else {
stream.write('/*# sourceMappingURL=' + sourceMap.mapURL + ' */\n');
}Would this lib be open to an improvement like this? I'm not sure what the option switch(es) should be to toggle the behavior.
Also I'm unclear if this lib is meant to be standalone or if it's a microlib for ember-cli only. If the latter, what would it take to make this functionality controllable from ember-cli-build.js? They already support babel: { sourceMaps: 'inline' } but the intent isn't to do this, or it'd already be doing it. So it needs a new switch, with a different name to not interfere with existing use cases.