webpack / enhanced-resolve

Offers an async require.resolve function. It's highly configurable.
MIT License
916 stars 186 forks source link

feat: ignore `false`/`null`/`undefined` plugins #389

Closed alexander-akait closed 1 year ago

alexander-akait commented 1 year ago

Part of https://github.com/webpack/webpack-cli/issues/3836

Allow to use:

// `false` value for an example, for example when you are in development mode and don't want to use plugin
// so you don't need to use `.filter(Boolean)`, it is faster and has a better DX
const isProduction = false; 

module.exports = {
  //...
  resolve: {
    plugins: [
      isProduction && new DirectoryNamedWebpackPlugin()
    ],
  },
};

Note - you an use any falsy values, NaN is falsy too, but https://github.com/Microsoft/TypeScript/issues/15135, and I don't think it is a good idea allow to pass NaN

codecov[bot] commented 1 year ago

Codecov Report

:exclamation: No coverage uploaded for pull request base (main@3c3d31e). Click here to learn what that means. Patch coverage: 100.00% of modified lines in pull request are covered.

:exclamation: Current head f5677bc differs from pull request most recent head 3a765d9. Consider uploading reports for the commit 3a765d9 to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #389 +/- ## ======================================= Coverage ? 92.85% ======================================= Files ? 43 Lines ? 2042 Branches ? 598 ======================================= Hits ? 1896 Misses ? 118 Partials ? 28 ``` | [Impacted Files](https://app.codecov.io/gh/webpack/enhanced-resolve/pull/389?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=webpack) | Coverage Δ | | |---|---|---| | [lib/ResolverFactory.js](https://app.codecov.io/gh/webpack/enhanced-resolve/pull/389?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=webpack#diff-bGliL1Jlc29sdmVyRmFjdG9yeS5qcw==) | `96.15% <100.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.