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

@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

  • 4.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
209K
decreased by-6.57%
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 05 Oct 2023

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