samrith-s / parcel-plugin-structurize

A plugin to customize the output (dist) directory structure during production.
MIT License
41 stars 6 forks source link

Run on watch #6

Closed Immortalin closed 5 years ago

Immortalin commented 5 years ago

This currently doesn't run in watch mode.

Immortalin commented 5 years ago

@samrith-s any suggestions for how to fix this?

samrith-s commented 5 years ago

Reopening while there is still an active PR.

@Immortalin Please don't use Closes x in the title. Use Fixes x in the description instead.

samrith-s commented 5 years ago

Quick question, why is this needed in watch or serve mode?

This is an expensive operation, as it traverses all the files and modifies them. When you watch, it'll happen every time Parcel builds. From the Parcel docs, even during serve, the bundler emits buildEnd. This plugin hooks on to that event, and runs once it the build has ended.

It would be a very bad idea to make it run on watch and serve, as it will do really expensive operations in the dist folder every time you do any modifications to any file watched by Parcel.

samrith-s commented 5 years ago

Closing due to no response.

Immortalin commented 5 years ago

Hi sorry I just noticed this. My reason for adding build mode is because if you are working with Web frameworks like Django etc. you need live loading support. Webpack has support for this.

samrith-s commented 5 years ago

Here are some points to consider:

Keeping these in mind, it is not a very viable option to run it every time.

Immortalin commented 5 years ago

Hmm, then how do webpack et al. usually do it? Perhaps we can cache most of the ops?

samrith-s commented 5 years ago

Maybe we can, but that's an insane amount of heavy lifting for a plugin. It's not possible to do a compare operation on every save and update parts of the file. That's a task for the bundler to do, and would require a big overhaul. Should not be done within the scope of this plugin.

Alternatively, what we can do, is add the mode, but document it with a very clear warning about performance implications.

Immortalin commented 5 years ago

Sure that could work, feel free to modify the pull.

samrith-s commented 5 years ago

I'm reopening your PR. But it has failed the Codacy tests. Please ensure your PR follows code quality standards, I'll review it then.

Immortalin commented 5 years ago

Send me the link to the failing test

samrith-s commented 5 years ago

It's on the PR itself. https://app.codacy.com/app/samrith/parcel-plugin-structurize/pullRequest?prid=3745658

samrith-s commented 5 years ago

Marking this as won't fix, as it is not in the scope of this plugin.