Skip to content

[AssetMapper] Better public without digest #50232

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

Conversation

weaverryan
Copy link
Member

Q A
Branch? 6.3
Bug fix? no
New feature? yes
Deprecations? no
Tickets None
License MIT
Doc PR Not needed

We have a MappedAsset::getPublicPathWithoutDigest() method, which would return something like /assets/file2.js. This, sort of odd method, is super useful, for example, when generating the importmap, where we want to communicate to the browser that when it searches for /assets/file2.js (e.g. because inside assets/file1.js there is an import './file1.js'), here it should use the digested path - e.g.

'/assets/file2.js' => '/assets/file2.1234abcd.js',

Anyway, the way that I calculated this originally was a little sketchy. In truth, we have this info very easily in AssetMapper, so now we pass it in. This also allows an "asset compiler" to figure out which "directory" the final asset will be in, which isn't possible with "public path" as it's still being generated. That little nice detail will be needed in StimulusBundle :).

Cheers!

}

return $this->extensionsMap[$extension];
return $this->extensionsMap[$extension] ?? null;
Copy link
Member Author

Choose a reason for hiding this comment

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

This is unrelated. I had a file that mentioned a sourcemap - so foo.js.map - and the system exploded because we didn't know the mime type of .map. The mime type is only important for (A) the dev server to return that asset with the correctContent-Type and (B) for asset compilers, if they rely on the mime type. So I think this is a reasonable thing to do.

@weaverryan weaverryan force-pushed the asset-mapper-better-public-without-digest branch from 11641cb to 4dbdca0 Compare May 3, 2023 18:16
@nicolas-grekas nicolas-grekas force-pushed the asset-mapper-better-public-without-digest branch from 4dbdca0 to 54ebd6d Compare May 5, 2023 15:57
@nicolas-grekas
Copy link
Member

Thank you @weaverryan.

@nicolas-grekas nicolas-grekas merged commit a0a7524 into symfony:6.3 May 5, 2023
@weaverryan weaverryan deleted the asset-mapper-better-public-without-digest branch May 5, 2023 16:46
@fabpot fabpot mentioned this pull request May 7, 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.

4 participants