[Stimulus Bridge] Entrypoint: Allow to import aliases#1390
[Stimulus Bridge] Entrypoint: Allow to import aliases#1390Jibbarth wants to merge 1 commit intosymfony:mainfrom
Conversation
|
|
||
| const version = packageHelper.getPackageVersion('@symfony/stimulus-bridge'); | ||
| if (!semver.satisfies(version, '^3.0.0')) { | ||
| if (!semver.satisfies(version, '>3.0.0')) { |
There was a problem hiding this comment.
i had the v4.0.0 on my side, so this test wasn't triggered. That's why I changed the comparison here
|
|
||
| for (let name in controllersData.entrypoints) { | ||
| // Imported entrypoint (e.g. from node_modules) should be used as-is | ||
| if (controllersData.entrypoints[name].startsWith('@')) { |
There was a problem hiding this comment.
I am not sure about this one, only scoped-packages are supported? What if the package name is tototata? It can't define aliases?
There was a problem hiding this comment.
That's my guess yes @Kocal
This is for package.json imported from a bundle, not for a dependency imported directly in the app package.json (unless i'm wrong)
We already recommend to use the @ in the package.json name of a bundle:

The entrypoint section that package.json is read by symfony flex and added in /assets/controllers.json of the app as it.
I'm not sure of the purpose, maybe it was to be completed by a recipe that would copy that entrypoint inside assets folder to be used directly ?
By adding these line, we allow to reference to the assets from the bundle, and yes only if the package name start with @.
Maybe an other option could be "if not start by ./" but maybe it could break somewhere.
Or improve flex to add some directive telling the entrypoint added came from a bundle?
WDYT ?
I was re-working on the doc pr to expose entrypoint inside a UX bundle.
symfony/symfony-docs#21292
I didn't really like the fact that, to expose an entrypoint in webpack encore, user must add it relative to node_modules folder :
{ "name": "@acme/feature", "symfony": { "entrypoints": { "@acme/feature/entrypoint": "../node_modules/@acme/feature/entrypoint.js" } } }With that change in enableStimulusBridge, we allow to import entrypoint from a bundle like that