Make sure sourcemap callback works having to clean cache

Note that the reason for passing a JSON string rather than an object
reference is that Rollup mutates the object, leading to unpredictable
behaviour.
This commit is contained in:
Lukas Rieder 2018-03-26 13:07:52 +02:00
parent 52593d203b
commit ffb2c0d835
5 changed files with 1183 additions and 1024 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -216,13 +216,9 @@ export default function typescript(options?: Partial<IOptions>)
const map = _.find(output.outputFiles, (entry) => _.endsWith(entry.name, ".map"));
const dts = _.find(output.outputFiles, (entry) => _.endsWith(entry.name, ".d.ts"));
if (pluginOptions.sourceMapCallback && map) {
pluginOptions.sourceMapCallback(id, map.text);
}
return {
code: transpiled ? transpiled.text : undefined,
map: map ? JSON.parse(map.text) : { mappings: "" },
map: map ? map.text : undefined,
dts,
};
});
@ -254,6 +250,13 @@ export default function typescript(options?: Partial<IOptions>)
result.dts = undefined;
}
if (result && result.map) {
if (pluginOptions.sourceMapCallback) {
pluginOptions.sourceMapCallback(id, result.map);
}
result.map = JSON.parse(result.map);
}
return result;
},