docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a tool that processes CSS Modules files and determines the correct import order based on their dependencies. The tool should analyze CSS files containing composes declarations and output the files in an order that respects their dependency relationships.
CSS Modules use composes to inherit styles from other classes. When classes compose from external files, those files must be loaded in the correct order. Your task is to build a system that:
Your tool will receive a list of CSS file paths and their contents. Each CSS file may contain composes declarations like:
.button {
composes: base from "./theme.css";
color: blue;
}This indicates that the current file depends on theme.css and therefore theme.css must be loaded first.
Your tool should output:
/**
* Analyzes CSS module files and determines the correct load order
*
* @param {Object} files - Map of file paths to CSS content
* @returns {Array<string>} - Ordered list of file paths
* @throws {Error} - If circular dependencies are detected
*/
function sortModulesByDependency(files) {
// IMPLEMENTATION HERE
}
module.exports = { sortModulesByDependency };A PostCSS plugin that processes CSS Modules and manages dependency graphs for import ordering.