Skip to content

Commit e446d9c

Browse files
committed
chore: update readme
1 parent af7386a commit e446d9c

File tree

1 file changed

+37
-17
lines changed

1 file changed

+37
-17
lines changed

README.md

+37-17
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)
44
[![Version npm](https://img.shields.io/npm/v/@ton-community/func-js.svg?logo=npm)](https://www.npmjs.com/package/@ton-community/func-js)
55

6-
Cross-platform bindings for TON FunC compiler.
6+
Cross-platform bindings and CLI for TON FunC compiler.
77

88
## Features
99

1010
- 🚀 No need to compile of download FunC binaries
1111
- 📦 Works both in Node.js & WEB (WASM support is required)
1212
- ⚙️ Compiles straight to BOC with code Cell
13-
- ⚙️ Assembly is returned fot debugging purposes
14-
- 📁 Does not depend on file-system
13+
- ⚙️ Assembly is returned for debugging purposes
14+
- 📁 Does not depend on filesystem
1515

1616
## How it works
1717

@@ -36,6 +36,11 @@ or
3636
npm i @ton-community/func-js
3737
```
3838

39+
## CLI
40+
Usage: `npx func-js ./stdlib.fc ./wallet.fc --boc ./output.boc`
41+
42+
See more output options by running `npx func-js -h`
43+
3944
## Usage example
4045

4146
```typescript
@@ -47,13 +52,13 @@ async function main() {
4752
let version = await compilerVersion();
4853

4954
let result = await compileFunc({
50-
// Entry points of your project
51-
entryPoints: ['main.fc'],
55+
// Targets of your project
56+
targets: ['main.fc'],
5257
// Sources
5358
sources: {
5459
"stdlib.fc": "<stdlibCode>",
5560
"main.fc": "<contractCode>",
56-
// Rest of the files which are included in main.fc if some
61+
// The rest of the files which are included in main.fc if any
5762
}
5863
});
5964

@@ -70,28 +75,43 @@ async function main() {
7075
}
7176
```
7277

73-
You can also pass a resolver (a function of type `(path: string) => string`) into `sources` instead of a source map object, for example if `main.fc` and all contracts used by it (such as `stdlib.fc`) are located in the same directory as the compiling file, you can use the following:
78+
Instead of a source map, you can also use a source array, like so:
79+
```typescript
80+
let result = await compileFunc({
81+
// Sources
82+
sources: [
83+
{
84+
filename: "stdlib.fc",
85+
content: "<stdlibCode>",
86+
},
87+
{
88+
filename: "main.fc",
89+
content: "<contractCode>",
90+
},
91+
// The rest of the files which are included in main.fc if any
92+
]
93+
});
94+
```
95+
Notice that passing a sources *array* makes `targets` optional (if not passed, `targets` will be set to `filename`s of `sources` in the order they were given).
96+
97+
You can also pass a resolver (a function of type `(path: string) => string`) into `sources` instead of a source map object or array, for example if `main.fc` and all contracts used by it (such as `stdlib.fc`) are located in the same directory as the compiling .ts/.js file, you can use the following:
7498
```typescript
7599
import { readFileSync } from "fs";
76100
import { compileFunc } from "@ton-community/func-js";
77101

78102
let result = await compileFunc({
79-
// Entry points of your project
80-
entryPoints: ['main.fc'],
103+
// Targets of your project
104+
targets: ['main.fc'],
81105
// Sources
82106
sources: (path) => readFileSync(__dirname + '/' + path).toString()
83107
});
84108
```
85-
And the resolver will be called for each required source file (including the entrypoints) using the same name as in the `#include` statement. Note however that the resolver must be synchronous and must return a string; if you need the resolver to get files from the network, you can repeatedly run the compiler with the known sources, check if the compilation failed, download the required sources and rerun the compiler until compilation succeeds.
109+
And the resolver will be called for each required source file (including the targets) using the same name as in the `#include` statement. Note however that the resolver must be synchronous and must return a string; if you need the resolver to get files from the network, you can repeatedly run the compiler with the known sources, check if the compilation failed, download the required sources and rerun the compiler until compilation succeeds.
86110

87-
Note that all FunC source files contents used in your project should be passed to `sources` (if it is a source map) or be resolvable by it (if it is a resolver), including:
88-
- entry points
111+
Note that all FunC source files contents used in your project should be passed to `sources` (if it is a source map or array) or be resolvable by it (if it is a resolver), including:
112+
- targets
89113
- stdlib.fc (if you use it)
90-
- all files included in entry points
91-
92-
## CLI
93-
Usage: `npx func-js ./stdlib.fc ./wallet.fc --boc ./output.boc`
94-
See more output options by running `npx func-js -h`
114+
- all files included in targets
95115

96116
## License
97117

0 commit comments

Comments
 (0)