Skip to content

postcss.config.js plugins causing exception #46

Closed
@BasilPP

Description

@BasilPP

Describe the bug
When using this plugin, it throws an exception when a postcss.config.js file with plugins is present.
Error Message:
[typescript-plugin-css-modules] Stack trace: Error: Use process(css).then(cb) to work with async plugins

To Reproduce
Include a postcss.config.js file with any of these plugins:
• postcss-import
• postcss- url
• postcss-preset-env
• cssnano

Expected behavior
Exception to not be thrown.

Desktop (please complete the following information):
OS - windows

Additional context
I’ve traced the error to a line in DtsSnapshotCreator.ts:
const processedCss = processor.process(transformedCss);

Now, in my scenario, processor.process(transformedCss) is returning a Promise and a simple solution I found was to await the promise returned by processor.process(transformedCss).

But I'm not sure if the reason a Promise is being returned in my case is that:

  • there is something wrong in my setup?
  • one of the plugins I'm using is forcing processor.process(transformedCss) to behave in an async fashion?
    I noticed that there is code in the index.ts file to filter out the postcss-mixins plugin as it might be async.
    Do more plugins need to be excluded in this way?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions