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
You may also use the selective build options found in the [Kernel Library Selective Build guide](../../docs/source/kernel-library-selective-build.md) or with optimized kernels using the `EXECUTORCH_BUILD_KERNELS_OPTIMIZED` option. Portable kernels are used by default.
36
+
To reduce the binary size, you may also use the selective build options found in the [Kernel Library Selective Build guide](../../docs/source/kernel-library-selective-build.md). You may also use optimized kernels with the `EXECUTORCH_BUILD_KERNELS_OPTIMIZED` option. Portable kernels are used by default.
37
37
38
38
### Building for Web
39
39
@@ -63,37 +63,17 @@ Building this should output `executorch_wasm_lib.js` and `executorch_wasm_lib.wa
63
63
<scriptsrc="executorch_wasm_lib.js"></script>
64
64
```
65
65
66
-
Alternatively, you may want to have your code come after the JS library code.
67
-
68
-
```html
69
-
<scriptsrc="executorch_wasm_lib.js"></script>
70
-
<script>
71
-
constet= Module; // Assign Module into et for ease of use
72
-
et.onRuntimeInitialized= () => {
73
-
// Emscripten calls Module.onRuntimeInitialized once the runtime is ready.
74
-
constmodel=et.Module.load("mv2.pte");
75
-
// ...
76
-
}
77
-
</script>
78
-
```
79
-
80
66
### Building for Node.js
81
67
82
-
You can follow the [Building for Web](#building-for-web) instructions and access the API with:
83
-
84
-
```js
85
-
constet=require("./executorch_wasm_lib");
86
-
```
87
-
88
-
However, doing so does not give you access to the [Emscripten API](https://emscripten.org/docs/api_reference/index.html) which would be stored in the globals. For example, you may want to use the [File System API](https://emscripten.org/docs/api_reference/Filesystem-API.html) in your unit tests, which cannot be done if the library is loaded with `require`. Instead, you can use the `--pre-js` or `--post-js` to prepend or append your file to the end of the JS output.
68
+
While the standard way to import a module in Node.js is to use the `require` function, doing so does not give you access to the [Emscripten API](https://emscripten.org/docs/api_reference/index.html) which would be stored in the globals. For example, you may want to use the [File System API](https://emscripten.org/docs/api_reference/Filesystem-API.html) in your unit tests, which cannot be done if the library is loaded with `require`. Instead, you can use the `--pre-js` option to prepend your file to the start of the JS output and behave similarly to the example in the [Web build](#building-for-web).
89
69
90
70
```cmake
91
71
add_executable(my_project) # Emscripten outputs this as a JS and Wasm file
0 commit comments