Name: extractify
Owner: Yahoo Inc.
Description: Browserify plugin to extract code to be lazy loaded into separate bundles
Created: 2016-04-21 00:03:47.0
Updated: 2017-12-12 00:48:38.0
Pushed: 2016-06-15 17:58:10.0
Homepage: null
Size: 115
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Browserify plugin to extract code to be lazy or on-demand loaded into separate bundles aka code-splitting.
install extractify
Following diagram summarizes how extractify works:
dep4
module in above diagram is determined to be loaded as on-demand and should be stripped from the main bundle main.js
.lazy_bundle_dep4.js
which will be loaded later.only
dep4
depends on. In this case dep5
is only used by dep4
. On the other hand, dep1
module is included in main_app_bundle.js
since it was already used by main.js..json
config file soft or hard. See bundleMapOption
options belowYou can use extractify as a browserify plugin:
serify -p [ extractify OPTIONS ]
see below for OPTIONS
ampe command line OPTIONS
serify test/files/main.js -p ['extractify' --lazy [ [ --entries [ './test/files/dep4.js' './test/files/dep6.js' ] --outfile './test/lazy_bundle/lazy_bundle.js' ] ] --bundleMapOption [ --injectSoft false --dest 'test/lazy_bundle/map.json' ] ] > test/lazy_bundle/main_bundle.js
ample api OPTIONS
ndleMapOption: {
injectSoft: false,
dest: 'lazy_bundle/map.json'
zy: [
{
entries: [
'./files/dep4.js'
],
outfile: './lazy_bundle/lazy_bundle_dep4.js'
}
bundleMapOption
: optional property that instructs how the map object will be injected into source or written into file systeminjectSoft
: instructs how the map object will be injected. If it is true, it will be written to the dest file [default: true]dest
: optional location of map destination .json map file which holds module name and bundle name key value pairslazy
: holds the lazy entry and output files definition.entries
: array of the entry module names to build stripped lazy bundleoutfile
: name of the stripped lazy bundlebrowserify = require('browserify');
fs = require('fs');
b = browserify(['./files/main.js'], {
basedir: __dirname
ugin('extractify', {
zy: [
{
entries: [
'./files/dep4.js',
'./files/dep6.js'
],
outfile: './bundles/lazy_bundle.js'
}
ndle().pipe(fs.createWriteStream('./bundles/main_app.js'))
Emits with lazy bundle outfile
right after the splitted bundle written into the file system
Each splitted bundles will emits stream
before written into filesystem.
The outfile name is available as stream.file
.
MIT