@modular-css/processor
Advanced tools
Comparing version 29.0.1 to 29.0.2
{ | ||
"name": "@modular-css/processor", | ||
"version": "29.0.1", | ||
"version": "29.0.2", | ||
"description": "A streamlined reinterpretation of CSS Modules", | ||
@@ -5,0 +5,0 @@ "main": "./processor.js", |
@@ -36,3 +36,2 @@ "use strict"; | ||
FILE_PREFIX, | ||
SELECTOR_PREFIX, | ||
} = keys; | ||
@@ -242,4 +241,4 @@ | ||
// Mark all selectors in the file invalid | ||
filterByPrefix(SELECTOR_PREFIX, this._graph.dependenciesOf(key), { clean : false }).forEach((sKey) => { | ||
const data = this._graph.getNodeData(sKey); | ||
this._graph.dependenciesOf(key).forEach((dep) => { | ||
const data = this._graph.getNodeData(dep); | ||
@@ -252,2 +251,4 @@ if(data.file !== normalized) { | ||
}); | ||
this._log("invalidate()", normalized); | ||
} | ||
@@ -268,5 +269,19 @@ | ||
const dependencies = this._graph.dependenciesOf(key); | ||
return filterByPrefix(FILE_PREFIX, this._graph.dependenciesOf(key)); | ||
} | ||
return filterByPrefix(FILE_PREFIX, dependencies); | ||
// Get the file dependents for a specific file | ||
fileDependents(file) { | ||
if(!file) { | ||
throw new Error("fileDepenendents() must be called with a file"); | ||
} | ||
const normalized = this._normalize(file); | ||
const key = fileKey(normalized); | ||
if(!this._graph.hasNode(key)) { | ||
throw new Error(`Unknown file: ${normalized}`); | ||
} | ||
return filterByPrefix(FILE_PREFIX, this._graph.dependantsOf(key)); | ||
} | ||
@@ -503,11 +518,2 @@ | ||
// Add selector and its dependencies to the graph | ||
const selectorId = selectorKey(name, selector); | ||
// Remove any existing dependencies for the selector if it is invalid | ||
if(graph.hasNode(selectorId) && !graph.getNodeData(selectorId).valid) { | ||
graph.dependenciesOf(selectorId).forEach((other) => { | ||
graph.removeDependency(selectorId, other); | ||
}); | ||
} | ||
this._addSelector(name, selector); | ||
@@ -605,4 +611,20 @@ | ||
const fKey = this._addFile(name); | ||
const fKey = fileKey(name); | ||
// Clean up old graph dependencies for this node since it's about to be parsed | ||
// and they'll all be recreated anyways | ||
if(graph.hasNode(fKey)) { | ||
graph.directDependenciesOf(fKey).forEach((dep) => { | ||
const data = this._graph.getNodeData(dep); | ||
if(data.file !== name) { | ||
return; | ||
} | ||
graph.directDependenciesOf(dep).forEach((dep2) => graph.removeDependency(dep, dep2)); | ||
}); | ||
} | ||
this._addFile(name); | ||
this._log("_before()", name); | ||
@@ -609,0 +631,0 @@ |
165856
5039