diff --git a/designs/0003-generate-d-ts-files-for-altcss.md b/designs/0003-generate-d-ts-files-for-altcss.md index 1519e68..79bdbed 100644 --- a/designs/0003-generate-d-ts-files-for-altcss.md +++ b/designs/0003-generate-d-ts-files-for-altcss.md @@ -67,11 +67,21 @@ For example, consider the following Sass files: In this case, the tokens exported from `1.module.scss` are `foo` and `bar`. -Here, the tokens from `1.module.scss` are `foo` and `bar`. +Now, if `2.module.scss` is changed as follows: -If `happy-css-modules` is run with the `--cache` option, it needs to detect that `1.module.scss` should be reprocessed if `2.module.scss` changes. To achieve this, we need to implement a dependency graph that tracks the relationship between AltCSS files. When an AltCSS file is transpiled, its dependencies should be detected, and this information should be stored in the dependency graph. When a file changes, the dependency graph should be consulted to determine which files need to be reprocessed. +```scss +// 2.module.scss +.bar { + color: green; +} +.baz { + color: yellow; +} +``` + +In this case, the tokens exported from `1.module.scss` will be `foo`, `bar`, and `baz`. Therefore, even if `1.module.scss` itself has not been modified, the `happy-css-modules` command needs to regenerate the type definition file for `1.module.scss`. -The following pseudo-code demonstrates this: +To achieve this, `happy-css-modules` will retrieve information about embedded files from the preprocessor. Here is the code: ```ts import { watch } from 'chokidar';