# webpack-sol-loader

> Simple webpack loader for .sol files and typescript support.

Latest version **0.1.33** (published 2022-12-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install webpack-sol-loader
pnpm add webpack-sol-loader
yarn add webpack-sol-loader
bun add webpack-sol-loader
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.33 |
| Published | 2022-12-08 |
| First published | 2022-12-04 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Vitalii Koliesnik v1xel@outlook.de |
| Maintainers | v1xel |
| Keywords | .sol, sol-loader, loader, webpack, ts, typescript |

## Links

- npm: https://www.npmjs.com/package/webpack-sol-loader
- Repository: https://github.com/V1xel/webpack-sol-loader
- Homepage: https://github.com/V1xel/webpack-sol-loader.git
- Issues: https://github.com/V1xel/webpack-sol-loader/issues
- npm.io page: https://npm.io/package/webpack-sol-loader

## Alternatives

- [csv-to-markdown-table](https://npm.io/package/csv-to-markdown-table.md) — 47.0K weekly downloads
- [@sapphire/ratelimits](https://npm.io/package/@sapphire/ratelimits.md) — 4.4K weekly downloads
- [js-csvparser](https://npm.io/package/js-csvparser.md) — 2.0K weekly downloads
- [@adadapted/js-sdk](https://npm.io/package/@adadapted/js-sdk.md) — 251 weekly downloads
- [@grapecity/spread-sheets-sparklines](https://npm.io/package/@grapecity/spread-sheets-sparklines.md) — 103 weekly downloads

## Recent versions

- 0.1.33 (latest) — 2022-12-08
- 0.1.32 — 2022-12-08
- 0.1.31 — 2022-12-08
- 0.1.3 — 2022-12-04
- 0.1.25 — 2022-12-04
- 0.1.242 — 2022-12-04
- 0.1.241 — 2022-12-04
- 0.1.24 — 2022-12-04
- 0.1.23 — 2022-12-04
- 0.1.22 — 2022-12-04
- 0.1.21 — 2022-12-04
- 0.1.2 — 2022-12-04
- 0.1.19 — 2022-12-04
- 0.1.18 — 2022-12-04
- 0.1.17 — 2022-12-04
- … 8 more at https://npm.io/package/webpack-sol-loader/versions

## README

# Loader for .sol files and typescript support.

Compiles `.sol` with [Solidity compiler](https://github.com/ethereum/solc-js).
Provides following object depending on imported `.sol` file.

```ts
interface SolidityDocument {
    abi: AbiItem,
    bytecode: string,
    contracts: undefined
}

interface SolidityDocumentCollection {
    contracts: SolidityDocument[]
}
```

## Installation

```bash
npm install webpack-sol-loader --save-dev
```

## Usage

Update your `webpack.config.ts`:

```ts
const config: Configuration = {
	module: {
		rules: [{
			test: /\.sol?$/,
			use: {
				loader: 'webpack-sol-loader'
			}
		}]
	}
}
```

Just import .sol file
```ts
import wallet from './wallet.sol'
// => returns SolidityDocument or SolidityDocumentCollection that are written above.
```

## Types

Create file webpack-sol-loader.d.ts and include the following:

```ts
type AbiType = 'function' | 'constructor' | 'event' | 'fallback' | 'receive';
type StateMutabilityType = 'pure' | 'view' | 'nonpayable' | 'payable';

interface AbiInput {
    name: string;
    type: string;
    indexed?: boolean;
    components?: AbiInput[];
    internalType?: string;
}

interface AbiOutput {
    name: string;
    type: string;
    components?: AbiOutput[];
    internalType?: string;
}

interface AbiItem {
    anonymous?: boolean;
    constant?: boolean;
    inputs?: AbiInput[];
    name?: string;
    outputs?: AbiOutput[];
    payable?: boolean;
    stateMutability?: StateMutabilityType;
    type: AbiType;
    gas?: number;
}

interface SolidityDocument {
    abi: AbiItem,
    bytecode: string,
    contracts: undefined
}

interface SolidityDocumentCollection {
    abi: undefined,
    source: undefined,
    bytecode: undefined
    contracts: SolidityDocument[]
}

declare module '*.sol' {
    const value: SolidityDocument | SolidityDocumentCollection
    export default value
}
```

---
_Source: https://npm.io/package/webpack-sol-loader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
