55 lines
4.0 KiB
JavaScript
55 lines
4.0 KiB
JavaScript
|
"use strict";
|
||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
|
});
|
||
|
};
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
require("typings-global");
|
||
|
let Module = require('module');
|
||
|
const sourceMap = require("source-map-support");
|
||
|
const through2 = require("through2");
|
||
|
sourceMap.install({
|
||
|
retrieveFile: function (path) {
|
||
|
if (cache[path]) {
|
||
|
return cache[path].contents.toString();
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
let cache = {};
|
||
|
let originalLoader = Module._extensions['.js'];
|
||
|
Module._extensions['.js'] = function (module, filename) {
|
||
|
let file = cache[filename];
|
||
|
if (file) {
|
||
|
module._compile(file.contents.toString(), filename);
|
||
|
}
|
||
|
else {
|
||
|
originalLoader.apply(this, arguments);
|
||
|
}
|
||
|
};
|
||
|
let originalModuleResolve = Module._resolveFilename;
|
||
|
Module._resolveFilename = function (request, parent, isMain) {
|
||
|
let file = cache[request];
|
||
|
if (file) {
|
||
|
return request;
|
||
|
}
|
||
|
else {
|
||
|
return originalModuleResolve.apply(this, arguments);
|
||
|
}
|
||
|
};
|
||
|
exports.gulpPipe = function () {
|
||
|
return through2.obj(function (file, enc, cb) {
|
||
|
cache[file.path] = file;
|
||
|
return cb(null, file);
|
||
|
});
|
||
|
};
|
||
|
exports.injectFileArray = (fileArray) => __awaiter(this, void 0, void 0, function* () {
|
||
|
for (let fileObject of fileArray) {
|
||
|
cache[fileObject.path] = fileObject;
|
||
|
}
|
||
|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