emsdk-env 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -2
- package/dist/build-oenTJc-4.cjs +782 -0
- package/dist/build-oenTJc-4.cjs.map +1 -0
- package/dist/build-qp0IEBnb.js +783 -0
- package/dist/build-qp0IEBnb.js.map +1 -0
- package/dist/index.cjs +5 -298
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +76 -5
- package/dist/index.mjs +5 -298
- package/dist/index.mjs.map +1 -1
- package/dist/vite.cjs +686 -9
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.ts +40 -6
- package/dist/vite.mjs +686 -9
- package/dist/vite.mjs.map +1 -1
- package/images/emsdk-env-120.png +0 -0
- package/package.json +15 -11
package/README.md
CHANGED
|
@@ -1,10 +1,98 @@
|
|
|
1
1
|
# emsdk-env
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A Vite plugin that automatically builds WASM C/C++ source code using the Emscripten SDK.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
[](https://www.repostatus.org/#wip)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
WIP:
|
|
4
13
|
|
|
5
14
|
## What is this?
|
|
6
15
|
|
|
7
|
-
|
|
16
|
+
This is a Vite plugin that automatically downloads and manages the Emscripten SDK, and makes it possible to automatically build WASM C/C++ code in your project.
|
|
17
|
+
With this plugin, you can easily set up a WASM C/C++ development environment in your Vite project.
|
|
18
|
+
|
|
19
|
+
Usage is simple. Just add this Vite plugin package to your project and initialize the plugin in `vite.config.ts` like this:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
// `vite.config.ts`
|
|
23
|
+
import { defineConfig } from 'vite';
|
|
24
|
+
|
|
25
|
+
// Refer to the emsdk-env Vite plugin
|
|
26
|
+
import emsdkEnv from 'emsdk-env/vite';
|
|
27
|
+
|
|
28
|
+
export default defineConfig({
|
|
29
|
+
plugins: [
|
|
30
|
+
// Add as a plugin
|
|
31
|
+
emsdkEnv({
|
|
32
|
+
// Build targets
|
|
33
|
+
targets: {
|
|
34
|
+
// Generate "add.wasm"
|
|
35
|
+
add: {
|
|
36
|
+
// Compiler options
|
|
37
|
+
options: ['-O3', '-std=c99'],
|
|
38
|
+
// Linker options
|
|
39
|
+
linkOptions: ['-s', 'STANDALONE_WASM=1', '--no-entry'],
|
|
40
|
+
// Exported symbols
|
|
41
|
+
exports: ['_add'],
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
}),
|
|
45
|
+
],
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
If the source code changes, it will automatically rebuild and reload the page.
|
|
50
|
+
You can focus on writing C/C++ code just like you would TypeScript/JavaScript code!
|
|
51
|
+
|
|
52
|
+
### Features
|
|
53
|
+
|
|
54
|
+
- Automatic setup and caching of the Emscripten SDK
|
|
55
|
+
- HMR support via Vite plugin (Note: C/C++ code requires a full build)
|
|
56
|
+
- Support for parallel builds
|
|
57
|
+
- Simplified specification of export symbols
|
|
58
|
+
- Ability to generate multiple target WASM binaries
|
|
59
|
+
- Customizable directory paths, compile options, and linker options
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Usage
|
|
64
|
+
|
|
65
|
+
### Installation
|
|
66
|
+
|
|
67
|
+
Add to `devDependencies` (emsdk-env itself does not require runtime code):
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
$ npm install -D emsdk-env
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### C/C++ Source Code and Binary Placement
|
|
74
|
+
|
|
75
|
+
By default, C/C++ source code is placed in the `wasm/` directory under your project,
|
|
76
|
+
and the built WASM binaries are placed in the `src/wasm/` directory.
|
|
77
|
+
|
|
78
|
+
A typical directory structure looks like this:
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
project/
|
|
82
|
+
├── package.json
|
|
83
|
+
├── vite.config.ts
|
|
84
|
+
├── src/
|
|
85
|
+
│ └── wasm/
|
|
86
|
+
│ └── add.wasm
|
|
87
|
+
└── wasm/
|
|
88
|
+
└── add.c
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Documents
|
|
92
|
+
|
|
93
|
+
For more information, please visit repository and refer README: [emsdk-env](https://github.com/kekyo/emsdk-env)
|
|
94
|
+
|
|
95
|
+
---
|
|
8
96
|
|
|
9
97
|
## License
|
|
10
98
|
|