-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
What problem does this feature solve?
Currently the instructions to make vue-router@next with vue@next do not take into consideration the scenario where the vue application was generated by vite and has a module bundler such as rollup. The instructions just demonstrate that it is possible make it work with an index file that points to CDNs and has a script tag.
Trying to follow those instructions with a generated vue template and making the necessary teaks such as not pointing to the CDNs because there is already a main file that resolves those imports results in an error.
[Vue warn]: Component provided template option but runtime compilation is not supported in this build of Vue. Configure your bundler to alias "vue" to "vue/dist/vue.esm-bundler.js"
The way I managed to solve it was:
import { createApp } from 'vue/dist/vue.esm-bundler.js'
import { createRouter, createWebHashHistory } from 'vue-router'
As I didn't like that reference there I tried tweaking vite.config.js
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import alias from '@rollup/plugin-alias';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
build: {
rollupOptions: {
plugins: [
alias({
entries: [{ find: 'vue', replacement: '/node_modules/vue/dist/vue.esm-bundler.js' }]
})
]
}
}
})
But it unfortunately didn't work.
It would be really nice if vue-router@next has an official documentation describing how to make the router work in that scenario since in these days vite is gaining a lot of traction.
Thanks in advance,
If needed I can provide a repository showing the issue but it is very easy to replicate.
What does the proposed API look like?
There is no change in the api itself, just support for vite module bundler.