modernweb-dev / web

Guides, tools and libraries for modern web development.
https://modern-web.dev
MIT License
2.21k stars 281 forks source link

mergeConfigs should merge objects recursively #2688

Open DavidPeicho opened 6 months ago

DavidPeicho commented 6 months ago

Calling startTestRunner with this config:

startTestRunner({
    config: {
            testFramework: {
                config: {
                    grep: 'GrepSomething'
                },
            },
    },
});

would fail if another configuration down the line contain any testFramework parameters. It looks like mergeConfig should probably recursively merge objects, just like it does with arrays here.

bashmish commented 6 months ago

Not sure if there was a specific reason to not do it like that? cc @thepassle @LarsDenBakker

Did you consider implementing or using 3rd party merge for your use-case? IIUC, both configs are in your code: one in the config file and one in the JS file where you invoke startTestRunner? It's often hard to define a single merge strategy that works for everyone, so if you can use smth custom for yourself, that can be a better strategy.