0.0.2 • Published 6 years ago
@csgis/json-module-args-loader v0.0.2
JSON Module Arguments Loader
A Webpack loader that loads a JSON object and fills a property with a map of argument names for each module in a specific property.
It is possible to configure the name of the function and the number of arguments to skip.
If the JSON object already contains a property with argument names it merges them, preserving the ones in the JSON file.
Install
With npm:
npm install --save-dev @csgis/json-module-args-loader
With yarn:
yarn add -D @csgis/json-module-args-loader
Usage
webpack.config.js
{
test: /app\.json$/,
use: ['json-loader', {
loader: '@csgis/json-module-args-loader',
options: {
'function': 'f',
'skip': 1
}
}]
}
app.json
{
"modules": {
"x": "./file.js"
}
}
file.js
export function f(opts, dependency) {}
main.js
import app from './app.json';
console.log(`${app.deps.x} must be ['dependency']`);
Options
Name | Type | Default | Description |
---|---|---|---|
modules | { String } | modules | Name of the property JSON property with module paths. |
args | { String } | args | Name of the property JSON property to put argument names. |
function | { String } | bricjs | Name of the function to parse. |
skip | { Integer } | 0 | Number of function arguments to skip. |