-
-
Notifications
You must be signed in to change notification settings - Fork 420
-
-
Notifications
You must be signed in to change notification settings - Fork 420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide "modern" microbundle build #447
Comments
Ooh, it would be really cool to support Vite! Since Inertia only supports modern browsers anyway, I personally think this would be a perfectly reasonable thing to add (especially since it doesn't increase the maintenance cost at all from what I can tell?) What do you think, @reinink? EDIT: Bookmarking for relevance/future use: https://github.com/laravel-presets/inertia/blob/main/templates/default/resources/scripts/main.ts |
Yeah I can't immediately see an ongoing maintenance burden because microbundle handles everything nicely! |
Any love for this issue? It seems to be a rather non-intrusive change and getting it working with Vite would be a real boost, since it is growing in popularity in the JS community. |
Seems reasonable to me. 👍 @sebastiandedeyne, any thoughts on this, as our resident publishing and Vite expert? |
@reinink Actually, I got this to compile properly. I needed to add the So, I am not sure if we need to do something, besides maybe documenting the extra step with the |
You can use Inertia with Vite without any additional configuration. @mindreframer are you sure the That said, I do believe we should add an ESM build to Inertia. I've opened #610 to continue this discussion. |
By using
|
According to that linked issue:
Rollup is choosing the wrong dependency for whatever reason. I'm using Inertia with Vite and not seeing any issues here. Either way, this is a Rollup or object-inspect issue, not directly related to Inertia. |
Well... I had this issue in my setup, where bundling would work, but the app would fail at runtime trying to require the |
I'm using vite with inertia + wordpress as well and it's working:
and my package.json
|
I got a similar problem when using Inertia + Vue 3 + Vite and Yarn 2+ (3.1.1 in fact). No problem when using Yarn classic (1).
package.json {
"name": "atermacao",
"packageManager": "yarn@3.1.1",
"scripts": {
"dev": "vite"
},
"devDependencies": {
"@vitejs/plugin-vue": "^2.2.0",
"vite": "^2.8.2"
},
"dependencies": {
"@inertiajs/inertia": "^0.11.0",
"@inertiajs/inertia-vue3": "^0.6.0",
"vue": "^3.2.31"
}
} vite.config.js import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
export default defineConfig(({command}) => ({
plugins: [
vue()
],
base: command === 'serve' ? '' : '/build/',
publicDir: false,
cacheDir: 'storage/vite',
resolve: {
alias: {
'@': path.resolve(__dirname, 'resources/js'),
'@@': path.resolve(__dirname, 'resources')
}
},
build: {
manifest: true,
outDir: 'public/build',
rollupOptions: {
input: 'resources/js/app.js',
},
},
})) app.js import { createApp, h } from 'vue'
import { createInertiaApp } from '@inertiajs/inertia-vue3'
createInertiaApp({
resolve: async (name) => {
return (await import(`./Pages/${name}.vue`)).default;
},
setup({ el, App, props, plugin }) {
createApp({ render: () => h(App, props) })
.use(plugin)
.mount(el)
},
}) |
Hey! Thanks so much for your interest in Inertia.js and for sharing this issue/suggestion. In an attempt to get on top of the issues and pull requests on this project I am going through all the older issues and PRs and closing them, as there's a decent chance that they have since been resolved or are simply not relevant any longer. My hope is that with a "clean slate" me and the other project maintainers will be able to better keep on top of issues and PRs moving forward. Of course there's a chance that this issue is still relevant, and if that's the case feel free to simply submit a new issue. The only thing I ask is that you please include a super minimal reproduction of the issue as a Git repo. This makes it much easier for us to reproduce things on our end and ultimately fix it. Really not trying to be dismissive here, I just need to find a way to get this project back into a state that I am able to maintain it. Hope that makes sense! ❤️ |
👋
To get inertia working with native es module build tools such as Vite, I had to add a "modern" build for all the packages.
This involves adding
"exports": "dist/index.modern.js",
& e.g."build:modern": "microbundle --format modern",
for all packagespackage.json
.An easy PR if need be, but maybe there are other things I haven't considered?
The text was updated successfully, but these errors were encountered: