Skip to content

The "lazyness" of symfony/ux-react isn't true? Why my React imports are loaded for every request? #1177

Closed
@gremo

Description

@gremo

Given this controllers.json (notice the lazy):

{
  "controllers": {
    "@symfony/ux-react": {
      "react": {
        "enabled": true,
        "fetch": "lazy"
      }
    }
  },
  "entrypoints": []
}

The controller symfony--ux-react--react itself will in fact load lazly:

image

The main problem is that every import inside alll React components is loaded on every page request, not only on the page that uses the symfony--ux-react--react controller.

Take the following. It's a page that doesn't load the symfony--ux-react--react at all. I've highlighted the network tab, where you can see that:

  • vendors-node_modules_symfony_stimulus-bridge_dist_index_js-node_modules_symfony_ux-react_dist-2a274e.css: which is used by my BusinessList.jsx component (not loaded in this page)
  • vendors-node_modules_mapbox-gl_dist_mapbox-gl_js.js: used by my BusinessMap.jsx component (not loaded in this page)

image

The question is: is this the intended behaviour of symfony/ux-react, or my fault, or maybe a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions