jcoreio / crater

Meteor/Webpack/React SSR app skeleton that runs your app code outside of Meteor Isobuild
ISC License
82 stars 10 forks source link

Build server with webpack in development #151

Closed jthomaschewski closed 7 years ago

jthomaschewski commented 7 years ago

I'm wondering if it's possible (and useful) to also use webpack for the server files in development. This would add the possibility of using TS-Loaders for language support and other things.

I'm especially interested in getting crater to work with Typescript. This works fine for client code but I'm struggling in getting this to work for server code as well.

Has anyone got this working and is it worth the effort? I'm worried that bundling server code for webpack might result in poor build performance (many small modules vs. 1 huge bundle...).

Despite performance - are there other reasons for skipping webpack for server in dev?

jedwards1211 commented 7 years ago

@jbbr it already webpacks up many of the server-side files, though not all. I inherited this from Meatier (mainly to make it possible to import CSS files, though that's no longer necessary). I regret the complexity. I should probably just webpack all or none of the server-side code.

Using webpack on the server makes debugging your code or build toolchain problems is much more complicated. In other projects I avoid webpacking server code if I can.

Surely there's a way of getting Typescript support without using Webpack? Can Typescript not compile all your Typescript files over to plain JS files?

jthomaschewski commented 7 years ago

@jedwards1211 you are probably right. Thanks for your tips! I got it working after fiddling around for about an hour. I configured typescript to emit JS to the build/ directory and spawned the typescript watcher for the server files automatically in the start script.

I published this if others are interested: https://github.com/jbbr/crater/tree/webpack2-typescript

It's not polished and not everything is working and tested. But it's possible to use TypeScript in both client and server code with proper source mapping and debugging (debugger crashes after code changes when debugging server).

Now I'm interested in getting my unit tests running - this seems to be something not yet covered by crater (only integration tests)

jedwards1211 commented 7 years ago

Cool! Yeah the integration tests in crater are only designed to test that all of its scripts and Meteor integration work.