Merge pull request #24673 from iMobs/react-loadable/webpack

[react-loadable] Add server side rendering webpack plugin and getBundles helper function
This commit is contained in:
Paul van Brenk
2018-04-03 10:36:24 -07:00
committed by GitHub
4 changed files with 59 additions and 1 deletions
+1
View File
@@ -4,6 +4,7 @@
// Oden S. <https://github.com/odensc>
// Ian Ker-Seymer <https://github.com/ianks>
// Tomek Łaziuk <https://github.com/tlaziuk>
// Ian Mobley <https://github.com/iMobs>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
+25
View File
@@ -0,0 +1,25 @@
import webpack = require('webpack');
import Loadable = require('react-loadable/webpack');
const config: webpack.Configuration = {
plugins: [
new Loadable.ReactLoadablePlugin(),
new Loadable.ReactLoadablePlugin({
filename: 'react-loadable.json'
})
]
};
const manifest = {
react: [
{
id: 0,
name: './node_modules/react/index.js',
file: 'main.js'
}
]
};
const manifestIds = ['react'];
const bundles = Loadable.getBundles(manifest, manifestIds);
+3 -1
View File
@@ -19,8 +19,10 @@
},
"files": [
"index.d.ts",
"webpack.d.ts",
"test/index.tsx",
"test/webpack.ts",
"test/imports/no-default.tsx",
"test/imports/with-default.tsx"
]
}
}
+30
View File
@@ -0,0 +1,30 @@
import webpack = require("webpack");
declare namespace LoadableExport {
interface Options {
filename: string;
}
class ReactLoadablePlugin extends webpack.Plugin {
constructor(opts?: Options);
}
interface Bundle {
id: number;
name: string;
file: string;
}
interface Manifest {
[moduleId: string]: Bundle[];
}
function getBundles(manifest: Manifest, moduleIds: string[]): Bundle[];
}
declare const exports: {
getBundles: typeof LoadableExport.getBundles;
ReactLoadablePlugin: typeof LoadableExport.ReactLoadablePlugin;
};
export = exports;