MCPcopy Index your code
hub / github.com/adobe/react-spectrum / removeCircularDeps

Function removeCircularDeps

scripts/extractStarter.mjs:511–536  ·  view source on GitHub ↗

Removes circular dependencies from the CSS, which breaks webpack.

(file, seen = new Set())

Source from the content-addressed store, hash-verified

509
510/** Removes circular dependencies from the CSS, which breaks webpack. */
511function removeCircularDeps(file, seen = new Set()) {
512 let ast = postcss.parse(fs.readFileSync(file, 'utf8'));
513
514 let deps = new Set();
515 let modified = false;
516 ast.walkAtRules('import', rule => {
517 let dep = resolve(dirname(file), rule.params.match(/['"](.*?)['"]/)[1]);
518 if (seen.has(dep)) {
519 console.log(`removing circular dep ${rule.params} in ${file}`);
520 rule.remove();
521 modified = true;
522 } else {
523 deps.add(dep);
524 }
525 });
526
527 if (modified) {
528 fs.writeFileSync(file, ast.toString());
529 }
530
531 seen.add(file);
532 for (let dep of deps) {
533 removeCircularDeps(dep, seen);
534 }
535 seen.delete(file);
536}
537
538/** Generates a wrapper component when there is no Reusable wrappers section. */
539function generateWrapper(name) {

Callers 1

extractStarter.mjsFile · 0.85

Calls 7

deleteMethod · 0.80
hasMethod · 0.65
removeMethod · 0.65
addMethod · 0.65
toStringMethod · 0.65
resolveFunction · 0.50
parseMethod · 0.45

Tested by

no test coverage detected