unyaml 语句
通用YAML装载器. 在Node.js(CJS)工作 require /无害环境管理 import, (中文(简体) ), 兴建 财务报告和审定财务报表 维特 - 一个包裹 一个心理模型.
节点.js
节点.js ^22.15 || >=24 需要时间.
从CLI
CJS: 贾克:
node -r unyaml path/to/index.cjs
无害环境管理:
node --import unyaml path/to/index.mjs
手动导入
CJS: 贾克:
require('unyaml')
require('path/to/file.yml') // now it works!
无害环境管理:
import 'unyaml'
const data = await import('path/to/file.yml')
兴建
import esbuild from 'esbuild'
import unyaml from 'unyaml/esbuild'
await esbuild.build({
entryPoints: ['src/index.ts'],
bundle: true,
outfile: 'dist/index.js',
plugins: [unyaml()],
})
.yml 编号 : .yaml 进口作为 JSON 模块加载、解析和内含.
选项
unyaml({
filter?: RegExp // default: /\.ya?ml$/
// ...plus any js-yaml LoadOptions (schema, json, onWarning, ...)
})
维特
// vite.config.ts
import { defineConfig } from 'vite'
import unyaml from 'unyaml/vite'
export default defineConfig({
plugins: [unyaml()],
})
Vite 插件处理主管道 财务报告和审定财务报表 基于构建的依赖性预捆绑(optimizeDeps,因此从内部导入 YAML node_modules 工作从盒子.
选项
unyaml({
filter?: RegExp // default: /\.ya?ml(?:\?.*)?$/
// ...plus any js-yaml LoadOptions (schema, json, onWarning, ...)
})
类型脚本支持
安静 Cannot find module 'file.yml' or its corresponding type declarations. 错误, 添加 unyaml/types 改为 compilerOptions.types 内 tsconfig.json数字 :
{
"compilerOptions": {
"types": [
"unyaml/types"
]
}
}