Enable code splitting with require()
npm install rollup-plugin-require-split-coderollup-plugin-require-split-code
================================


Enable code splitting with require().
Installation
------------
``
`
npm install -D rollup-plugin-require-split-code
// split
Usage
-----
Mark the split point with comment:
`
js
`
function lazyLoadSomeModule() {
const foo = require("./foo"); // split
console.log(foo);
}
module.exports = lazyLoadSomeModule;
`
Then add the plugin to the config:
js
`
import split from "rollup-plugin-require-split-code";
import cjs from "rollup-plugin-cjs-es";
export default {
input: ["entry.js"],
output: {
dir: "dist",
format: "cjs"
},
plugins: [
split(),
cjs()
],
experimentalCodeSplitting: true
};
require("./foo.js")
How it works
------------
This plugin converts into _UNWRAP_IMPORT_(import("./foo.js")) so that rollup would register "foo" as a dynamic import entry point and tries splitting "foo" into a separate file. After generating the bundle, the plugin converts _UNWRAP_IMPORT_(Promise.resolve(require("./foo.js"))) back to require("./foo.js").
undefined
Options
-------
$3
An array of glob pattern. Only matched files would be processed. If not set then process all files. Default: .
undefined`.
$3
An array of glob pattern. Matched files would not be processed. Default:
Changelog
---------
* 0.2.0 (Jun 5, 2019)
- Bump dependencies. Update rollup to 1.14.0.
* 0.1.0 (Jun 29, 2018)
- Pulled out from rollup-plugin-cjs-es.