bundle-loader
Advanced tools
Comparing version 0.5.5 to 0.5.6
@@ -13,3 +13,3 @@ /* | ||
var options = { | ||
context: query.context || this.options.context, | ||
context: query.context || this.rootContext || this.options && this.options.context, | ||
regExp: query.regExp | ||
@@ -16,0 +16,0 @@ }; |
{ | ||
"name": "bundle-loader", | ||
"version": "0.5.5", | ||
"version": "0.5.6", | ||
"author": "Tobias Koppers @sokra", | ||
"description": "bundle loader module for webpack", | ||
"license": "MIT", | ||
"main": "index.js", | ||
"files": [ | ||
"index.js" | ||
], | ||
"engines": { | ||
"node": ">= 4" | ||
}, | ||
"scripts": { | ||
"release": "standard-version" | ||
}, | ||
"dependencies": { | ||
"loader-utils": "^1.0.2" | ||
"loader-utils": "^1.1.0" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "http://www.opensource.org/licenses/mit-license.php" | ||
} | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/webpack/bundle-loader.git" | ||
} | ||
"devDependencies": { | ||
"standard-version": "^4.0.0" | ||
}, | ||
"repository": "https://github.com/webpack-contrib/bundle-loader.git", | ||
"bugs": "https://github.com/webpack-contrib/bundle-loader/issues", | ||
"homepage": "https://webpack.js.org/loaders/bundle-loader" | ||
} |
192
README.md
[![npm][npm]][npm-url] | ||
[![node][node]][node-url] | ||
[![deps][deps]][deps-url] | ||
[![tests][tests]][tests-url] | ||
[![coverage][cover]][cover-url] | ||
[![chat][chat]][chat-url] | ||
<div align="center"> | ||
<!-- replace with accurate logo e.g from https://worldvectorlogo.com/ --> | ||
<a href="https://github.com/webpack/webpack"> | ||
<img width="200" height="200" vspace="" hspace="25" | ||
<img width="200" height="200" | ||
src="https://cdn.rawgit.com/webpack/media/e7485eb2/logo/icon.svg"> | ||
</a> | ||
<h1>Bundle Loader</h1> | ||
<p>Bundle loader for Webpack.<p> | ||
<p>Bundle loader for webpack<p> | ||
</div> | ||
@@ -21,36 +23,133 @@ | ||
<h2 align="center">Usage</h2> | ||
<h2 align="center"><a href="https://webpack.js.org/concepts/loaders">Usage</a></h2> | ||
[Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html) | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.bundle\.js$/, | ||
use: 'bundle-loader' | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
``` javascript | ||
// The chunk is requested, when you require the bundle | ||
var waitForChunk = require("bundle-loader!./file.js"); | ||
The chunk is requested, when you require the bundle. | ||
// To wait until the chunk is available (and get the exports) | ||
// you need to async wait for it. | ||
waitForChunk(function(file) { | ||
// use file like it was required with | ||
// var file = require("./file.js"); | ||
**file.js** | ||
```js | ||
import bundle from './file.bundle.js'; | ||
``` | ||
To wait until the chunk is available (and get the exports) | ||
you need to async wait for it. | ||
```js | ||
bundle((file) => { | ||
// use the file like it was required | ||
const file = require('./file.js') | ||
}); | ||
// wraps the require in a require.ensure block | ||
``` | ||
The file is requested when you require the bundle loader. If you want it to request it lazy, use: | ||
This wraps the `require('file.js')` in a `require.ensure` block | ||
``` javascript | ||
var load = require("bundle-loader?lazy!./file.js"); | ||
Multiple callbacks can be added. They will be executed in the order of addition. | ||
// The chunk is not requested until you call the load function | ||
load(function(file) { | ||
```js | ||
bundle(callbackTwo) | ||
bundle(callbackThree) | ||
``` | ||
}); | ||
If a callback is added after dependencies were loaded, it will be called immediately. | ||
<h2 align="center">Options</h2> | ||
|Name|Type|Default|Description| | ||
|:--:|:--:|:-----:|:----------| | ||
|**`lazy`**|`{Boolean}`|`false`|Loads the imported bundle asynchronously| | ||
|**`name`**|`{String}`|`[id].[name]`|Configure a custom filename for your imported bundle| | ||
### `lazy` | ||
The file is requested when you require the `bundle-loader`. If you want it to request it lazy, use: | ||
**webpack.config.js** | ||
```js | ||
{ | ||
loader: 'bundle-loader', | ||
options: { | ||
lazy: true | ||
} | ||
} | ||
``` | ||
You may set name for bundle (`name` query parameter). See [documentation](https://github.com/webpack/loader-utils#interpolatename). | ||
```js | ||
import bundle from './file.bundle.js' | ||
``` javascript | ||
require("bundle-loader?lazy&name=my-chunk!./file.js"); | ||
bundle((file) => {...}) | ||
``` | ||
> ℹ️ The chunk is not requested until you call the load function | ||
### `name` | ||
You may set name for a bundle using the `name` options parameter. | ||
See [documentation](https://github.com/webpack/loader-utils#interpolatename). | ||
**webpack.config.js** | ||
```js | ||
{ | ||
loader: 'bundle-loader', | ||
options: { | ||
name: '[name]' | ||
} | ||
} | ||
``` | ||
> :warning: chunks created by the loader will be named according to the | ||
[`output.chunkFilename`](https://webpack.js.org/configuration/output/#output-chunkfilename) rule, which defaults to `[id].[name]`. Here `[name]` corresponds to the chunk name set in the `name` options parameter. | ||
<h2 align="center">Examples</h2> | ||
```js | ||
import bundle from './file.bundle.js' | ||
``` | ||
**webpack.config.js** | ||
``` js | ||
module.exports = { | ||
entry: { | ||
index: './App.js' | ||
}, | ||
output: { | ||
path: path.resolve(__dirname, 'dest'), | ||
filename: '[name].js', | ||
// or whatever other format you want | ||
chunkFilename: '[name].[id].js', | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.bundle\.js$/, | ||
use: { | ||
loader: 'bundle-loader', | ||
options: { | ||
name: 'my-chunk' | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
Normal chunks will show up using the `filename` rule above, and be named according to their `[chunkname]`. | ||
Chunks from `bundle-loader`, however will load using the `chunkFilename` rule, so the example files will produce `my-chunk.1.js` and `file-2.js` respectively. | ||
You can also use `chunkFilename` to add hash values to the filename, since putting `[hash]` in the bundle options parameter does not work correctly. | ||
<h2 align="center">Maintainers</h2> | ||
@@ -62,24 +161,28 @@ | ||
<td align="center"> | ||
<img width="150" height="150" | ||
src="https://avatars3.githubusercontent.com/u/166921?v=3&s=150"> | ||
</br> | ||
<a href="https://github.com/bebraw">Juho Vepsäläinen</a> | ||
<a href="https://github.com/bebraw"> | ||
<img width="150" height="150" src="https://github.com/bebraw.png?v=3&s=150"> | ||
</br> | ||
Juho Vepsäläinen | ||
</a> | ||
</td> | ||
<td align="center"> | ||
<img width="150" height="150" | ||
src="https://avatars2.githubusercontent.com/u/8420490?v=3&s=150"> | ||
</br> | ||
<a href="https://github.com/d3viant0ne">Joshua Wiens</a> | ||
<a href="https://github.com/d3viant0ne"> | ||
<img width="150" height="150" src="https://github.com/d3viant0ne.png?v=3&s=150"> | ||
</br> | ||
Joshua Wiens | ||
</a> | ||
</td> | ||
<td align="center"> | ||
<img width="150" height="150" | ||
src="https://avatars3.githubusercontent.com/u/533616?v=3&s=150"> | ||
</br> | ||
<a href="https://github.com/SpaceK33z">Kees Kluskens</a> | ||
<a href="https://github.com/michael-ciniawsky"> | ||
<img width="150" height="150" src="https://github.com/michael-ciniawsky.png?v=3&s=150"> | ||
</br> | ||
Michael Ciniawsky | ||
</a> | ||
</td> | ||
<td align="center"> | ||
<img width="150" height="150" | ||
src="https://avatars3.githubusercontent.com/u/3408176?v=3&s=150"> | ||
</br> | ||
<a href="https://github.com/TheLarkInn">Sean Larkin</a> | ||
<a href="https://github.com/evilebottnawi"> | ||
<img width="150" height="150" src="https://github.com/evilebottnawi.png?v=3&s=150"> | ||
</br> | ||
Alexander Krasnoyarov | ||
</a> | ||
</td> | ||
@@ -94,6 +197,15 @@ </tr> | ||
[node]: https://img.shields.io/node/v/bundle-loader.svg | ||
[node-url]: https://nodejs.org | ||
[deps]: https://david-dm.org/webpack-contrib/bundle-loader.svg | ||
[deps-url]: https://david-dm.org/webpack-contrib/bundle-loader | ||
[chat]: https://img.shields.io/badge/gitter-webpack%2Fwebpack-brightgreen.svg | ||
[tests]: http://img.shields.io/travis/webpack-contrib/bundle-loader.svg | ||
[tests-url]: https://travis-ci.org/webpack-contrib/bundle-loader | ||
[cover]: https://coveralls.io/repos/github/webpack-contrib/bundle-loader/badge.svg | ||
[cover-url]: https://coveralls.io/github/webpack-contrib/bundle-loader | ||
[chat]: https://badges.gitter.im/webpack/webpack.svg | ||
[chat-url]: https://gitter.im/webpack/webpack |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
9371
209
1
Updatedloader-utils@^1.1.0