Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

How @bem/sdk.deps works?

node v10.24.1
version: 1.0.1
endpointsharetweet
const deps = require('@bem/sdk.deps'); const Config = require('@bem/sdk.config'); const mockfs = require('mock-fs'); const { stripIndent } = require('common-tags'); // Describe a file structure of the project. mockfs({ '.bemrc': stripIndent` module.exports = { root: true, levels: [ { naming: 'legacy', layer: 'common', path: 'common.blocks' } ], sets: { 'desktop': 'common', } }`, 'common.blocks': { 'page': { 'page.deps.js': stripIndent` ({ shouldDeps: [ { mods: { view: ['404'] } }, 'header', 'body', 'footer' ]})` }, 'header': { 'header.deps.js': '({ shouldDeps: ["logo"] })' }, } }); // Get the project's configuration from the `.bemrc` file. const config = Config(); // Load the project's dependencies list. const dependencies = await deps.load({ config }); // Show the dependencies in a readable format. dependencies.map(e => e.vertex.id + ' => ' + e.dependOn.id);
Create a graph and get the dependenciesOf the block `page`.
// Create a graph from the dependencies list. const graph = deps.buildGraph(dependencies); // Now you can use any functions from the @bem/sdk.graph package. // For example, show sorted dependencies of the block `page`. graph.dependenciesOf({ block: 'page'});
Loading…

no comments

    sign in to comment