preactjs/preact-cli

Automatic code splitting for nested routes

Open

#690 创建于 2019年1月4日

在 GitHub 查看
 (3 评论) (0 反应) (0 负责人)JavaScript (415 fork)batch import
enhancementhelp wanted

仓库指标

Star
 (4,674 star)
PR 合并指标
 (30 天内没有已合并 PR)

描述

Do you want to request a feature or report a bug?

Feature

What is the current behaviour?

Automatic code splitting works perfectly for top-level routes like src/components/blog/index.js but it doesn't work for nested routers, i.e. src/components/blog/first-post/index.js or something like src/components/blog/first-post.js. Code from those routers is bundled in the main bundle. I'm not sure if this is expected behavior.

What is the expected behaviour?

Automatic code splitting for every route, not just top-level index.js.

If this is a feature request, what is motivation or use case for changing the behaviour?

I think it's a common way to organize nested routes in subdirectories. At least in tools like Gatsby and Next.js.

Example:

src
├── components
├── routes
│   ├── about
│   │   ├── index.js
│   │   └── style.css
│   ├── blog
│   │   ├── hello-world-post
│   │   │   └── index.js
│   │   ├── another-amazing-post
│   │   │   └── index.js
│   │   └── index.js
│   ├── contact
│   │   ├── foo
│   │   │   ├── bar
│   │   │   │   └── index.js
│   │   │   └── index.js
│   │   └── index.js
│   ├── home
│   │   ├── index.js
│   │   └── style.css

贡献者指南