Skip to content

Documentation for features postcss-preset-env features that need polyfills should be less confusing #860

@dpschen

Description

@dpschen

Hello csstools team,

First of thanks for your amazing work!
I struggled a bit to configure postcss correctly to enable a plugin that requires a polyfill. In the following my train of thought in the sequence it happened to me while trying to make that feature work.


  1. In the README.md of the postcss-preset-env pack under enableClientSidePolyfills it is written that:
  • This only controls if the PostCSS plugins are enabled. It does not cause the browsers libraries to be included in your bundle.
  1. At the same time it is said that:
  • Note that manually enabling/disabling features via the "feature" option overrides this flag.
  1. Now under "Plugins that need client library
    "
    there is a list of all the libraries with each a link to the plugin and the polyfill.

For my project I only need the focus-within-pseudo-class feature.

  1. Checking now the documentation of that plugin it is written:

PostCSS Focus Within works in all major browsers, including Safari 6+ and Internet Explorer 9+ without any additional polyfills.

… which really confused me because:

Isn't the example given there a way to add a polyfill?

  1. Then again in the documentation of "Plugins that need client library
    "
    it is also written that:

If you want to disable these types of features, please check the enableClientSidePolyfills option.

(I later realised that this should probably be changed to something like If you want to enable all of these types of features [?])


I ended up with something that seems to be working by manually enabling the feature I wanted and manually importing the polyfill like this:

import focusWithin from 'focus-within'

focusWithin(document)

I'm still unsure if this is the correct way.
For me my own solution is fine I only want to spare the next person to go through all of this again :)

Basically it seems that there is a missing documentation of how to integrate the plugins that when you use the postcss-preset-env pack.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions