question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Document how to declare a PostCSS plugin in an ES6/TypeScript module

See original GitHub issue

It’s currently unclear how to properly declare a PostCSS module using ES6 module syntax (which TypeScript also uses idiomatically). The suggested module.exports isn’t idiomatic in these systems.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:19 (19 by maintainers)

github_iconTop GitHub Comments

2reactions
nex3commented, Aug 19, 2022

Okay, I’ve found an incantation that works:

// eslint-disable-next-line @typescript-eslint/no-namespace
namespace plugin {
  export interface Options { … }
}

const plugin: PluginCreator<olugin.Options> = (opts = {}) => { … };
plugin.postcss = true;

export = plugin;

It would be nice if there were an alternative way to declare these plugins that was more module-system friendly—allowing the PluginCreator to be defined as the top-level postcss field, for example.

1reaction
romainmenkecommented, Nov 3, 2022

That was from before my time as a maintainer of these plugins so I would have to start digging through old commits.

Most likely this happened :

  • someone had an issue with some plugin in esm, deno, webpack, …
  • conditional exports were setup with the dual distibution of esm and cjs
  • someone fixed the actual issue by changing/adding the rollup config

I don’t dare removing it now 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Writing a PostCSS Plugin
For public plugins: Use the guide in PostCSS plugin boilerplate to create a plugin directory. Create a repository on GitHub or GitLab. Publish...
Read more >
Issues · postcss/postcss · GitHub
Contribute to postcss/postcss development by creating an account on GitHub. ... Document how to declare a PostCSS plugin in an ES6/TypeScript module.
Read more >
HTML and CSS — Zulip 7.0-dev+git documentation
Stylesheets are written in CSS extended by various PostCSS plugins; ... in the HTML templates under templates/ with the bundles declared in tools/webpack....
Read more >
Using Tailwind CSS with Django 3.x - weautomate.org
For an optimal setup, we'll be using Tailwind as a postcss plugin. ... init -p which will create tailwind.config.js and postcss.config.js.
Read more >
So you want to make a PostCSS plugin - CSS-Tricks
The PostCSS API is the fastest and most accurate CSS parser that I have ever used. The documentation behind it is very well...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found