@afterpack/wasm 0.2.8 → 1.0.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/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/engine/afterpack_engine_bg.wasm +0 -0
- package/package.json +1 -1
- package/readme.md +23 -2
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PACKAGE_VERSION = "0.
|
|
1
|
+
export declare const PACKAGE_VERSION = "1.0.0-rc.202610210240";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const PACKAGE_VERSION = "0.
|
|
1
|
+
export const PACKAGE_VERSION = "1.0.0-rc.202610210240";
|
|
Binary file
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -28,6 +28,27 @@ export default {
|
|
|
28
28
|
};
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
+
### Pro from a Worker
|
|
32
|
+
|
|
33
|
+
Add your Pro key to the same call. The build then runs on AfterPack's cloud with Pro features, and files too big for a Worker move to containers automatically. The Pro build never ships into your Worker.
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
export default {
|
|
37
|
+
async fetch(request, env) {
|
|
38
|
+
const source = await request.text();
|
|
39
|
+
const result = await obfuscate(
|
|
40
|
+
{ path: "app.js", source },
|
|
41
|
+
{ preset: "hard", key: env.AFTERPACK_KEY }, // your key, stored as a Worker secret
|
|
42
|
+
);
|
|
43
|
+
return new Response(result.bytes, {
|
|
44
|
+
headers: { "content-type": "application/javascript" },
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Tip: each Pro call is a metered build, so cache the result for a rotation window. Key the [Cache API](https://developers.cloudflare.com/workers/runtime-apis/cache/) by the asset and the window, and each asset is built once per window instead of on every request.
|
|
51
|
+
|
|
31
52
|
The full guide: [obfuscate JavaScript in a Cloudflare Worker](https://www.afterpack.dev/docs/workers).
|
|
32
53
|
|
|
33
54
|
## In Node
|
|
@@ -77,8 +98,8 @@ Without a key, all of Free runs inside your Worker or Node process, with every p
|
|
|
77
98
|
|
|
78
99
|
| Measure | Bytes | |
|
|
79
100
|
|---|---:|---|
|
|
80
|
-
| Raw `.wasm` | 4,
|
|
81
|
-
| Gzipped | 1,
|
|
101
|
+
| Raw `.wasm` | 4,640,237 | 4.43 MiB |
|
|
102
|
+
| Gzipped | 1,325,736 | 1.26 MiB |
|
|
82
103
|
|
|
83
104
|
This fits Cloudflare's Worker size limit on both the free and paid plans. CPU time is the tighter limit: the free plan allows 10 ms per request, and obfuscating a 185 KB bundle at `complexity: 8` takes about 263 ms on an Apple M-series laptop. Plan on Workers Paid for real bundles.
|
|
84
105
|
|