quasar-app-extension-auto-routing icon indicating copy to clipboard operation
quasar-app-extension-auto-routing copied to clipboard

RouterLayout should be Generated named static import instead of dynamic import for Vite.

Open composite opened this issue 3 years ago • 4 comments

Quasar with Webpack is still working without problem. but, when I using Vite, it's not working. Due to lack of supported dynamic routes on Rollup, layout will not exposed, so Quasar with Vite will render nothing. but if it generate as named dynamic static import like this:

const RouterLayout = createRouterLayout(layout => {
  switch(layout) { // or plain object or more something template that awesome...
      // user created layout files:
      case 'some': return import('layouts/some.vue');
      case 'other': return import('layouts/other.vue');
      // default layout:
      default: return import('layouts/default.vue'); // or as configure
  }
})

I think it will works like charm even using Vite. If you not excused, I'll make a pull request after test.

composite avatar Jun 22 '22 04:06 composite

Oh wonderful! Thanks for being proactive :+1:

absolutely, pr is welcome :)

ldiebold avatar Jul 15 '22 02:07 ldiebold

Coming from Nuxt, I really like this extension, but the issue raised above still seems to be unresolved. I'd prefer to use Vite over Webpack, but as it stands, I'll either have to go back to manual routing or switch to Webpack.

jpet710122 avatar Mar 24 '23 04:03 jpet710122

I tried adding @rollup/plugin-dynamic-import-vars and configuring it with import dynamicImportVars from '@rollup/plugin-dynamic-import-vars';

export default { plugins: [ dynamicImportVars({ include: ['../src/layouts/*.vue'] }) ] };

I still get the error: [vite] warning: /Users/user/Projects/memberportalq/src/router/auto-routing/index.js 4 |
5 | const RouterLayout = createRouterLayout(layout => { 6 | return import('/Users/user/Projects/memberportalq/src/layouts/' + layout + '.vue') | ^ 7 | }) 8 |
The above dynamic import cannot be analyzed by vite. See https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations for supported dynamic import formats. If this is intended to be left as-is, you can use the /* @vite-ignore */ comment inside the import() call to suppress this warning.

Plugin: vite:import-analysis File: /Users/user/Projects/memberportalq/src/router/auto-routing/index.js

jpet710122 avatar Mar 24 '23 07:03 jpet710122

Any news on that? @composite ? I can't use the plugin because of this problem.

TheCutter avatar Nov 09 '23 10:11 TheCutter