@bem/sdk.deps: load()

node v10.24.1
version: 1.0.0
endpointsharetweet
const deps = require('@bem/sdk.deps'); const mockfs = require('mock-fs'); const { stripIndent } = require('common-tags'); // Describe a file structure of the project. This is a simplified bem-express structure. mockfs({ '.bemrc': stripIndent` module.exports = { root: true, levels: [ { naming: 'legacy', layer: 'common', path: 'common.blocks' }, { naming: 'legacy', layer: 'development', path: 'development.blocks' } ], sets: { 'desktop': 'common', 'development': 'common development' } }`, 'common.blocks': { 'page': { 'page.deps.js': stripIndent` ({ shouldDeps: [ { mods: { view: ['404'] } }, 'header', 'body', 'footer' ]})` }, 'header': { 'header.deps.js': '({ shouldDeps: ["logo"] })' }, }, 'development.blocks': { 'page': { 'page.deps.js': '({ shouldDeps: ["livereload"] })' } } }); const defaultDeps = await deps.load({ }); defaultDeps.map(e => e.vertex.id + ' => ' + e.dependOn.id);
Let's load the dependencies list for the 'development' level set whic includes 'common' and 'development' layers.
const platform = 'development'; const developmentDeps = await deps.load({ platform }); developmentDeps.map(e => e.vertex.id + ' => ' + e.dependOn.id);
Loading…

no comments

    sign in to comment