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

jsonnet-node-loader

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonnet-node-loader

A loader that allows Node.js to import Jsonnet settings from an ESModule file.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

NodeCI License: MIT tested with jest code style: prettier PRs Welcome Open in Visual Studio Code

jsonnet-node-loader

A loader that allows Node.js to import Jsonnet settings from an ESModule file.

Features

  • Support importing .jsonnet file

Installation

If you're using the npm or yarn CLI, then add the plugin by:

NPM

# yarn
$ yarn add -D jsonnet-node-loader
# or npm
$ npm install --save-dev jsonnet-node-loader

Usage

loader option

Specify jsonnet-node-loader in the loader option and execute the file.

Then, when the jsonnet file is imported, the evaluated value is returned.

$ node --experimental-loader jsonnet-node-loader example.mjs
{
  person1: { name: 'Alice', welcome: 'Hello Alice!' },
  person2: { name: 'Bob', welcome: 'Hello Bob!' }
}
example.mjs
import data from './example.jsonnet';

console.log(data);
example.jsonnet
{
  person1: {
    name: "Alice",
    welcome: "Hello " + self.name + "!",
  },
  person2: self.person1 { name: "Bob" },
}

Advanced usage

When using std.extVar(x), query parameters can be specified and passed when importing vars.jsonnet.

vars.jsonnet
{
  vars: {
    foo: std.extVar('foo'),
    var: std.extVar('bar'),
  },
}
vars.mjs
import data from './vars.jsonnet?foo=1&bar=2';

console.log(data);
// { vars: { foo: '1', var: '2' } }

License

This software is released under the MIT License, see LICENSE.

Keywords

FAQs

Package last updated on 30 Oct 2021

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