Skip to content

A Webpack loader that loads a JSON object and resolves paths to actual modules.

License

Notifications You must be signed in to change notification settings

csgis/json-modules-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status codecov npm downloads

JSON Modules loader

A Webpack loader that loads a JSON object and resolves paths to actual modules.

It is useful to decouple your dependencies from your code. Just replace the dependencies in you JSON file with others that behave the same.

Install

With npm:

npm install --save-dev @csgis/json-modules-loader

With yarn:

yarn add -D @csgis/json-modules-loader

Usage

webpack.config.js

{
   test: /app\.json$/,
   use: [ '@csgis/json-modules-loader' ]
}

app.json

{
  "modules": {
    "x": "react",
    "y": "react-dom"
  }
}

file.js

import app from './app.json';

app.modules.y.render(
  app.modules.x.createElement(Hello, {toWhat: 'World'}, null),
  document.getElementById('root')
);

Options

Name Type Default Description
key { String } modules Name of the property JSON property with paths to be resolved.
importName { String } default Name of the export to use as module value.

About

A Webpack loader that loads a JSON object and resolves paths to actual modules.

Resources

License

Stars

Watchers

Forks

Packages

No packages published