samrith-s / parcel-plugin-structurize

A plugin to customize the output (dist) directory structure during production.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Run on watch

Immortalin opened this issue · comments

commented

This currently doesn't run in watch mode.

commented

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

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.

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.

Closing due to no response.

commented

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.

Here are some points to consider:

  • This operation requires traversing over all the files and modifying the structure. If it runs on every save, it will be a very expensive operation to perform.
  • What we can do, is to detect the file and just modify that file. Even then, it's an extremely expensive option to perform.

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

commented

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

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.

commented

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

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.

commented

Send me the link to the failing test

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