st-bundle
Version:
CLI for watching and bundling SpringType projects.
33 lines (32 loc) • 1.07 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* This module is used to store "weak" references for non-js modules
* For example a scss file can have multiple import, none of those imports actually belong to the project
* hence won't be matched by the wather. In order to solve this sutation we map those references to corresponding modules
*/
class WeakModuleReferences {
constructor(ctx) {
this.ctx = ctx;
this.collection = {};
}
add(absPath, filePath) {
if (!this.collection[absPath]) {
this.collection[absPath] = [];
}
if (this.collection[absPath].indexOf(filePath) === -1) {
this.collection[absPath].push(filePath);
}
}
flush() {
this.collection = {};
}
find(absPath) {
return this.collection[absPath];
}
}
exports.WeakModuleReferences = WeakModuleReferences;
function createWeakModuleReferences(ctx) {
return new WeakModuleReferences(ctx);
}
exports.createWeakModuleReferences = createWeakModuleReferences;