mollie / Shopware6

47 stars 52 forks source link

Move package.json files for tests to a different folders (admin and storefront), e.g. a subfolder tests #217

Open AndreasA opened 2 years ago

AndreasA commented 2 years ago

With current shopware production template all plugin dependencies call a npm install for all installed plugins in admin and storefront build processes: https://github.com/shopware/production/blob/v6.4.5.1/bin/build-storefront.sh#L32

This means that the npm install is triggered for your tests which seems unnecessary if those dependencies are really only necessary for tests.

boxblinkracer commented 2 years ago

Hi

thank you for this

as far as I know, this is based on the guides of Shopware. if they install it it including dev-dependencies, that that build file should be fixed.

theres a clear section for prod and dev dependencies in package.json that has to be respected by the calling instance.

so i think its better if shopware itself get fixed...or maybe theres a reason for this what do you think?

AndreasA commented 2 years ago

@boxblinkracer Dev dependencies can be required by webpack to correctly do the dependency build.

E.g. usually in dependencies one puts things that are deployed in the end but things like webpack/babel/file loaders etc. are still required to build it, which are to be placed in devDependencies. devDependencies for node are a bit different to require-dev in PHP. They are modules that are not required during runtime but still required during development / building of assets. So if I want to build my plugin javascript files and the mollie plugin is installed, those dependencies are could still be required.

One scenario would be a plugin adding a fileloader and adding webpack build adjustments (which is possible), in this case the file loader will be required to successfully completely the build.

However, if I understand it correctly you only use it for tests, so the question is are those dependencies needed at all. Probably not but Shopware cannot make that distinction. Your plugin can though by e.g. moving the package.json in a tests subfolder or similar.

Though I could be wrong but from what I understand that's how it is, e.g. according to: https://medium.com/@dylanavery720/npmmmm-1-dev-dependencies-dependencies-8931c2583b0c

boxblinkracer commented 2 years ago

Hi there

thanks for this, ah yeah..sorry, kinda confusing day :D totally makes sense that that build command has dev-dependencies haha :D

ok so you basically just mean, the overhead of the testing stuff can be avoided if not needed by anyone else so we could move it to a different file that is not automatically run by shopware

now i got you, right?

AndreasA commented 2 years ago

@boxblinkracer Yes. I think it would make sense to do so? It isn't strictly a must but it would simplify running storefront / admin builds locally and it should be easy to do.