0.1.0 • Published 9 years ago
namespace-imports-loader v0.1.0
namespace imports loader for webpack
Can be used to inject variables into the scope of a module under some namespace. This is especially useful if third-party modules are relying on some namespace being initialized with some value like com.foo.bar.
Heavily inspired by imports-loader
Installation
npm install namespace-imports-loaderUsage
Given you have this file example.js
var value = com.foo.bar.getValue()then you can inject the com.foo.bar namespace into the module by configuring the namespace-imports-loader like this:
require("namespace-imports?com.foo.bar=someFile!./example.js");It is possible to put multiple values on the same namespace. It will merge the values into one object.
webpack.config.js
As always, you should rather configure this in your webpack.config.js:
// ./webpack.config.js
module.exports = {
...
module: {
loaders: [
{
test: require.resolve("some-module"),
loader: "namespace-imports?com.foo.bar=someFile"
}
]
};License
0.1.0
9 years ago