-
Notifications
You must be signed in to change notification settings - Fork 69
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
feat(config): support modules
config to customize css modules processing
#218
feat(config): support modules
config to customize css modules processing
#218
Conversation
- Handle all errors centrally and properly set process exit code - Use console.warn where appropriate to funnel messaged to stderr - Do not ignore errors when loading config file
This stops ignoring errors generated by the sass compiler (as well as any other potential errors generated during the process of writing to disk). Instead, errors are now always thrown to the top of the stack, they are logged, and properly set the exit code. Any errors that include file info are assumed to be sass errors, and some additional formatting applied to improve debuggability.
This also changes the TS target to ES2022 to support the second argument of the Error constructor.
…odules Options are delegated to `postcss-modules`: https://www.npmjs.com/package/postcss-modules
@skovy I noticed a subtle issue in the current implementation of It parses a CSS file, resolves CSS Module imports, then it recursively processes CSS Module imports. For example: In the consumer's repo, one may have a SCSS file as In .my-class {
composes: some-class from './some-other.scss'
} In @use '@some-aliased-module' as m;
@include m.some-mixin-that-produces-some-class; When I'm not sure what happens at the moment, this probably produces a silent failure (something that I'm attempting to fix in #217). Also, in this example, it probably is ok beause we don't need I think the fix would be to pass a custom Additionally, this can be leveraged to improve type safety. The proper types for import {Styles as SomeOtherScssStyles} from './some-other.scss'
type Styles = {
'my-class': SomeOtherScssStyles['some-class']
} or some assertion that ensures that class exists (excuse my poor man's TS assertions 😅 ) import {Styles as SomeOtherScssStyles} from './some-other.scss'
type Assert<T extends 'yes'> = unknown;
type Assertion1 = Assert<SomeOtherScssStyles['some-class'] extends string ? 'yes' : 'no'>
type Styles = {
'my-class':string
} |
About my last comment, I actually encountered this issue 😢 . When properly raising errors, this is preventing my build from working. I will try to fix this in this branch. |
Use an identity-obj-proxy to avoid loading downstream files. This solves the problem called out here[^1], while minimizing disk access, at the cost of issues with broken imports. [^1]: skovy#218 (comment)
@GeorgeTaveras1231 I don't fully follow, but we do expose the custom |
I'm confused about what this PR is doing with changes from another branch, several updates, and bugs that seem to be unrelated. Please open focused issues or pull requests so we can discuss each item individually. |
Goal
resolve
function for CSS modules. I thought it was reasonable to allow customizingpostcss-modules
entirely. See the full list of options here. Some options may not make sense in this context (such as thescopedNameFormat
) but others likeexportGlobals
andscopeBehaviour
may be useful for consumers.Update: I no longer need the ability to customize the
resolve
option. The newIdentityObjProxyLoader
removes the need to customize the resolution logic as all CSS Module imports are resolved and stubbed. It may still be useful to allow customizing thepostcss-modules
options, but I'd be okay with rolling back that change.