Making sure the compiler picks up files with 'Exclude Unused Files' option

Is there an easy way to make sure the compiler picks up files used by plugins when you use the 'Exclude Unused Files' option?

If you pick the 'Exclude Unused Files' option during deployment, the compiler will pick up files that the base engine uses, but it fails to pick up files that are just used by plugins, leading to nasty errors for your players when the engine goes looking for them. Up to this point, I've gotten around that by manually adding back in files I know it missed, but I'm thinking there has to be a better way.

I tried writing a plugin that allows you to choose a file and tags it with `@require 1`, but the compiler didn't grab that file:
Code:
//===========================================================================
// RequiredFiles.js                                                             
//===========================================================================

/*:
*
* @author Me
* @plugindesc Ensures necessary files are picked up by the compiler.
*
* @help
* No help here!
*
* @param include1
* @text File to Include no 1
* @type file
* @require 1
*
*/

(function() {
  console.log("Hello, world!");
})();

Ideally, I'd like a way to tag both specific files AND specific directories. Does anyone know of a way to do that? Thanks!
You can't modify the software (the engine itself, not the game) with plugins. So that means we can't modify the deployment process. Also, it would be extremely hard to track all the resources used in plugins, especially if you're using third party plugins.
Right. I understand I can't modify the editor, but the `@require 1` parameter when used with `@type file` is supposed to force the compiler to include the specified file in a deployment.

For anyone else having this issue, it looks like there's another parameter `@requiredAssets` that does seem to work. Unfortunately, it doesn't seem to support a wildcard (so no directories), and you have to hardcode in the path. Example:

Code:
//===========================================================================
// RequiredFiles.js                                                             
//===========================================================================

/*:
*
* @author Me
* @plugindesc Ensures necessary files are picked up by the compiler.
*
* @help
* No help here!
*
* @requiredAssets img/titles1/myImg
*
*/

(function() {})();

Note: leave off the file extension.

It also looks like there's been a discussion about something similar here, but I'll have to find the time to parse what's happening in Shaz's plugin.
Yep, thanks for the link - saves me trying to look it up. What that plugin does is look for tags in the Tileset notes that refer to a new file to be included, and adds it to the js file as a requiredAsset.

If you want to grab ALL the files in a particular directory, you could use a command to get a list of all the files (I'm assuming there would be one - maybe check what the FileManager does when looking to see what save files exist?) and iterate through them, just like I've iterated through $dataTilesets.

Also check out my Change Tile Size plugin. It does something similar, looking for all the files used by a tileset then adding a require for the "small" version of that tileset to the plugin itself. At least that one is still working (the upper autotiles broke with an MV update a long, long time ago).

The info on the command itself is in the help file, under the Javascript section IIRC. I have a feeling that audio needs a different command, and that one type of asset (animations?) has an extra parameter.
I think you have to include the @dir part of the parameter in order for the exporter tool to recognize where to include the file from.
Code:
//===========================================================================
// RequiredFiles.js                                                             
//===========================================================================

/*:
*
* @author Me
* @plugindesc Ensures necessary files are picked up by the compiler.
*
* @help
* No help here!
*
* @param include1
* @text File to Include no 1
* @type file
* @require 1
* @dir img
*
*/
@Aloe Guvner
You're right, it does work if you include the `@dir img`! Unfortunately, some of the files I'll need to grab might be audio, so this restriction prevents me from using the `@file` method for a general solution of my problem. (I know it would probably work with `@dir audio` too, but I'd envisioned a plugin with 100 or so general-purpose slots.) But this method can't handle directories, so I guess it was never going to work as a general solution anyway. Good to know for writing other plugins, though!

@Shaz
Thanks for the reply! I think I get it now; the idea of having a plugin rewrite itself is pretty clever. This is the only idea I've seen so far that should be able to handle directories, so I think I'll give it a shot.

Original thread: https://forums.rpgmakerweb.com/threads/making-sure-the-compiler-picks-up-files-with-exclude-unused-files-option.108999/