Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hqjs/babel-plugin-transform-json-imports

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hqjs/babel-plugin-transform-json-imports

Transform json imports

  • 0.0.5
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

https://hqjs.org

Transform json imports

Installation

npm install hqjs@babel-plugin-transform-json-imports

Usage

{
  "plugins": [["hqjs@babel-plugin-transform-json-imports", { "dirname": "/json/directory", "root": "/root/directory" }]]
}

If you are invoking this plugin from javascript it becomes possible to pass filesystem implementation trough fs option, it expects the object with readFileSync method defined.

Transformation

Transforms .json imports into inplace definition e.g. having file values.json

{
  "a": 1,
  "b": 2,
  "c": 3
}

and importing it

import values from './values.json';
// Or with destructure
import {a, b} from './values.json';

or similar expressions with require

const values = require('./values.json');
// Or with destructure
const {a, b} = require('./values.json');

we will obtain

const values = {a: 1, b: 2, c: 3};
const {a, b} = {a: 1, b: 2};

Keywords

FAQs

Package last updated on 20 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc