bloat-loader
v0.4.0
Published
import source injection loader for Webpack
Downloads
6
Readme
Bloat loader for webpack
bloat-loader is a webpack loader that will replace all import declarations with the requested file's source code. Effectively, bloating your code from this:
import FooBar from 'app/directory/FooBar';
const instance = new FooBar();
instance.init();
...to something like this:
class FooBar {
constructor() {
this.foo = 'bar';
}
init() {
return this.foo;
}
}
const instance = new FooBar();
instance.init();
Currently Supported Syntax (v0.4.0):
Directly import the default:
import myDefault from 'my-module'
Import a single member of a module:
import { myMember } from 'my-module'
Import multiple members of a module:
import { foo, bar } from 'my-module'
Import a member with a more convenient alias:
import { reallyReallyLongModuleMemberName as shortName } from 'my-module'
Import multiple members of a module with aliases:
import { reallyReallyLongModuleMemberName as shortName, anotherLongModuleName as short } from 'my-module'
Import an entire module's contents:
import * as myModule from 'my-module'
See the bloat-loader feature roadmap for more information on upcoming syntax support.
Install
Via npm install
npm install bloat-loader --save-dev
Requirements
bloat-loader uses ES2015+ features and requires Node 4.4.5 or above
Usage
Intended Usage
This loader should (probably) never be applied to an entire project and is intended for use cases where compiling a class or method's dependencies into one source is particularly useful (e.g. when creating a Bookmarklet).
Apply via webpack config
module.exports = {
...
module: {
loaders: [
{
test: /\.js$/,
loaders: ['bloat-loader'],
include: path.join(__dirname, 'app/myBloatedFiles')
}
]
}
};
When using Babel or another transpiler, bloat-loader must be applied beforehand so that it's result can be transpiled:
...
loaders: ['babel', 'bloat-loader'],
...