0.0.2 • Published 6 years ago

@csgis/json-module-args-loader v0.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Build Status codecov npm downloads

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

NameTypeDefaultDescription
modules{ String }modulesName of the property JSON property with module paths.
args{ String }argsName of the property JSON property to put argument names.
function{ String }bricjsName of the function to parse.
skip{ Integer }0Number of function arguments to skip.