Cache babel source map.

When source is already cached and you reload,
the source map is lost which makes debugging
async functions difficult.
This commit is contained in:
Brendan Dahl 2021-04-09 10:34:15 -07:00
parent 6429ccc002
commit a31d142253

View File

@ -43,7 +43,7 @@ function getDb() {
return dbPromise;
}
function storeCache(address, hashCode, translated, format) {
function storeCache(address, hashCode, translated, format, sourceMap) {
return getDb().then(function (db) {
var tx = db.transaction(dbCacheTable, "readwrite");
var store = tx.objectStore(dbCacheTable);
@ -53,6 +53,7 @@ function storeCache(address, hashCode, translated, format) {
translated,
expires: Date.now() + cacheExpiration,
format,
sourceMap,
});
return new Promise(function (resolve, reject) {
tx.oncomplete = function () {
@ -80,6 +81,7 @@ function loadCache(address, hashCode) {
? {
translated: found.translated,
format: found.format,
sourceMap: found.sourceMap,
}
: null
);
@ -127,7 +129,8 @@ exports.translate = function (load, opt) {
load.address,
savedHashCode,
translated,
load.metadata.format
load.metadata.format,
load.metadata.sourceMap
).then(function () {
return translated;
});