DEPRECATED - This has been moved into bit-bundler as well as bit-imports and made available when registering a plugin as a function.
var bundler = new Bitbundler({
loader: {
plugins: [
function(builder) {
return builder.configure({
extensions: ["esm"]
});
}
]
}
});
Helper for creating bit-loader plugin configurations
Plugin builder simplifies the process of creating configurations for bit-loader plugins. It merges transforms, resolve, fetch, dependency handlers in a Plugin. It also merges match and ignore rules.
Factory method to create a Plugin builder. Options can be passed in for setting the intial state of the Plugin builder.
- returns PluginBuilder instance
var utils = require("bit-bundler-utils");
var defaultOptions = {
match: {
path: /[\w]+\.(js)$/
}
};
var pluginBuilder = PluginBuilder.create(defaultOptions);
Method to configure PluginBuilder instance
- returns PluginBuilder instance (self)
pluginBuilder = pluginBuilder.configure({
transform: function(meta) {
console.log(meta);
}
});
Method that creates a plugin configuration object to register plugins with the loader
- returns loader plugin configuration
var plugin = pluginBuilder.build();
Sample plugin that loads JSON files.
var PluginBuilder = require("bit-bundler-utils/PluginBuilder");
var defaults = {
match: {
path: /[\w]+\.(json)$/
},
dependency: function dependencyText(meta) {
return {
source: "module.exports = " + meta.source + ";"
};
}
};
function textPlugin(options) {
return PluginBuilder
.create(defaults)
.configure(options)
.build();
}
module.exports = textPlugin;
Licensed under MIT