Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method to build full form of import notation #275

Open
Vittly opened this issue Feb 4, 2018 · 4 comments
Open

Add method to build full form of import notation #275

Vittly opened this issue Feb 4, 2018 · 4 comments
Assignees

Comments

@Vittly
Copy link
Collaborator

Vittly commented Feb 4, 2018

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
Copy link
Collaborator Author

Vittly commented Feb 4, 2018

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)

@qfox
Copy link
Member

qfox commented Feb 5, 2018

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?

@Vittly
Copy link
Collaborator Author

Vittly commented Feb 6, 2018

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

@qfox
Copy link
Member

qfox commented Feb 6, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants