From cd5d873c753316bbed384f9bbe82754353a8c600 Mon Sep 17 00:00:00 2001 From: romainmenke Date: Fri, 21 Jan 2022 17:16:22 +0100 Subject: [PATCH] flip disableClientSidePolyfills --- plugin-packs/postcss-preset-env/.tape.mjs | 8 ++++---- plugin-packs/postcss-preset-env/README.md | 6 +++--- plugin-packs/postcss-preset-env/src/index.js | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/plugin-packs/postcss-preset-env/.tape.mjs b/plugin-packs/postcss-preset-env/.tape.mjs index 0fcd6de73..2211ba31c 100644 --- a/plugin-packs/postcss-preset-env/.tape.mjs +++ b/plugin-packs/postcss-preset-env/.tape.mjs @@ -141,16 +141,16 @@ postcssTape(plugin)({ } }, 'disable-client-side-polyfills': { - message: 'supports { disableClientSidePolyfills: true } usage', + message: 'supports { enableClientSidePolyfills: false } usage', options: { - disableClientSidePolyfills: true, + enableClientSidePolyfills: false, stage: 0, } }, 'disable-client-side-polyfills:disabled': { - message: 'supports { disableClientSidePolyfills: false } usage (default)', + message: 'supports { enableClientSidePolyfills: true } usage (default)', options: { - disableClientSidePolyfills: false, + enableClientSidePolyfills: true, stage: 0, } }, diff --git a/plugin-packs/postcss-preset-env/README.md b/plugin-packs/postcss-preset-env/README.md index 78cc0c96a..754325e3a 100644 --- a/plugin-packs/postcss-preset-env/README.md +++ b/plugin-packs/postcss-preset-env/README.md @@ -100,7 +100,7 @@ to the polyfill's library. * `has-pseudo-class`: [Plugin](https://github.com/csstools/postcss-plugins/blob/main/plugins/css-has-pseudo) / [Polyfill](https://github.com/csstools/postcss-plugins/blob/main/plugins/css-has-pseudo/README-BROWSER.md) * `prefers-color-scheme-query`: [Plugin](https://github.com/csstools/postcss-plugins/blob/main/plugins/css-prefers-color-scheme) / [Polyfill](https://github.com/csstools/postcss-plugins/blob/main/plugins/css-prefers-color-scheme/README-BROWSER.md) -If you want to disable these types of features, please check the [`disableClientSidePolyfills` option](#disableclientsidepolyfills). +If you want to disable these types of features, please check the [`enableClientSidePolyfills` option](#enableclientsidepolyfills). ## Usage @@ -407,9 +407,9 @@ postcssPresetEnv({ The `debug` option enables debugging messages to stdout which should be useful to help you debug which features have been enabled/disabled and why. -### disableClientSidePolyfills +### enableClientSidePolyfills -The `disableClientSidePolyfills` disables any feature that would need an extra browser library to be loaded into the page for it to work. +The `enableClientSidePolyfills` enables any feature that would need an extra browser library to be loaded into the page for it to work. Defaults to `true`. Note that manually enabling/disabling features via the "feature" option overrides this flag. diff --git a/plugin-packs/postcss-preset-env/src/index.js b/plugin-packs/postcss-preset-env/src/index.js index d36555343..08554bb49 100644 --- a/plugin-packs/postcss-preset-env/src/index.js +++ b/plugin-packs/postcss-preset-env/src/index.js @@ -20,7 +20,7 @@ const plugin = opts => { // initialize options const options = Object(opts); const features = Object(options.features); - const disableClientSidePolyfills = options.disableClientSidePolyfills; + const enableClientSidePolyfills = 'enableClientSidePolyfills' in options ? options.enableClientSidePolyfills : true; const featureNamesInOptions = Object.keys(features); const insertBefore = Object(options.insertBefore); const insertAfter = Object(options.insertAfter); @@ -84,7 +84,7 @@ const plugin = opts => { // staged features (those at or above the selected stage) const stagedFeatures = polyfillableFeatures.filter(feature => { const isAllowedStage = feature.stage >= stage; - const isAllowedByType = !disableClientSidePolyfills || !featuresWithClientSide.includes(feature.id); + const isAllowedByType = enableClientSidePolyfills || !featuresWithClientSide.includes(feature.id); const isDisabled = features[feature.id] === false; const isAllowedFeature = features[feature.id] ? features[feature.id] : isAllowedStage && isAllowedByType; @@ -97,7 +97,7 @@ const plugin = opts => { log(` ${feature.id} with stage ${feature.stage} has been disabled`); } } else if (!isAllowedByType) { - log(` ${feature.id} has been disabled by "disableClientSidePolyfills".`); + log(` ${feature.id} has been disabled by "enableClientSidePolyfills: false".`); } return isAllowedFeature;