1.0.0 • Published 1 year ago

@transformation-dev/esm-loader-yaml v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

esm-loader-yaml

Node.js ESModule Loader for importing YAML files as modules.

Warning! This uses experimental Node.js features and flags, whose API will likely change. This code may be helpful for development and testing, but should not be used in production.

Usage

npm install --save-dev esm-loader-yaml

You may have code which imports .yaml files:

// data.yaml
- name: Vito
// index.js
import data from './data.yaml'
console.log(data) // { "name": "Vito" }

Standalone

NODE_OPTIONS="--loader esm-loader-yaml" node index.js

Chainable

This loader can be configured, and chained with other loaders, using node-esm-loader.

npm install --save-dev node-esm-loader
// .loaderrc.js
export default {
  loaders: ['esm-loader-yaml'],
}
NODE_OPTIONS="--loader node-esm-loader" node index.js

Options

Debug

// .loaderrc.js
export default {
  loaders: [
    {
      loader: 'esm-loader-yaml',
      options: {
        debug: true,
      },
    },
  ],
}

License

MIT