@tevm/bun-plugin
Version:
A bun plugin for tevm
73 lines (68 loc) • 2.19 kB
text/typescript
import * as bun from 'bun';
import * as _tevm_base_bundler from '@tevm/base-bundler';
import * as _tevm_solc from '@tevm/solc';
/**
* Re-exports the Bun file API for working with files in the file system.
* The Bun file API provides an optimized interface for file operations with
* methods for reading, writing, and checking file existence.
*
* @type {typeof import('bun').file}
* @see {@link https://bun.sh/docs/api/file-io | Bun File I/O Documentation}
*
* @example
* ```javascript
* import { file } from '@tevm/bun'
*
* // Create a file reference
* const myFile = file('path/to/file.txt')
*
* // Check if the file exists
* const exists = await myFile.exists()
*
* // Read file as text
* const content = await myFile.text()
*
* // Write to file
* await myFile.write('Hello, world!')
* ```
*/
declare const file: typeof bun.file;
/**
* An adapter around the Bun file API that implements the FileAccessObject interface
* required by @tevm/base-bundler.
*
* This object combines Node.js file system functions with Bun's optimized file API
* to provide a complete implementation of the FileAccessObject interface, which is
* used by Tevm bundlers to read and write files during the Solidity compilation process.
*
* @type {import("@tevm/base-bundler").FileAccessObject}
*
* @example
* ```javascript
* import { bunFileAccesObject } from '@tevm/bun'
* import { bundler } from '@tevm/base-bundler'
*
* // Use in Tevm bundler
* const tevmBundler = bundler(
* config,
* console,
* bunFileAccesObject, // Pass the file access object
* solcCompiler,
* cacheInstance
* )
*
* // Or use directly
* const fileExists = await bunFileAccesObject.exists('./contracts/Token.sol')
* if (fileExists) {
* const content = await bunFileAccesObject.readFile('./contracts/Token.sol', 'utf8')
* console.log(content)
* }
* ```
*
* @see {@link https://bun.sh/docs/api/file-io | Bun File I/O Documentation}
*/
declare const bunFileAccesObject: _tevm_base_bundler.FileAccessObject;
declare function bunPluginTevm({ solc }: {
solc?: _tevm_solc.SolcVersions | undefined;
}): bun.BunPlugin;
export { bunFileAccesObject, bunPluginTevm, file };