123456789101112131415161718192021222324252627282930 |
- const {
- addOrUpdateConfigObject,
- findAndRemovePluginByName
- } = require("../../utils/ast-utils");
- /**
- *
- * Transform for NamedModulesPlugin. If found, removes the
- * plugin and sets optimizations.namedModules to true
- *
- * @param {Object} j - jscodeshift top-level import
- * @param {Node} ast - jscodeshift ast to transform
- * @returns {Node} ast - jscodeshift ast
- */
- module.exports = function(j, ast) {
- // Remove old plugin
- const root = findAndRemovePluginByName(j, ast, "webpack.NamedModulesPlugin");
- // Add new optimizations option
- root &&
- addOrUpdateConfigObject(
- j,
- root,
- "optimizations",
- "namedModules",
- j.booleanLiteral(true)
- );
- return ast;
- };
|