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.