fix: React Refresh has trouble inferring router exports
This commit is contained in:
parent
c5befc3965
commit
07b64dc217
|
@ -1,4 +1,4 @@
|
|||
import {resolve} from 'path';
|
||||
import {join, resolve} from 'path';
|
||||
|
||||
import {register} from 'react-refresh/runtime';
|
||||
|
||||
|
@ -83,8 +83,7 @@ export async function createRoutesFromFiletree({importer, paths, resolver}) {
|
|||
const last = parts[i + 1];
|
||||
// Non-index is a sibling, create if necessary.
|
||||
if ('index' !== last) {
|
||||
const offset = '/' === parts[i] ? 1 : 0;
|
||||
const nestedPath = segments.slice(i + offset).join('/');
|
||||
const nestedPath = join(...segments.slice(i));
|
||||
route = walk.find(({path}) => nestedPath === path);
|
||||
if (!route) {
|
||||
route = {path: nestedPath};
|
||||
|
|
|
@ -5,7 +5,7 @@ import {createRoutesFromContext} from '@flecks/react/router';
|
|||
it('does not nest siblings', async () => {
|
||||
const routes = await createRoutesFromContext(require.context('./filetree/siblings'));
|
||||
expect(routes)
|
||||
.to.deep.equal([{path: '/', name: 'index'}, {path: 'test', name: 'sibling'}]);
|
||||
.to.deep.equal([{path: '/', name: 'index'}, {path: '/test', name: 'sibling'}]);
|
||||
});
|
||||
|
||||
it('does nest siblings under parent', async () => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user