@florian-s/rollup-plugin-toml
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

@florian-s/rollup-plugin-toml

🍣 A Rollup plugin which Converts .toml files to ES6 modules.

Requirements

This plugin requires an LTS Node version (v8.0.0+) and Rollup v1.20.0+.

Install

Using npm:

npm install @florian-s/rollup-plugin-toml --save-dev

Why another toml plugin ?

Previous rollup plugins for TOML use older TOML libraries that are not compliant with TOML v1.0.0. This package uses @ltd/j-toml.

Usage

Create a rollup.config.js configuration file and import the plugin:

import toml from '@florian-s/rollup-plugin-toml';

export default {
  input: 'src/index.js',
  output: {
    dir: 'output',
    format: 'cjs'
  },
  plugins: [toml()]
};

Then call rollup either via the CLI or the API.

With an accompanying file src/index.js, the local package.toml file would now be importable as seen below:

// src/index.js
import pkg from './package.toml';
console.log(`running version ${pkg.version}`);

Options

compact

Type: Boolean
Default: false

If true, instructs the plugin to ignore indent and generates the smallest code.

exclude

Type: String | Array[...String]
Default: null

A minimatch pattern, or array of patterns, which specifies the files in the build the plugin should ignore. By default no files are ignored.

include

Type: String | Array[...String]
Default: null

A minimatch pattern, or array of patterns, which specifies the files in the build the plugin should operate on. By default all files are targeted.

indent

Type: String
Default: '\t'

Specifies the indentation for the generated default export.

namedExports

Type: Boolean
Default: true

If true, instructs the plugin to generate a named export for every property of the JSON object.

preferConst

Type: Boolean
Default: false

If true, instructs the plugin to declare properties as variables, using either var or const. This pertains to tree-shaking.

Meta

CONTRIBUTING

LICENSE (MIT)

Package Sidebar

Install

npm i @florian-s/rollup-plugin-toml

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

15.8 kB

Total Files

8

Last publish

Collaborators

  • florian-s