@graphox/swc-plugin 0.2.0 → 0.2.2
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/dist/index.js +11 -2
- package/package.json +11 -5
- package/wasm/.gitkeep +8 -0
- package/wasm/graphox_swc_plugin.wasm +0 -0
package/dist/index.js
CHANGED
|
@@ -28,6 +28,14 @@
|
|
|
28
28
|
*/
|
|
29
29
|
import * as path from 'path';
|
|
30
30
|
import * as fs from 'fs';
|
|
31
|
+
import { fileURLToPath } from 'url';
|
|
32
|
+
/**
|
|
33
|
+
* Robust way to get __dirname equivalent in both CJS and ESM.
|
|
34
|
+
*/
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
const _dirname = typeof import.meta.url !== 'undefined'
|
|
37
|
+
? path.dirname(fileURLToPath(import.meta.url))
|
|
38
|
+
: __dirname;
|
|
31
39
|
/**
|
|
32
40
|
* Get the path to the WASM plugin.
|
|
33
41
|
*
|
|
@@ -35,8 +43,9 @@ import * as fs from 'fs';
|
|
|
35
43
|
* and bundled with this package.
|
|
36
44
|
*/
|
|
37
45
|
function getWasmPath() {
|
|
38
|
-
// The WASM file
|
|
39
|
-
|
|
46
|
+
// The WASM file is built using cargo build --target wasm32-wasip1
|
|
47
|
+
// and placed in the wasm/ directory.
|
|
48
|
+
const wasmPath = path.join(_dirname, '..', 'wasm', 'graphox_swc_plugin.wasm');
|
|
40
49
|
if (!fs.existsSync(wasmPath)) {
|
|
41
50
|
throw new Error(`WASM plugin not found at ${wasmPath}. ` +
|
|
42
51
|
'Run "pnpm run build:wasm" to build the plugin.');
|
package/package.json
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphox/swc-plugin",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
7
13
|
"files": [
|
|
8
14
|
"dist/",
|
|
9
15
|
"wasm/",
|
|
@@ -35,7 +41,7 @@
|
|
|
35
41
|
"license": "UNLICENSED",
|
|
36
42
|
"scripts": {
|
|
37
43
|
"build": "tsc",
|
|
38
|
-
"build:wasm": "
|
|
44
|
+
"build:wasm": "cargo build --manifest-path ../rust/Cargo.toml --target wasm32-wasip1 --release && mkdir -p wasm && cp ../../../target/wasm32-wasip1/release/graphox_swc_plugin.wasm wasm/",
|
|
39
45
|
"build:all": "pnpm run build:wasm && pnpm run build",
|
|
40
46
|
"test": "vitest run"
|
|
41
47
|
}
|
package/wasm/.gitkeep
ADDED
|
Binary file
|