css-modules/postcss-modules-extract-imports

:external proposal

sullenor opened this issue · 4 comments

I decided to make a separate issue about :external keyword proposal (css-modules/css-modules#147) in order to summarize and discuss the implementation details.

Syntax

In my opinion the :external keyword can be easily implemented with the icss imports which are mostly generated with the current module. So, it will be easy to integrate it into the existing tools.

The possible transformation:

:external(inner from './elsewhere.css') {
  prop: value;
}

into:

:import("./elsewhere.css") {
  _generid_id: inner;
}

._generid_id { /* not sure about the _generid_id pointer */
  prop: value;
}

The next step will be to patch the :import resolving libs in order to check the rules and replace it with imported token. For the parsing convenience the generated rule may be wrapped with any keyword, like :external(_generid_id). So it will transform:

:external(inner from './elsewhere.css') {
  prop: value;
}

into:

:import("./elsewhere.css") {
  _generid_id: inner;
}

:external(._generid_id) {
  prop: value;
}

css-loader

Are you planning to add this feature?

Care to elaborate?

selectors/values issue