Skip to content

[Stimulus Bridge] Entrypoint: Allow to import aliases#1390

Open
Jibbarth wants to merge 1 commit intosymfony:mainfrom
Jibbarth:feature/stimulus-bridge-external-entrypoint
Open

[Stimulus Bridge] Entrypoint: Allow to import aliases#1390
Jibbarth wants to merge 1 commit intosymfony:mainfrom
Jibbarth:feature/stimulus-bridge-external-entrypoint

Conversation

@Jibbarth
Copy link

Q A
Bug fix? no
New feature? yes
Deprecations? no
Issues Fix #...
License MIT

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

// acme-feature-bundle/assets/package.json

    {
        "name": "@acme/feature",
        "symfony": {
            "entrypoints": {
                "@acme/feature/entrypoint": "@acme/feature/entrypoint.js"
            }
        }
    }

@carsonbot carsonbot added Feature New Feature Status: Needs Review Needs to be reviewed labels Feb 15, 2026

const version = packageHelper.getPackageVersion('@symfony/stimulus-bridge');
if (!semver.satisfies(version, '^3.0.0')) {
if (!semver.satisfies(version, '>3.0.0')) {
Copy link
Author

Choose a reason for hiding this comment

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

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('@')) {
Copy link
Member

@Kocal Kocal Feb 19, 2026

Choose a reason for hiding this comment

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

I am not sure about this one, only scoped-packages are supported? What if the package name is tototata? It can't define aliases?

Copy link
Author

Choose a reason for hiding this comment

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

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:
image

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 ?

@carsonbot carsonbot added Status: Needs Work Additional work is needed and removed Status: Needs Review Needs to be reviewed labels Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature New Feature Status: Needs Work Additional work is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants