Skip to content

[AssetMapper] Make asset-map:compile clean assets in debug mode, require --force to generate them #59073

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

Closed
wants to merge 1 commit into from

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Dec 2, 2024

Q A
Branch? 7.3
Bug fix? no
New feature? yes
Deprecations? no
Issues -
License MIT

Related to #59072, the goal is to improve the DX and allow adding the command to the default recipe.

This doesn't fully fix the issue #59072 - a cache warmer would be required for a full DX improvement.


foreach ($this->assetMapper->allAssets() as $asset) {
if (is_file($publicDir.'/'.$asset->publicPath)) {
unlink($publicDir.'/'.$asset->publicPath);
Copy link
Contributor

@chadyred chadyred Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, the FileSystem component could be used here ? (With exists and remove functions) ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not without reasons. What would be yours?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, it handles issues in case of errors like "impossible" to remove a directory and raise an IOException well formatted and exists handle cases like PHP_MAXPATHLEN, I think the lib is made to ease developer life, isn't it ? :)

@OskarStark OskarStark changed the title [AssetMapper] Make "asset-map:compile" clean assets in debug mode, require --force to generate them [AssetMapper] Make asset-map:compile clean assets in debug mode, require --force to generate them Dec 7, 2024
Comment on lines +7 to +9
* Make `asset-map:compile` remove assets in debug mode
* Add `--force` to the `asset-map:compile` command to make it generate assets in debug mode
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would not have been easier to get / use with an option "--purge" + keeping the current behaviour ?

A compile command that clear files feels very weird .. using different arguments to do the same thing also 🤷

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My reasoning is that in dev mode you don't want the assets to block dynamic generation, yet this is the default right now, and this serves no DX purpose.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current DX can be improved for users after they compile assets locally, yes.

But this PR can also make things worse for all the others.. Two opposite behaviour between debug and not debug.. i'm not sure this will be a DX win. 🤷‍♂️

Two commands: asset-map:compile and asset-map:purge (or asset-map:clear) feels easier to explain, document, use.

Just a personal feeling.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please explain what you mean by "worse".
The behavior I'm proposing here is not opposite, it's consistent with what each mode (debug/non-debug) needs to work. Adding a myriad of commands for fine grained operations will just make things more complex, aka worse, when we know what the behavior should be to make things Just Work (TM)

@smnandre
Copy link
Member

My answer here to explain my opinion on these PRs: compiled is not only cached
#59072 (comment)

@smnandre
Copy link
Member

Implémentation comment: doing assetMapper->allAsset() will rebuild all the assets (as the config has been removed) to then delete them. And wont delete any asset that changed.

Also without the event beeing triggered the result will change (at least a bit).

You way need to delete all the folder (?) or use the manifest generated (easier and quicker but other files can be in here too)

@nicolas-grekas
Copy link
Member Author

Let me come back later on this topic.

@nicolas-grekas nicolas-grekas deleted the am-compile-debug branch February 19, 2025 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants