多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] ## TypeScript - Vite 天然支持引入 .ts 文件。 - 建议在一个单独的进程中运行 `tsc --noEmit --watch` ## JSON ``` // 导入整个对象 import json from './example.json' // 对一个根字段使用具名导入 —— 有效帮助 treeshaking! import { field } from './example.json' ``` ## WebAssembly 预编译的`.wasm`文件可以通过`?init`来导入。默认导出一个初始化函数,返回值为所导出 wasm 实例对象的 Promise ``` import init from './example.wasm?init' init().then((instance) => { instance.exports.test() }) ``` `init`函数还可以将传递给`WebAssembly.instantiate`的导入对象作为其第二个参数: ``` init({ imports: { someFunc: () => { /* ... */ }, }, }).then(() => { /* ... */ }) ``` 在生产构建当中,体积小于`assetInlineLimit`的`.wasm`文件将会被内联为 base64 字符串。否则,它们将作为资源复制到`dist`目录中,并按需获取