enb / enb-bem-techs

ENB package to build BEM-projects
Other
22 stars 22 forks source link

Verbose Options #105

Open blond opened 9 years ago

blond commented 9 years ago

Options in all techs can be divided into three types: targets, sources and options.

Now, all options are set as a flat list. Because of this, not possible to understand what type of each option.

var techs = require('enb-bem-techs'),
    css = require('css-stylus-with-autoprefixer');

nodeConfig.addTechs([
    [techs.levels, {
        levels: ['blocks'],
        target: '?.levels'
    }],
    [techs.bemjsonToBemdecl, {
        source: '?.bemjson.js',
        target: '?.bemdecl.js'
    }],
    [techs.deps, {
        levelsTarget: '?.levels',
        bemdeclFile: '?.bemdecl.js'
        target: '?.deps.js'
    }],
    [techs.files, {
        levelsTarget: '?.levels',
        depsFile: '?.deps.js',
        filesTarget: '?.files',
        dirsTarget: '?.dirs'
    }],
    [css, {
        target: '?.css',
        filesTarget: '?.files',
        browsers: ['ie 7', 'ie 8']
    }]
]);

We can explicitly indicate which of the options are sources, which targets, and which options.

 var techs = require('enb-bem-techs');

nodeConfig.addTechs([
    [techs.levels, {
        sources: ['blocks'],
        target: '?.levels'
    }],
    [techs.bemjsonToBemdecl, {
        target: '?.bemdecl.js'
        source: '?.bemjson.js'
    }],
    [techs.deps, {
        target: '?.deps.js',
        sources: {
            levels: '?.levels',
            decl: '?.bemdecl.js'
        }
    }],
    [techs.files, {
        targets: {
            files: '?.files',
            dirs: '?.dirs'
        },        
        sources: {
            levels: '?.levels',
            decl: '?.deps.js',
        }
    }],
    [css, {
        target: '?.css',
        sources: {
            files: '?.files'
        },
        options: {
            browsers: ['ie 7', 'ie 8']
        }
    }]
]);
qfox commented 9 years ago

So you propose source/sources and target/targets as a standard for enb-techs? :+1: for that.

tadatuta commented 9 years ago

cc @arikon

qfox commented 9 years ago

Options looks like overkill, btw. But I'm not against it.

arikon commented 9 years ago

@andrewblond Why not just use the generic prefixes consistently in all the techs?

blond commented 9 years ago

Why not just use the generic prefixes consistently in all the techs?

It seems that it less obvious and less unification between techs.

Options looks like overkill, btw. But I'm not against it.

Yes, it seems that without options will be better

arikon commented 9 years ago

@andrewblond I don't like the distinction between target and targets, source and sources.

What if some of sources are optional? Than I have to write single nested option:

{
  sources: {
    sourceBemjson: '...'
  }
}

For me the generic prefix (convention) is more obvious than grouped options.

blond commented 9 years ago

For me the generic prefix (convention) is more obvious than grouped options.

If not group options then lost information that has more source options:

{
  sourceBemjson: '...'
}

if group then added not too many characters:

{
  sources: { bemjson: '...' }
}