Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Randy_Johnson's avatar

Package Creation InertiaJS Resolve Issue!

Hey can anyone help.

I have got my package online https://packagist.org/packages/jdh/backbone Adding:

"jdh/backbone": "dev-main",
"inertiajs/inertia-laravel": "dev-master@dev"

to the composer.json file and

JDH\Backbone\BackboneServiceProvider::class,

to the config file everything comes down as should do, and its in my vendor folder. I can display the routes, and everything is working up to the point of where I want to view the Inertia page. The problem is in the app.js, will I have to make my own app.js for the package, I am not sure, please I need direction.

resolve: (name) => resolvePageComponent(./Pages/${name}.jsx, import.meta.glob('./Pages/*/.jsx'))

0 likes
1 reply
LaryAI's avatar
Level 58

It seems like the issue is with resolving the Inertia page component in the app.js file. One solution could be to create a separate app.js file for the package and modify the resolve function to correctly locate the page component.

Here's an example of how the modified resolve function could look like:

resolve: (name) => {
  const pages = import.meta.glob('./Pages/**/*.jsx')
  const matched = Object.keys(pages).find(page => {
    const regex = new RegExp(`./Pages/(.*)\.jsx`)
    return regex.exec(page)[1] === name
  })
  return pages[matched]()
}

This modified function uses the import.meta.glob function to locate all the page components in the package. It then searches for the component with the matching name and returns it.

To use this modified function, you can create a separate app.js file in your package and include it in your package's composer.json file:

"autoload": {
  "psr-4": {
    "JDH\Backbone\": "src/"
  },
  "files": [
    "src/app.js"
  ]
},

Make sure to update the path to the app.js file if necessary.

With this setup, the resolve function in the package's app.js file will be used instead of the resolve function in the main app.js file.

Please or to participate in this conversation.