Socket
Socket
Sign inDemoInstall

@rollup/plugin-yaml

Package Overview
Dependencies
Maintainers
4
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rollup/plugin-yaml

Convert YAML files to ES6 modules


Version published
Weekly downloads
180K
decreased by-15.71%
Maintainers
4
Weekly downloads
 
Created

What is @rollup/plugin-yaml?

@rollup/plugin-yaml is a Rollup plugin that allows you to import YAML files as JavaScript modules. This can be particularly useful for configuration files, data files, or any other structured data that you want to include in your JavaScript project.

What are @rollup/plugin-yaml's main functionalities?

Import YAML files

This feature allows you to import YAML files directly into your JavaScript code. The YAML content is parsed and converted into a JavaScript object.

import data from './data.yaml';
console.log(data);

Custom YAML parsing

This feature allows you to customize the YAML parsing process using the `js-yaml` library. You can include or exclude specific files and transform the YAML content as needed.

import { createFilter } from '@rollup/pluginutils';
import yaml from 'js-yaml';

export default function yamlPlugin(options = {}) {
  const filter = createFilter(options.include, options.exclude);
  return {
    name: 'yaml',
    transform(code, id) {
      if (!filter(id)) return null;
      const parsed = yaml.load(code);
      return {
        code: `export default ${JSON.stringify(parsed)};`,
        map: { mappings: '' }
      };
    }
  };
}

Other packages similar to @rollup/plugin-yaml

Keywords

FAQs

Package last updated on 11 May 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