<commit_before>import express from 'express';
import React from 'react';
import { renderToStaticMarkup, renderToString } from 'react-dom/server';
import { Provider } from 'react-redux';
import { combineReducers, createStore } from 'redux';
import { ReduxRouter, routerStateReducer } from 'redux-router';
import { match, reduxReactRouter } from 'redux-router/lib/server';

import config from './common/config';
import routes from './common/routes';

import * as reducers from './reducers';

import Edit from './containers/Edit';
import Home from './containers/Home';

import Page from './components/page/Page';

let scripts = [ ...config.scripts ];

const app = express();

app.use( express.static( 'static' ));

if ( __DEVELOPMENT__ ) {
  const webpackConfig = require( '../webpack/development/browser.config' );
  const compiler = require( 'webpack' )( webpackConfig );

  app.use( require( 'webpack-dev-middleware' )( compiler, {
    noInfo: true,
    publicPath: webpackConfig.output.publicPath,
  }));

  app.use( require( 'webpack-hot-middleware' )( compiler ));

  scripts = scripts.map( script => {
    return script.replace( '.min', '' );
  });
}

function handleRender ( req, res ) {
  const reducer = combineReducers({
    ...reducers,
    router: routerStateReducer,
  });

  const initialState = { 'name': req.query.name || '' };

  const store = reduxReactRouter({
    routes,
  })( createStore )( reducer, initialState );

  store.dispatch( match( req.path, () => {
    res.send( renderFullPage(
      renderToString(
        <Provider store={ store }>
          <ReduxRouter />
        </Provider>
      ),
      store.getState()
    ));
  }));
};

function renderFullPage ( html, state ) {
  return '<!DOCTYPE html>' +
    renderToStaticMarkup(
      <Page
        html={ html }
        scripts={ scripts }
        state={ JSON.stringify( state ) }
        title="Hello world"
      />
    );
};

app.use( handleRender );

app.listen( 3000 );
<commit_msg>Node need for lib directory when importing `react-router/server`<commit_after>import express from 'express';
import React from 'react';
import { renderToStaticMarkup, renderToString } from 'react-dom/server';
import { Provider } from 'react-redux';
import { combineReducers, createStore } from 'redux';
import { ReduxRouter, routerStateReducer } from 'redux-router';
import { match, reduxReactRouter } from 'redux-router/server';

import config from './common/config';
import routes from './common/routes';

import * as reducers from './reducers';

import Edit from './containers/Edit';
import Home from './containers/Home';

import Page from './components/page/Page';

let scripts = [ ...config.scripts ];

const app = express();

app.use( express.static( 'static' ));

if ( __DEVELOPMENT__ ) {
  const webpackConfig = require( '../webpack/development/browser.config' );
  const compiler = require( 'webpack' )( webpackConfig );

  app.use( require( 'webpack-dev-middleware' )( compiler, {
    noInfo: true,
    publicPath: webpackConfig.output.publicPath,
  }));

  app.use( require( 'webpack-hot-middleware' )( compiler ));

  scripts = scripts.map( script => {
    return script.replace( '.min', '' );
  });
}

function handleRender ( req, res ) {
  const reducer = combineReducers({
    ...reducers,
    router: routerStateReducer,
  });

  const initialState = { 'name': req.query.name || '' };

  const store = reduxReactRouter({
    routes,
  })( createStore )( reducer, initialState );

  store.dispatch( match( req.path, () => {
    res.send( renderFullPage(
      renderToString(
        <Provider store={ store }>
          <ReduxRouter />
        </Provider>
      ),
      store.getState()
    ));
  }));
};

function renderFullPage ( html, state ) {
  return '<!DOCTYPE html>' +
    renderToStaticMarkup(
      <Page
        html={ html }
        scripts={ scripts }
        state={ JSON.stringify( state ) }
        title="Hello world"
      />
    );
};

app.use( handleRender );

app.listen( 3000 );

{'fraction_non_alphanumeric': 0.1511657056906493, 'fraction_numerical': 0.002005515166708448, 'mean_word_length': 3.2857142857142856, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6560313', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1203, 'n_words': 307}