0.1.1 • Published 5 months ago

@importable/yaml v0.1.1

Weekly downloads
-
License
CC0-1.0
Repository
github
Last release
5 months ago

@importable/yaml

Importable YAML allows you to import YAML files with strong typing based on import attributes (presently import assertions).

import config from './config.yml' with { type: 'yaml' }

console.assert(config.doe === 'a deer, a female deer')

Installation

npm install importable @importable/yaml

To support YAML from the TypeScript server, add @importable/yaml to tsconfig.json:

{
  "compilerOptions": {
    "plugins": [
      {
        "name": "importable",
        "plugins": [
          "@importable/yaml"
        ]
      }
    ]
  }
}

Integrations

Vite Integration

To support YAML within Vite, add @importable/yaml to vite.config.js:

import { defineConfig } from 'vite'
import importableYAML from '@importable/yaml/vite'

export default defineConfig({
  plugins: [
    importableYAML()
  ]
})

Astro Integration

To support YAML within Astro, add @importable/yaml to astro.config.js:

import { defineConfig } from 'astro'
import importableYAML from '@importable/yaml/astro'

export default defineConfig({
  integrations: [
    importableYAML()
  ]
})

Next Integration

To support YAML within Next, add @importable/next to next.config.js:

const withYaml = require('@importable/yaml/next');

module.exports = withYaml({
  // existing NextJS config
});

License

Code original to this project is licensed under the CC0-1.0 License.