Skip to content

[AssetMapper] Allowing circular references in JavaScriptImportPathCompiler #52323

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

Merged

Conversation

weaverryan
Copy link
Member

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

Hi!

In AssetMapper, we throw a CircularAssetsException if you ask for the app.js asset, but it's still being created. This circular situation only happens via asset compilers: if, while compiling app.js, we ask for other.js... and then while compiling that, we ask for app.js.

However, JS modules do allow for circular references - e.g. app.js imports other.js which imports app.js. Before this PR, this situation would trigger the CircularAssetsException. After, it is handled correctly. JavaScriptImportPathCompiler calls $assetMapper->getAsset() only to populate the MappedAsset.javaScriptImports property. So, allowing for the half-created MappedAsset is safe here: we do not use any of the not-yet-populated properties.

Cheers!

@carsonbot carsonbot added this to the 6.4 milestone Oct 27, 2023
@weaverryan weaverryan force-pushed the asset-mapper-allow-circular-workaround branch from ec9e073 to 2f98cb3 Compare October 27, 2023 18:47
@fabpot
Copy link
Member

fabpot commented Oct 28, 2023

Thank you @weaverryan.

@fabpot fabpot force-pushed the asset-mapper-allow-circular-workaround branch from 2f98cb3 to b0953a4 Compare October 28, 2023 23:44
@fabpot fabpot merged commit 2ccdfbc into symfony:6.4 Oct 28, 2023
@weaverryan weaverryan deleted the asset-mapper-allow-circular-workaround 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.

3 participants