bem-sdk icon indicating copy to clipboard operation
bem-sdk copied to clipboard

Add method to build full form of import notation

Open Vittly opened this issue 8 years ago • 4 comments

webpack-bem-plugin requests method: import-notation-string -> import-notation-full-string

For now extending context process is integrated in parse method. Can we do a simple refactoring here?

Vittly avatar Feb 04 '18 08:02 Vittly

Its also needed for method('b:foo e:x e:y') and method('b:foo e:y e:x') to return same result independent from initial order (of elements/modifiers/techs/etc-if-any)

Vittly avatar Feb 04 '18 08:02 Vittly

method('b:foo e:x e:y') and method('b:foo e:y e:x') — ooh, are you sure it should be the same order?

import-notation-string -> import-notation-full-string

Can you collaborate on this a lil bit more?

qfox avatar Feb 05 '18 18:02 qfox

are you sure it should be the same order?

not really. In plugin I want notation-string to be unique. In general it is not required

Can you collaborate on this a lil bit more?

add more info or make a PR ? Can do all two. You can assign it to me

Vittly avatar Feb 06 '18 08:02 Vittly

According to old known BEM Full Stack and their must-should-deps mess there can be different order if entities relates each to another with "should" (weak) link.

I'd suggest to use the order of the first found set.

It could be something like:

const cache = {};
const method = (str) => {
  const cells = parseImport(str);
  const key = Array.from(new Set(cells.sort().map(c => c.id)).join(' ');
  if (cache[key]) return cache[key];
  return cache[key] = cells;
}

But how many times I'll get js code of block if I import it few times in different places? Accordingly to the logic we should reuse this code ;-)

It means we should group all js files of block with all their mods and then bake it to one Class with applyDecls() (hope we will change name and the way we call it).

Can you collaborate on this a lil bit more?

add more info or make a PR ? Can do all two. You can assign it to me

It's the least I can do ;-D

qfox avatar Feb 06 '18 11:02 qfox