0.1.1 • Published 3 years ago

esbuild-plugin-yaml-import v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

esbuild-plugin-yaml-import

ESBuild plugin for yaml import, by JS-YAML.

Usage

GitHub Repository/Homepage is private for now, if you got any troubles, just open issue in this repo.

npm i esbuild-plugin-yaml-import -D
pnpm i esbuild-plugin-yaml-import -D
yarn add esbuild-plugin-yaml-import -D
import { build } from 'esbuild';
import yaml from 'esbuild-plugin-yaml-import';

(async () => {
  const res1 = await build({
    entryPoints: ['./demo.tsx'],
    bundle: true,
    outfile: './dist/main.js',
    plugins: [yaml()],
  });
})();

Yaml content will be parsed as JSON, and processed by ESBuild json loader.

Configuration

See JS-YAML documents for details.

export interface Options {
  // JS-YAML load options
  jsyamlLoadOptions?: JSYamlOptions;

 // transform YAML content after read file
  transformContent?: (content: string) => string;

  // transform parsed content after load
  transformParsed?: (
    data: string | number | object,
    filePath: string
  ) => object | undefined;
}