JSPM

babel-plugin-inline-json

2.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 905
  • Score
    100M100P100Q127870F
  • License MIT

Package Exports

  • babel-plugin-inline-json

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (babel-plugin-inline-json) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

babel-plugin-inline-json

Build Status

Inline values from a JSON file eg. a config file

Does not work if the argument to require() is an identifier or a template literal

Example

config.json:

{
  "foo": "bar"
}

In

var foo = require('config').foo;

Out

var foo = "bar";

Installation

$ npm install babel-plugin-inline-json --save-dev

Usage

.babelrc

{
  "plugins": [["inline-json", {"matchPattern": "config"}]]
}

Via CLI

$ babel --plugins inline-json script.js

Via Node API

require("babel-core").transform("code", {
  "plugins": [["inline-json", {"matchPattern": "config"}]]
});

Origin

this is based on @mwilliams-change's babel-plugin-inline-json-config-values.