-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[AssetMapper] Always downloading vendor files #51786
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
Hey! To help keep things organized, we don't allow "Draft" pull requests. Could you please click the "ready for review" button or close this PR and open a new one when you are done? Note that a pull request does not have to be "perfect" or "ready for merge" when you first open it. We just want it to be ready for a first review. Cheers! Carsonbot |
42781ed
to
f9f357c
Compare
This is ready to go! And important for 6.4. Test failures look unrelated. |
eceb490
to
94082d6
Compare
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
Outdated
Show resolved
Hide resolved
src/Symfony/Component/AssetMapper/Command/ImportMapInstallCommand.php
Outdated
Show resolved
Hide resolved
f26669d
to
7722e10
Compare
Ready to go - test failures are expected (due to FWBundle not using the code from this PR) |
Rebase needed |
732c049
to
ac14da5
Compare
// https://regex101.com/r/MDz0bN/1 | ||
$regex = '/(?:(?P<registry>[^:\n]+):)?((?P<package>@?[^=@\n]+))(?:@(?P<version>[^=\s\n]+))?(?:=(?P<alias>[^\s\n]+))?/'; | ||
// https://regex101.com/r/z1nj7P/1 | ||
$regex = '/((?P<package>@?[^=@\n]+))(?:@(?P<version>[^=\s\n]+))?(?:=(?P<alias>[^\s\n]+))?/'; |
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.
The registry is a jspm concept, so I'm removing it.
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.
I love it!
src/Symfony/Component/AssetMapper/ImportMap/ImportMapConfigReader.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/AssetMapper/Command/ImportMapInstallCommand.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/AssetMapper/ImportMap/RemotePackageDownloader.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/AssetMapper/ImportMap/RemotePackageDownloader.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/AssetMapper/ImportMap/RemotePackageDownloader.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/AssetMapper/ImportMap/RemotePackageDownloader.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/AssetMapper/ImportMap/Resolver/JsDelivrEsmResolver.php
Outdated
Show resolved
Hide resolved
Thanks for the check! Changes made |
src/Symfony/Component/AssetMapper/ImportMap/RemotePackageDownloader.php
Outdated
Show resolved
Hide resolved
bbacaee
to
98e9cd6
Compare
src/Symfony/Component/AssetMapper/ImportMap/Resolver/JsDelivrEsmResolver.php
Outdated
Show resolved
Hide resolved
e3a4956
to
18e4200
Compare
Thank you @weaverryan. |
…osted locally easily (weaverryan) This PR was squashed before being merged into the 6.4 branch. Discussion ---------- [AssetMapper] Put importmap in polyfill so it can be hosted locally easily | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #51302 | License | MIT Note: Built on top of #51786 In #51302, it was asked to allow the polyfill to be an asset mapper path. We could do that, but it would still require the user to "manage" this vendor file locally - i.e. commit it into their repository. So this PR goes a bit further and requires your polyfill to be an item in `importmap.php`. That's a bit odd, but because of #51786, it allows the JS package to be downloaded like any other JS package. The item is actually removed from the `importmap` before it's finally dumped. So the small oddity of having this item in `importmap.php` makes a really nice DX. Cheers! Commits ------- d2014eb [AssetMapper] Put importmap in polyfill so it A3DB can be hosted locally easily
… (weaverryan) This PR was squashed before being merged into the 6.4 branch. Discussion ---------- [AssetMapper] Warn of missing or incompat dependencies | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | None | License | MIT Hi! The aim of the `importmap.php` system is to be a simple way to manage your JS dependencies. But to make it robust enough for production use, it does need a few things - like the `importmap:audit` command in #51650. This PR adds a check, during `importmap:require` and `importmap:update`, that reports any missing dependencies or dependencies with invalid versions. This is necessary so that, if package `A` requires package `B`, their versions don't "drift" over time without you being aware (e.g. you update package `A` to v3 but keep package `B` at v1, even though v3 of `A` requires v2 of `B`). <img width="1266" alt="Screenshot 2023-10-04 at 2 44 04 PM" src="https://github.com/symfony/symfony/assets/121003/3901a070-d092-494a-a7cb-3bfe5d5a99f9"> Built on top of #51786. Cheers! Commits ------- 42dfb9a [AssetMapper] Warn of missing or incompat dependencies
… obsolete (freerich) This PR was squashed before being merged into the 6.4 branch. Discussion ---------- [AssetMapper] Remove `--download` option that has become obsolete Minor adjustments corresponding to symfony/symfony#51786 Commits ------- 9f1f17f [AssetMapper] Remove `--download` option that has become obsolete
Hi!
I discovered a few problems with our CDN set up:
A) The
jsdelivr
CDN uses imports statements with specific versions - e.g.import{Controller as t}from"/npm/@hotwired/stimulus@3.2.1/+esm";
. This could cause the same dependency to be downloaded (at different verisons) every time.B) The
jspm
CDN has correct bare imports - e.g.import '@hotwired/stimulus';
. However, to they also include some "in-package" relative imports - e.g.import '../other-file.js'
. That is ok on the CDN, but to support local download, it means we ALSO need to download those files. This is possible, but adds quite a bit of complexity and would probably require animportmap.php.local
file so we could keep track of all of the files needed for somefoo-bar
package.Solution
Talking with @nicolas-grekas, we're going to change AssetMapper to "download-only" - like Composer, npm, etc. The
importmap.php
file will change to look like:We will exclusively use
jsdelivr
as the "backend", as it avoids the "in-package" relative imports. So, every package == 1 file.To download the remote packages, run:
This downloads everything into an
assets/vendor/
directory (which will be ignored by git).Other Notable Items
Added
MappedAsset.isVendor
property, which is a simple check to see if the file lives inassets/vendor/
. If it does, we still run the compilers, but we can silence invalid import warnings.Mapped assets ending in
.php
are excluded from AssetMapper. There could be edge-cases where you don't want this, but it felt like a safer default, and allowed me to easily NOT expose the newvendor/assets/installed.php
file.TODO