All Projects → webpack-contrib → Bundle Loader

webpack-contrib / Bundle Loader

Licence: mit
Bundle Loader

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Bundle Loader

Source Map Loader
extract sourceMappingURL comments from modules and offer it to webpack
Stars: ✭ 294 (-55.86%)
Mutual labels:  webpack-loader
Css Loader
CSS Loader
Stars: ✭ 4,067 (+510.66%)
Mutual labels:  webpack-loader
Comlink Loader
Webpack loader to offload modules to Worker threads seamlessly using Comlink.
Stars: ✭ 535 (-19.67%)
Mutual labels:  webpack-loader
Speedy.js
Accelerate JavaScript Applications by Compiling to WebAssembly
Stars: ✭ 300 (-54.95%)
Mutual labels:  webpack-loader
Awesome Cms Core
Awesome CMS Core is an open source CMS built using ASP.Net Core & ReactJS with module seperation concern in mind and provide lastest trend of technology like .Net Core, React, Webpack, SASS, Background Job, Message Queue.
Stars: ✭ 352 (-47.15%)
Mutual labels:  webpack-loader
Inject Loader
💉📦 A Webpack loader for injecting code into modules via their dependencies.
Stars: ✭ 474 (-28.83%)
Mutual labels:  webpack-loader
Ts Loader
TypeScript loader for webpack
Stars: ✭ 3,112 (+367.27%)
Mutual labels:  webpack-loader
Wasm Loader
✨ WASM webpack loader
Stars: ✭ 604 (-9.31%)
Mutual labels:  webpack-loader
Sass Loader
Compiles Sass to CSS
Stars: ✭ 3,718 (+458.26%)
Mutual labels:  webpack-loader
Expose Loader
Expose Loader
Stars: ✭ 531 (-20.27%)
Mutual labels:  webpack-loader
Css Hot Loader
This is a css hot loader, which support hot module replacement for an extracted css file.
Stars: ✭ 317 (-52.4%)
Mutual labels:  webpack-loader
Markdown Loader
markdown loader for webpack
Stars: ✭ 335 (-49.7%)
Mutual labels:  webpack-loader
Svg Inline Loader
Inline SVG loader with cleaning-up functionality
Stars: ✭ 490 (-26.43%)
Mutual labels:  webpack-loader
Extract Loader
webpack loader to extract HTML and CSS from the bundle
Stars: ✭ 297 (-55.41%)
Mutual labels:  webpack-loader
Responsive Loader
A webpack loader for responsive images
Stars: ✭ 536 (-19.52%)
Mutual labels:  webpack-loader
Graphql Let
A layer to start/scale the use of GraphQL code generator.
Stars: ✭ 282 (-57.66%)
Mutual labels:  webpack-loader
Json Loader
json loader module for webpack - UNMAINTAINED
Stars: ✭ 431 (-35.29%)
Mutual labels:  webpack-loader
Cache Loader
[DEPRECATED] Caches the result of following loaders on disk
Stars: ✭ 630 (-5.41%)
Mutual labels:  webpack-loader
React Svg Loader
A loader for webpack, rollup, babel that loads svg as a React Component
Stars: ✭ 570 (-14.41%)
Mutual labels:  webpack-loader
Imports Loader
Imports Loader
Stars: ✭ 500 (-24.92%)
Mutual labels:  webpack-loader

npm node deps tests coverage chat

! NO LONGER MAINTAINED !

This module is deprecated and will no longer be maintained.

In most cases, you can replace the functionality by using dynamic import instead:

index.js

import(
  /* webpackChunkName: "my-chunk-name" */
  './file.bundle.js'
  ).then(bundle => {
    // Doing something with `bundle`
    console.log(bundle)
});

This code lazy loading imports and exports values from file.bundle.js and creates a chunk from this module with the name my-chank-name


Bundle Loader

Bundle loader for webpack

Install

npm i bundle-loader --save

Usage

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.bundle\.js$/,
        use: 'bundle-loader'
      }
    ]
  }
}

The chunk is requested, when you require the bundle.

file.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.

bundle((file) => {
  // use the file like it was required
  const file = require('./file.js')
});

This wraps the require('file.js') in a require.ensure block

Multiple callbacks can be added. They will be executed in the order of addition.

bundle(callbackTwo)
bundle(callbackThree)

If a callback is added after dependencies were loaded, it will be called immediately.

Options

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

{
  loader: 'bundle-loader',
  options: {
    lazy: true
  }
}
import bundle from './file.bundle.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.

webpack.config.js

{
  loader: 'bundle-loader',
  options: {
    name: '[name]'
  }
}

⚠️ chunks created by the loader will be named according to the output.chunkFilename rule, which defaults to [id].[name]. Here [name] corresponds to the chunk name set in the name options parameter.

Examples

import bundle from './file.bundle.js'

webpack.config.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.

Maintainers

Juho Vepsäläinen Joshua Wiens Michael Ciniawsky Alexander Krasnoyarov
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].