Skip to content
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

fix: use single alias for reused components on different paths #280

Closed

Conversation

PindaPixel
Copy link
Contributor

@PindaPixel PindaPixel commented Dec 27, 2023

See: #262
Fix #284

I must add that I have not tested this extensively, so I have no idea whether this causes bugs on other ends.
I'm also unsure how to write a good unit test for this case.

Before:

import _page_0 from "/src/modules/Base/BaseLayout.vue"
import { default as _page_1, default as _page_3, default as _page_4, default as _page_5 } from "/src/router/components/NotFound.vue"
import _page_2 from "/src/modules/Account/Pages/AccountLayout.vue"
import _page_3 from "/src/modules/Reports/Pages/ReportsLayout.vue"
import _page_4 from "/src/modules/Account/Pages/Login@/LoginLayout.vue"

export const routes = [
  {
    path: '/',
    name: 'base-layout',
    component: _page_0,
    children: [
      {
        path: '',
        name: 'home',
        component: () => import("/src/modules/Base/HomePage.vue"),
        /* no children */
      },
      {
        path: ':index(.*)',
        name: 'not-found',
        component: _page_1,
        /* no children */
      },
      {
        path: 'account',
        name: 'account-layout',
        component: _page_2,
        children: [
          {
            path: '',
            name: 'account',
            component: () => import("/src/modules/Account/Pages/AccountPage.vue"),
            /* no children */
          },
          {
            path: ':index(.*)',
            name: 'account/not-found',
            component: _page_3,
            /* no children */
          }
        ],
      },
      {
        path: 'check',
        /* internal name: 'check' */
        /* no component */
        children: [
          {
            path: 'reports',
            name: 'check/reports-layout',
            component: _page_3,
            children: [
              {
                path: '',
                name: 'check/reports',
                component: () => import("/src/modules/Reports/Pages/ReportsPage.vue"),
                /* no children */
              },
              {
                path: ':index(.*)',
                name: 'check/reports/not-found',
                component: _page_4,
                /* no children */
              },
              {
                path: 'capacity',
                /* internal name: 'check/reports/capacity' */
                /* no component */
                children: [
                  {
                    path: '',
                    name: 'check/reports/capacity',
                    component: () => import("/src/modules/Reports/Pages/Capacity/CapacityPage.vue"),
                    /* no children */
                  }
                ],
              }
            ],
          }
        ],
      }
    ],
  },
  {
    path: '/account/login',
    name: 'account/login-layout',
    component: _page_4,
    children: [
      {
        path: '',
        name: 'account/login',
        component: () => import("/src/modules/Account/Pages/Login@/LoginPage.vue"),
        /* no children */
      },
      {
        path: ':index(.*)',
        name: 'account/login/not-found',
        component: _page_5,
        /* no children */
      }
    ],
  }
]

After:

import _page_0 from "/src/modules/Base/BaseLayout.vue"
import _page_1 from "/src/router/components/NotFound.vue"
import _page_2 from "/src/modules/Account/Pages/AccountLayout.vue"
import _page_3 from "/src/modules/Reports/Pages/ReportsLayout.vue"
import _page_4 from "/src/modules/Account/Pages/Login@/LoginLayout.vue"

export const routes = [{
    path: '/',
    name: 'base-layout',
    component: _page_0,
    children: [{
        path: '',
        name: 'home',
        component: ()=>import("/src/modules/Base/HomePage.vue"),
        /* no children */
    }, {
        path: ':index(.*)',
        name: 'not-found',
        component: _page_1,
        /* no children */
    }, {
        path: 'account',
        name: 'account-layout',
        component: _page_2,
        children: [{
            path: '',
            name: 'account',
            component: ()=>import("/src/modules/Account/Pages/AccountPage.vue"),
            /* no children */
        }, {
            path: ':index(.*)',
            name: 'account/not-found',
            component: _page_1,
            /* no children */
        }],
    }, {
        path: 'check',
        /* internal name: 'check' */
        /* no component */
        children: [{
            path: 'reports',
            name: 'check/reports-layout',
            component: _page_3,
            children: [{
                path: '',
                name: 'check/reports',
                component: ()=>import("/src/modules/Reports/Pages/ReportsPage.vue"),
                /* no children */
            }, {
                path: ':index(.*)',
                name: 'check/reports/not-found',
                component: _page_1,
                /* no children */
            }, {
                path: 'capacity',
                /* internal name: 'check/reports/capacity' */
                /* no component */
                children: [{
                    path: '',
                    name: 'check/reports/capacity',
                    component: ()=>import("/src/modules/Reports/Pages/Capacity/CapacityPage.vue"),
                    /* no children */
                }],
            }],
        }],
    }],
}, {
    path: '/account/login',
    name: 'account/login-layout',
    component: _page_4,
    children: [{
        path: '',
        name: 'account/login',
        component: ()=>import("/src/modules/Account/Pages/Login@/LoginPage.vue"),
        /* no children */
    }, {
        path: ':index(.*)',
        name: 'account/login/not-found',
        component: _page_1,
        /* no children */
    }],
}]

@posva posva changed the base branch from main to refactor/create-define-loader January 4, 2024 09:36
Copy link
Owner

@posva posva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot, now I understand what you meant! I will fix locally the lint errors and add a test

@posva
Copy link
Owner

posva commented Jan 4, 2024

I merged this locally as I couldn't push

@posva posva closed this Jan 4, 2024
@posva posva mentioned this pull request Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants