-
Notifications
You must be signed in to change notification settings - Fork 8
feat: Add an optional disableDependencyExtraction() method
#68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add an optional disableDependencyExtraction() method
#68
Conversation
|
I'm not sure about the strategy, yet another configurable field. If we could have the I'm not that confided we can approach a change in the default type for that field, though, looking at the process I'm worrying about the different ways the Assets instances can be passed here and there and the fact that, the resolution strategy can change at runtime right after the asset as been configured and already shared or, I can query for a field e.g. I'm not saying I don't like the concept but I don't trust the execution, to me disabling the Dependencies Extraction should be something happening at the beginning of the instantiation of an Asset object and should never change. |
|
Thanks for the feedback @widoz
Having such implicit behavior (
I share the concern about runtime mutation, but the same applies to other You currently have the exact same flaw with $asset->version(); // Triggers https://github.com/inpsyde/assets/blob/9bf2a427270a3c803544f807f4b32fe10d8c834b/src/BaseAsset.php#L140-L145
// Later on/elsewhere
$asset->disableAutodiscoverVersion();
echo $asset->version();
// 1764620994 (filemtime)
I understand your concerns but I tried to stick to the current library design and not introduce breaking changes. I tend to pick consistency over improvement when the latter implies large code refactoring. Would a |
|
Hi @nlemoine, forgive me for the late reply.
Well, no the internal logic would change the value to
That's true, but a wrong script version would not break the script from being enqueued, not having deps is a different problem. This leads me to your other comment
Yes, I would prefer that, and we could do cc @Chrico |
93cc50f to
9f0686c
Compare
|
Ciao @widoz, I moved the flag to After a second thought on this, I think the dependency extraction should probably check for files without globing. Since filenames are predictable, a loop of file checks would probably be more efficient. But that will be for a later PR. |
|
Hi @nlemoine changes lgtm, can you also add them to the |
9f0686c to
a9ed329
Compare
Add a `dependencyExtractionEnabled` property to `Script` & `ScriptModule` constructor that will disable automatic dependency extraction if set to `false`
a9ed329 to
7130822
Compare
widoz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Merged, thank you @nlemoine |
|
Grazie @widoz ! |
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Adds ability to disable automatic dependency extraction file lookups
What is the current behavior? (You can also link to an open issue here)
Dependency extraction always performs I/O operations (DirectoryIterator scans, file reads) to search for .asset.json/.asset.php files, even when not needed. Which can lead to (minor) performance issues.
What is the new behavior (if this is a feature change)?
Users can disable dependency extraction lookups for better performance when manually managing dependencies:
Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
No. Dependency extraction remains enabled by default. This is an opt-in performance optimization.
I'll update the docs if you're ok with that change.