griffel icon indicating copy to clipboard operation
griffel copied to clipboard

chore: migrate to to wyw-in-js

Open layershifter opened this issue 1 year ago • 1 comments

TODO

Update PR to reflect removal of @griffel/babel-preset.

Summary

This PR upgrades @griffel/babel-preset and @griffel/webpack-loader to use wyw-in-js. wyw-in-js introduces a concept of processors to handle different CSS-in-JS implementations i.e. "implement your processor (transform) and use existing tooling to run it".

The information is obtainer from package.json files:

{
  "linaria": {
    "tags": {
      "makeStyles": "@griffel/linaria-processor/make-styles",
      "makeResetStyles": "@griffel/linaria-processor/make-reset-styles"
    }
  }
}

👆 indicates Linaria to process makeStyles & makeResetStyles with matching transforms

Another benefit is that Linaria v5 supports async resolving of dependencies that was a blocker for other bundlers (#33).

BREAKING CHANGES

@griffel/babel-preset

  • modules & projectRoot options removed from configs, use package.json to define processors (see Summary ⬆️ )
  • EvalCache & Module are not longer exported and should not be used directly anymore
  • requires @griffel/linaria-processor installed

TODO

  • [ ] restore metadata parsing

@griffel/webpack-loader

  • modules & projectRoot options removed from configs, use package.json to define processors (see Summary ⬆️ )
  • requires @griffel/linaria-processor installed

Details

@griffel/babel-preset

All internals of @griffel/babel-preset were removed: module evaluation is gone, parts related to assets handling were moved to @griffel/linaria-processor.

  • error-argument-count: not needed, check is not longer there
  • import-custom-module: aliases are configured now in package.json files
  • import-custom-name: aliases are configured now in package.json files
  • non-existing-module-call: removed, @linaria/shaker now works differently
  • require-custom-module: removed, not needed

Updated fixtures:

  • asset: file paths handled properly, fixes #313
  • config-evaluation-rules: we don't have own evaluation part anymore, matches to what Linaria does
  • duplicated-imports: handles multiple imports as it should be 💪 Fixes #104

@griffel/webpack-loader

All internals of @griffel/webpack-loader were removed, now it's just a tiny wrapper around @linaria/webpack-loader.

Following fixtures were removed:

  • config-modules: aliases are configured now in package.json files
  • error-argument-count: not needed, check is not longer there
  • error-syntax: not needed

New fixture react-component to test a more real life example.

TODO

  • [ ] document breaking changes

Related issues

Fixes #104. Fixes #184. Fixes #313.

TODOs

  • [x] Test on Windows machine
  • [ ] Test in products
  • [x] ~~Pass proper import sources in processors~~
  • [x] ~~🔴 https://github.com/callstack/linaria/issues/1311~~
  • [x] ~~🔴 BLOCKER https://github.com/callstack/linaria/issues/1214~~
  • [x] ~~🔴 BLOCKER https://github.com/callstack/linaria/issues/1209~~
  • [x] ~~🔴 BLOCKER: https://github.com/callstack/linaria/issues/1186~~
  • [x] ~~🔴 BLOCKER: https://github.com/callstack/linaria/pull/1188~~
  • [x] ~~🔴 BLOCKER: https://github.com/callstack/linaria/issues/1189~~
  • [x] ~~💣 BLOCKER: https://github.com/callstack/linaria/issues/1193~~

layershifter avatar Jul 31 '23 13:07 layershifter