xhr-eval-chunk-webpack-plugin

Load chunks via XHR + eval, instead of creating <script> elements


Keywords
webpack
License
MIT
Install
npm install xhr-eval-chunk-webpack-plugin@0.0.2

Documentation

xhr-eval-chunk-webpack-plugin

npm version Travis CI Build Status Greenkeeper badge

Load chunks via XHR + eval, instead of creating <script> elements.

Replaces webpack's default require.ensure runtime function so it loads chunks via XMLHttpRequest + eval, instead of adding <script> elements to the DOM.

Useful if you're rendering your React app on the server, mounting the client app on the root window.document element, and using code splitting. Without this plugin, the server-rendered markup will differ from the client markup and React will fail to reuse the markup, since webpack will inject additional <script> elements into the <head> before React reconciles with the DOM.

Installation

npm install xhr-eval-chunk-webpack-plugin 

Usage

// webpack.config.js

import XhrEvalChunkPlugin from 'xhr-eval-chunk-webpack-plugin';
// or:
// const XhrEvalChunkPlugin = require('xhr-eval-chunk-webpack-plugin').default;

export default {
  // ...
  plugins: [
    // ...
    new XhrEvalChunkPlugin(),
  ],
};