Skip to content

Commit

Permalink
feat: add internal name in virtual files as comments
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Feb 16, 2023
1 parent 5c359c9 commit 326156d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
12 changes: 6 additions & 6 deletions e2e/__snapshots__/routes.spec.ts.snap
Expand Up @@ -24,7 +24,7 @@ export const routes = [
},
{
path: '/articles',
/* no name */
/* internal name: '/articles' */
/* no component */
children: [
{
Expand All @@ -43,12 +43,12 @@ export const routes = [
},
{
path: '/nested',
/* no name */
/* internal name: '/nested' */
/* no component */
children: [
{
path: 'folder',
/* no name */
/* internal name: '/nested/folder' */
/* no component */
children: [
{
Expand All @@ -59,12 +59,12 @@ export const routes = [
},
{
path: 'should',
/* no name */
/* internal name: '/nested/folder/should' */
/* no component */
children: [
{
path: 'work',
/* no name */
/* internal name: '/nested/folder/should/work' */
/* no component */
children: [
{
Expand All @@ -83,7 +83,7 @@ export const routes = [
},
{
path: '/optional',
/* no name */
/* internal name: '/optional' */
/* no component */
children: [
{
Expand Down
26 changes: 13 additions & 13 deletions src/codegen/__snapshots__/generateRouteRecords.spec.ts.snap
Expand Up @@ -17,7 +17,7 @@ exports[`generateRouteRecord > adds children and name when folder and component
},
{
path: '/b',
/* no name */
/* internal name: '/b' */
/* no component */
children: [
{
Expand Down Expand Up @@ -47,7 +47,7 @@ exports[`generateRouteRecord > correctly names index.vue files 1`] = `
},
{
path: '/b',
/* no name */
/* internal name: '/b' */
/* no component */
children: [
{
Expand Down Expand Up @@ -77,12 +77,12 @@ exports[`generateRouteRecord > generate custom imports 1`] = `
},
{
path: '/nested',
/* no name */
/* internal name: '/nested' */
/* no component */
children: [
{
path: 'file',
/* no name */
/* internal name: '/nested/file' */
/* no component */
children: [
{
Expand Down Expand Up @@ -120,12 +120,12 @@ exports[`generateRouteRecord > generate static imports 1`] = `
},
{
path: '/nested',
/* no name */
/* internal name: '/nested' */
/* no component */
children: [
{
path: 'file',
/* no name */
/* internal name: '/nested/file' */
/* no component */
children: [
{
Expand Down Expand Up @@ -260,7 +260,7 @@ exports[`generateRouteRecord > names > creates multi word names 1`] = `
},
{
path: '/some-nested',
/* no name */
/* internal name: '/some-nested' */
/* no component */
children: [
{
Expand Down Expand Up @@ -290,7 +290,7 @@ exports[`generateRouteRecord > names > creates single word names 1`] = `
},
{
path: '/users',
/* no name */
/* internal name: '/users' */
/* no component */
children: [
{
Expand Down Expand Up @@ -364,7 +364,7 @@ exports[`generateRouteRecord > nested children 1`] = `
"[
{
path: '/a',
/* no name */
/* internal name: '/a' */
/* no component */
children: [
{
Expand All @@ -389,7 +389,7 @@ exports[`generateRouteRecord > nested children 1`] = `
},
{
path: '/b',
/* no name */
/* internal name: '/b' */
/* no component */
children: [
{
Expand Down Expand Up @@ -419,7 +419,7 @@ exports[`generateRouteRecord > nested children 2`] = `
"[
{
path: '/a',
/* no name */
/* internal name: '/a' */
/* no component */
children: [
{
Expand All @@ -444,7 +444,7 @@ exports[`generateRouteRecord > nested children 2`] = `
},
{
path: '/b',
/* no name */
/* internal name: '/b' */
/* no component */
children: [
{
Expand Down Expand Up @@ -505,7 +505,7 @@ exports[`generateRouteRecord > removes trailing slashes 1`] = `
},
{
path: '/users',
/* no name */
/* internal name: '/users' */
/* no component */
children: [
{
Expand Down
4 changes: 3 additions & 1 deletion src/codegen/generateRouteRecords.ts
Expand Up @@ -30,7 +30,9 @@ ${node
const routeRecord = `${startIndent}{
${indentStr}path: '${node.path}',
${indentStr}${
node.value.components.size ? `name: '${node.name}',` : '/* no name */'
node.value.components.size
? `name: '${node.name}',`
: `/* internal name: '${node.name}' */`
}
${
// component
Expand Down

0 comments on commit 326156d

Please sign in to comment.