• I’m building a React-based admin dashboard and trying to use the @wordpress/route package as documented:
    https://developer.wordpress.org/block-editor/reference-guides/packages/packages-route/

    When running npm start, the build correctly lists @wordpress/route as a dependency. However, when enqueuing the compiled script in PHP with the generated dependencies, I encounter an issue because @wordpress/route is not available as a WordPress-provided script handle.

    At runtime, the script is enqueued with dependencies similar to:

    • react
    • react-dom
    • react-jsx-runtime
    • wp-element
    • wp-route (missing)

    Since wp-route does not appear to be registered by WordPress core, the script fails to load.

    I wanted to check whether I’m missing a required step or configuration:

    • Is @wordpress/route expected to be registered by WordPress core as wp-route?
    • Or is there a recommended way to handle this dependency when enqueuing admin scripts?

    If there’s an intended setup or best practice for this scenario, I’d appreciate any guidance.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • ivy125cordes

    (@ivy125cordes)

    Hello,
    The @wordpress/route package is primarily an internal utility for the Block Editor and, unlike core packages like wp-element or wp-data, it is not registered as a public script handle in WordPress core. Because there is no wp-route handle available in the WordPress environment, your script fails when the dependency script loader looks for it. To resolve this, you should update your build configuration (typically webpack.config.js) to treat @wordpress/route as a bundled dependency rather than an external one. By removing it from the “externals” list or using the @wordpress/scripts default configuration with a custom override, the nicview login package code will be compiled directly into your JavaScript bundle instead of being excluded in favor of a non-existent global variable.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.