You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See more output options by running `npx func-js -h`
43
+
39
44
## Usage example
40
45
41
46
```typescript
@@ -47,13 +52,13 @@ async function main() {
47
52
let version =awaitcompilerVersion();
48
53
49
54
let result =awaitcompileFunc({
50
-
//Entry points of your project
51
-
entryPoints: ['main.fc'],
55
+
//Targets of your project
56
+
targets: ['main.fc'],
52
57
// Sources
53
58
sources: {
54
59
"stdlib.fc": "<stdlibCode>",
55
60
"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
57
62
}
58
63
});
59
64
@@ -70,28 +75,43 @@ async function main() {
70
75
}
71
76
```
72
77
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 =awaitcompileFunc({
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:
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.
86
110
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:
0 commit comments