Briefly describe the enhancement or the feature request:
ProcessWire currently allows you to exclude files from compilation via the exclusions
config property. However, this isn't helpful for modules. In my case, I am developing Jumplinks 2, and have opted to bundle a vendor
directory with the module itself so I need not rely on the root composer.json
and vendor
to autoload my dependencies. The main issue with doing so means that an extra module installation step is needed, which I'd like to avoid.
It would be spectacular is ProcessWire modules could define a module info option, similar to the config option described above, but relative to the root of the module. So, for example, in a module's JSON file or related method, I would include the following (or something along the lines of) to prevent compilation of anything inside the vendor directory:
{
...
"fileCompilerOptions": {
"exclusions": ["vendor"]
}
}
That exclusion would then internally map to the following, in my case, and add to the global exclusions array:
D:/<root>/site/modules/ProcessJumplinks/vendor
Note: Using /
here as PW converts to this anyway.
Why would the enhancement be useful to users?
In this particular instance, certain non-namespaced files that get copiled could cause unintended side effects. For me, vendor/illuminate/Support/helpers.php
was being compiled as it is not namespaced, and class_parents
was being converted to ProcessWire\wireClassParents
, which is something not specific to the context of the compiled file.
Having looked through FileCompiler.php
, I see the same would occur for class_implements
and that, too, could cause unintended side effects.
This is useful for developers who choose to have vendor directories inside their module packages and don't want to worry about these side effects, which could pop up at any time.
The reason this should be specified in the module info declaration is due to the fact that I should not expect my users to manually add the exclusion to their site config.
Is there an alternative to this enhancement?
As this issue may only be valid for vendor
directories, a more suitable alternative would be to add "fileCompiler": { "excludeVendor": true }
to the module's info declaration, thus not needing to declare specific directories.
However, we should give consideration to those who have dependencies stored in different directories, such as lib
.
Edge-case?
This could well be seen as an edge-case, specifically in reference to the methods being converted. Nonetheless, I think it is wise to give the developer the choice to make these exclusions on a per-module basis.