0.1.2 • Published 3 years ago

babel-plugin-import-json-value v0.1.2

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

babel-plugin-import-json-value

NPM

中文文档

A babel pre-processor that inlines all imports of JSON files straight into your JavaScript files.

Example

My package.json file:

{
  "name": "babel-plugin-import-json-value",
  "version": "0.0.3",
  "devDependencies": {
    "@babel/cli": "^7.12.8"
  }
}

input:

import { version, name as name1, default as pkg } from "./data.json";
import pkg1 from "./data.json";
import * as pkg2 from "./data.json";
const pkg3 = require("./data.json");
const { version1, name: name2 } = require("./data.json");
const name3 = require("./data.json").name;
const text1 = require("./data.json").devDependencies["@babel/cli"];

output:

const version = "0.0.3",
      name1 = "babel-plugin-import-json-value",
      pkg = "{\"name\":\"babel-plugin-import-json-value\",\"version\":\"0.0.3\",\"devDependencies\":{\"@babel/cli\":\"^7.12.8\"}}";
const pkg1 = "{\"name\":\"babel-plugin-import-json-value\",\"version\":\"0.0.3\",\"devDependencies\":{\"@babel/cli\":\"^7.12.8\"}}";
const pkg2 = "{\"name\":\"babel-plugin-import-json-value\",\"version\":\"0.0.3\",\"devDependencies\":{\"@babel/cli\":\"^7.12.8\"}}";
const pkg3 = "{\"name\":\"babel-plugin-import-json-value\",\"version\":\"0.0.3\",\"devDependencies\":{\"@babel/cli\":\"^7.12.8\"}}";
const version1 = undefined,
      name2 = "babel-plugin-import-json-value";
const name3 = "babel-plugin-import-json-value";
const text1 = "^7.12.8";

Installation

$ yarn add -D babel-plugin-import-json-value

Add babel-plugin-import-json-value to your babel config .

{
  "plugins": [
    "babel-plugin-import-json-value"
  ]
}

Tips

Value types other than strings are not currently supported, and the rest will be implemented later

  • TODO:

  • Support other value types.

  • Support import and require default export.
  • Support esModule export.

License

This project is licensed under the MIT License - see the LICENSE file for details

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago