Skip to content
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

[AssetMapper] Fix file deleting errors & remove nullable MappedAsset on JS import #52331

Merged
merged 1 commit into from Oct 28, 2023

Conversation

weaverryan
Copy link
Member

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues None
License MIT

Hi!

This PR accomplishes 2 things:

A) If app.js imported foo.js, and you deleted foo.js, you got a big, unobvious error from Symfony. This was because the MappedAsset behind app.js remained cached, including the JavaScriptImport for foo.js. So then, the system was surprised when app.js had this JavaScriptImport... but the underlying file didn't exist. The fix was to add a FileExistenceResource for foo.js. We don't need to update the app.js cache if foo.js changes, but we DO need to update it if foo.js no longer exists (so that we can create a new MappedAsset without the import).

B) Upon looking at this, previously, JavaScriptImport.asset was nullable. That doesn't make sense, now that all vendor files are downloaded locally and exist in the AssetMapper. The MappedAsset.javascriptImports are used to implicitly add importmap entries for relative assets (which already required a MappedAsset) and to preload other dependencies. Previously, we added a JavaScriptImport with a null asset for things like absolute imports (`import 'https://example.com/foo.js') or bare imports that we couldn't find. But we can't preload things like this anyway - or we shouldn't bother to in the case of an absolute assets.

For (B), trying to tighten things up and do LESS, if we don't need it.

Cheers!

@fabpot fabpot force-pushed the asset-mapper-fix-file-deletes branch from 300f157 to f1708aa Compare October 28, 2023 23:40
@fabpot
Copy link
Member

fabpot commented Oct 28, 2023

Thank you @weaverryan.

@fabpot fabpot merged commit 6fad9a4 into symfony:6.4 Oct 28, 2023
2 of 9 checks passed
@weaverryan weaverryan deleted the asset-mapper-fix-file-deletes branch October 29, 2023 01:54
xabbuh added a commit that referenced this pull request Oct 29, 2023
This PR was merged into the 6.4 branch.

Discussion
----------

[AssetMapper] Fixing merge

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | None
| License       | MIT

Fixing the merge of #52323, #52331 and #52349

Also tested on a real project locally to verify the moving pieces :).

Thanks!

Commits
-------

99d5cbb [AssetMapper] Fixing merge from multiple PR's
This was referenced Oct 29, 2023
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.

None yet

4 participants