bem/themekit

Implement resolving path relative package, but not path in file system

vitonsky opened this issue · 2 comments

Proposal

Implement resolving path relative package, but not path in file system.

For example your convention may assume that all paths start from #, node_modules or other symbol will resolve with packages manager, but will not be a fs paths.

Use case

I have theme file in my project https://github.com/translate-tools/linguist/blob/master/src/themes/default.theme.json

I want to start use pnpm which keep node_modules not in project directory. But theme file is use relative paths in file system to some file in node_modules. I need a way to specify something like #react-elegant-ui/theme/tokens/light-color.tokens.yml instead of ./node_modules/react-elegant-ui/theme/tokens/light-color.tokens.yml because relative path will not work.

Maybe i could use .js config and resolve paths with require? If yes, then how i can do it?

As i see, you have issue #81 and i agree that this feature must be implemented ASAP, because it's not so friendly when i have to keep in my mind a directory from where will resolve relative paths for my theme. It's not my deal and current implementation is not allow to make really complicated design systems.

It's good to solve both problems with one approach to handle paths.

We have to introduce a convention to handle filepaths.

It must support:

  • absolute paths
  • relative paths
  • package-relative paths

You know, i think it's will fine if all paths will be package-related by default.

For example foo/bar/baz.yml will mean a file bar/baz.yml from the module foo.

For other cases, we have to use default FS prefixes, ./foo and ../foo for related current directory and /foo for absolute paths.

All we need is solve all paths which start not from special FS tokens ., /, ~ as paths for packages