node.js - ES6 React server-side rendering, how to import a React Component? -
i'm transpiling es6 es5.
- babeljs nodejs express server files , server-side rendering output directory build/server/.
- browserify + babelify reactcomponents output build/client/bundle.js file
when trying import react component build/client/bundle.js build/server/ file app crashes because i'm importing untranspiled reactcomponent.
how import reactcomponent without duplicating code in server (re-using code client/bundle.js)?
you have few solutions:
your server code doesn't need pre-compiled. if run
babel-node
, compiled on-the-fly.you bundle server code. don't know resource on how browserify, here's resource started webpack backend.
you build client code alongside server code.
Comments
Post a Comment