reapp / reapp-routes

Simple route DSL
MIT License
34 stars 13 forks source link

require issue when using webpack #4

Closed filod closed 9 years ago

filod commented 9 years ago

say that i init app/app.js like this:

doSomething1();
require; // or router(require, ...)
doSomething2();

this makes webpack include all other files in app folder into build process, which makes a bundle file much larger than i expected. seems require should not be used as a param or standalone expression when using webpack?

natew commented 9 years ago

The dynamic requires are optional, but you'd have to use the original react-router syntax or use objects for your routes:

routes({ name: 'xx', path: '/', handler: require('xx'), children: [] })

How big is your bundle? With reapp-kit we build in everything to the bundle anyway. With the old reapp-ui template you basically used nothing but the ui and you could choose the rest.

You could check out the repo here and use that: https://github.com/reapp/starter-default/commit/e5a9b2cb98d9b35fac81daf10855bebc434d2037

But reapp is designed for building mobile apps (primarily and for now), the bundle size makes very little difference. It's the difference in ~300kb, which takes no time to load on an app.

filod commented 9 years ago

thanks for replying. i just make my app only import the module i need other than use reapp-kit, ~300KB is huge when deal with mobile browser/web.