Skip to content
This repository has been archived by the owner on Nov 17, 2022. It is now read-only.

Feat: define routes and ignore route files #69

Merged
merged 41 commits into from
Apr 14, 2022
Merged

Conversation

luhc228
Copy link
Member

@luhc228 luhc228 commented Mar 31, 2022

#60

@vercel
Copy link

vercel bot commented Mar 31, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/imsobear/ice-next/522G1md9aHG1mYDePofTnppKQtL4
✅ Preview: https://ice-next-git-feat-define-routes-imsobear.vercel.app

@luhc228 luhc228 changed the title Featdefine routes Feat: define routes and ignore route files Mar 31, 2022
// },
routes: {
ignoreFiles: ['about.tsx'],
defineRoutes: (route) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

新建个 example 吧,不要把所有 feature 都放到一个 example 里面

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -89,14 +75,31 @@ async function createService({ rootDir, command, commandArgs }: CreateServiceOpt
},
});
await ctx.resolveConfig();
const { userConfig: { routes: routesConfig } } = ctx;
Copy link
Collaborator

Choose a reason for hiding this comment

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

routes 不存在的情况

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

...renderData,
...routesRenderData,
}));
dataCache.set('routes', JSON.stringify(routesRenderData));
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里可以顺便优化下仅缓存 manifest 信息

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -49,7 +52,7 @@ const getWatchEvents = (options: Options): WatchEvent[] => {
];

const watchConfigFile: WatchEvent = [
new RegExp(configFile),
new RegExp(configFile as string),
Copy link
Collaborator

Choose a reason for hiding this comment

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

从 ctx 类型上解决

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed


export function generateRoutesInfo(rootDir: string) {
const routeManifest = generateRouteManifest(rootDir);
export function generateRoutesInfo(rootDir: string, routesConfig?: UserConfig['routes']) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

routesConfig 为 undefined 的情况

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

packages/route-manifest/src/index.ts Outdated Show resolved Hide resolved
} else {
pathList.push(route.path || '/');
pathList.push(path.join('/', parentPath, route.path || ''));
Copy link
Contributor

Choose a reason for hiding this comment

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

SSR 的时候需要特殊处理吗?

Copy link
Member Author

Choose a reason for hiding this comment

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

需要的,生成的路由 manifest 中路由第一个字符不是 /,这里需要加上 / 否则不能 match 上

@luhc228 luhc228 merged commit d19f21e into release-next Apr 14, 2022
@luhc228 luhc228 deleted the feat/define-routes branch April 14, 2022 09:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants