Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

append nested arrays with mergeWithRules #175

Closed
noslouch opened this issue Feb 4, 2021 · 6 comments
Closed

append nested arrays with mergeWithRules #175

noslouch opened this issue Feb 4, 2021 · 6 comments

Comments

@noslouch
Copy link

noslouch commented Feb 4, 2021

Does append work with nested arrays?

const a = {
  module: {
    rules: [{
      test: /\.js$/,
      use: {
        loader: 'babel-loader',
        options: {
          plugins: ['@babel/plugin-proposal-class-properties']
        },
      }
    }]
  }
};

const b = {
  module: {
    rules: [{
      test: /\.js$/,
      use: {
        loader: 'babel-loader',
        options: {
          plugins: ['styled-components']
        }
      }
    }]
  }
};

const rules = {
  module: {
    rules: {
      test: 'match',
      use: {
        loader: 'match',
        options: {
          plugins: 'append'
        }
      }
    }
  }
};

mergeWithRules(rules)(a, b);
// result
{
  module: {
    rules: [{
      test: /\.js$/,
      use: {
        loader: 'babel-loader',
        options: {
          plugins: ['@babel/plugin-proposal-class-properties']
        },
      }
    }]
  }
};

// expected
{
  module: {
    rules: [{
      test: /\.js$/,
      use: {
        loader: 'babel-loader',
        options: {
          plugins: ['@babel/plugin-proposal-class-properties', 'styled-components']
        },
      }
    }]
  }
};
@bebraw
Copy link
Member

bebraw commented Feb 5, 2021

I think I have to add a bit of logic to catch the nested append case. Thanks for the heads up.

@noslouch
Copy link
Author

noslouch commented Feb 5, 2021

Appreciate it!

@G-Rath
Copy link

G-Rath commented Apr 23, 2021

I just hit exactly this situation, which I was expecting to work fine based on the documentation of mergeWithRules in the README 😬

@mohd-akram
Copy link

Any update on this?

@bebraw
Copy link
Member

bebraw commented Nov 3, 2021 via email

@burhanuday
Copy link
Contributor

This issue can be closed - #206

@bebraw bebraw closed this as completed Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants