parcel-bundler
Version:
Blazing fast, zero configuration web application bundler
43 lines (30 loc) • 1.15 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
const path = require('path');
const Packager = require('./Packager');
const SourceMap = require('../SourceMap');
class SourceMapPackager extends Packager {
start() {
var _this = this;
return (0, _asyncToGenerator2.default)(function* () {
_this.sourceMap = new SourceMap();
})();
}
addAsset(asset) {
var _this2 = this;
return (0, _asyncToGenerator2.default)(function* () {
yield _this2.sourceMap.addMap(asset.generated.map, _this2.bundle.parentBundle.getOffset(asset));
})();
}
end() {
var _this3 = this,
_superprop_callEnd = (..._args) => super.end(..._args);
return (0, _asyncToGenerator2.default)(function* () {
let file = path.basename(_this3.bundle.name);
yield _this3.write(_this3.sourceMap.stringify(file, path.relative(_this3.options.outDir, _this3.options.rootDir)));
yield _superprop_callEnd();
})();
}
}
module.exports = SourceMapPackager;