@zntc/wasm 0.1.2 → 0.1.3

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 CHANGED
@@ -1,72 +1,78 @@
1
1
  # @zntc/wasm
2
2
 
3
- ZNTC WASM 빌드 — 브라우저 / Bun / Node 환경에서 native binary (`zntc.node`) 없이 순수 WASM 으로 트랜스파일/번들 실행.
3
+ English · **[한국어](./README_KO.md)**
4
4
 
5
- `@zntc/core` NAPI 모듈을 없는 환경 (Edge runtime, Cloudflare Workers, 브라우저 in-page transpile 등) 용.
5
+ > WASM build of [ZNTC](https://github.com/ohah/zntc) transpile and bundle JavaScript / TypeScript / Flow in the browser, Deno, or Cloudflare Workers, with no native binary required.
6
6
 
7
- ## 설치
7
+ [![npm](https://img.shields.io/npm/v/@zntc/wasm.svg)](https://www.npmjs.com/package/@zntc/wasm)
8
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/ohah/zntc/blob/main/LICENSE)
9
+
10
+ `@zntc/wasm` runs the ZNTC pipeline as pure WebAssembly. It's for environments where the `@zntc/core` NAPI module can't be loaded — browser in-page transpile, Edge runtimes, Cloudflare Workers, Deno — without needing a platform-specific `.node` binary.
11
+
12
+ For server-side builds on Node / Bun, prefer [`@zntc/core`](https://www.npmjs.com/package/@zntc/core) (native speed). Reach for `@zntc/wasm` when the environment rules out NAPI.
13
+
14
+ ## Installation
8
15
 
9
16
  ```bash
10
17
  bun add -D @zntc/wasm
11
- # 또는
18
+ # or
12
19
  npm i -D @zntc/wasm
13
20
  ```
14
21
 
15
- WASM binary (`zntc.wasm` ~1.1MB / `zntc-bundler.wasm` ~2.0MB, gzipped 시 388KB / 675KB) 함께 install 됨.
22
+ The WASM binaries ship with the package: `zntc.wasm` (~1.1 MB / 388 KB gzipped, transpile-only) and `zntc-bundler.wasm` (~2.0 MB / 675 KB gzipped, bundler).
16
23
 
17
- ## 사용 예
24
+ ## Usage
18
25
 
19
- ### Browser / Edge runtime
26
+ ### Browser / Edge runtime / Workers
20
27
 
21
28
  ```ts
22
29
  import { init, transpile } from '@zntc/wasm';
23
- import wasmUrl from '@zntc/wasm/zntc.wasm?url'; // Vite 전용 syntax
30
+ import wasmUrl from '@zntc/wasm/zntc.wasm?url'; // Vite-specific syntax
24
31
 
25
32
  await init(wasmUrl);
26
- const r = transpile('const x: number = 1;', { filename: 'input.ts' });
27
- console.log(r.code);
33
+ const result = transpile('const x: number = 1;', { filename: 'input.ts' });
34
+ console.log(result.code);
28
35
  ```
29
36
 
30
- > Vite 아닌 bundler `fetch(new URL('@zntc/wasm/zntc.wasm', import.meta.url))` 또는 각자의 asset import 패턴 사용.
37
+ > Bundlers other than Vite use `fetch(new URL('@zntc/wasm/zntc.wasm', import.meta.url))` or their own asset-import pattern to obtain the WASM URL.
31
38
 
32
- ### Node.js / Bun (auto-resolve)
39
+ ### Deno / Node.js / Bun (auto-resolve)
33
40
 
34
41
  ```ts
35
42
  import { init, transpile } from '@zntc/wasm';
36
43
 
37
- await init(); // 동봉 zntc.wasm 자동 로드 (fs.readFileSync)
38
- const r = transpile('const x: number = 1;', { filename: 'input.ts' });
44
+ await init(); // loads the bundled zntc.wasm automatically (fs.readFileSync)
45
+ const result = transpile('const x: number = 1;', { filename: 'input.ts' });
39
46
  ```
40
47
 
41
- ### Bundler 사용
48
+ ### Bundler build
42
49
 
43
50
  ```ts
44
- import { bundlerLastErrorMessage, build, initBundler } from '@zntc/wasm';
51
+ import { build, initBundler, bundlerLastErrorMessage } from '@zntc/wasm';
45
52
  import wasmUrl from '@zntc/wasm/zntc-bundler.wasm?url';
46
53
 
47
- await initBundler(wasmUrl); // transpile init() 별도
54
+ await initBundler(wasmUrl); // separate from init() used for transpile
48
55
  const out = build('/main.ts', { format: 'esm', target: 'es2020' });
49
56
  if (out === null) throw new Error(bundlerLastErrorMessage());
50
57
  ```
51
58
 
52
- `build` sync 이며 실패 `null` 반환 — `bundlerLastErrorMessage()` 마지막 에러 조회.
53
-
54
- ## NAPI 와 차이
59
+ `build` is synchronous and returns `null` on failure call `bundlerLastErrorMessage()` to read the last error.
55
60
 
56
- | 항목 | @zntc/core (NAPI) | @zntc/wasm |
57
- | ----------- | ----------------- | ------------------------------------- |
58
- | 환경 | Node.js / Bun | + Browser / Edge / Workers |
59
- | 속도 | 빠름 (~native) | 50~70% (WASM 오버헤드) |
60
- | binary 크기 | ~4MB (.node) | 1.1MB + 2.0MB (gzipped 388KB + 675KB) |
61
- | install | 플랫폼별 prebuilt | 단일 wasm (universal) |
61
+ ## `@zntc/core` vs `@zntc/wasm`
62
62
 
63
- 대부분의 server-side 빌드 사용 사례는 `@zntc/core` 권장. `@zntc/wasm` 은 환경 제약 시.
63
+ | | `@zntc/core` (NAPI) | `@zntc/wasm` |
64
+ | ----------- | --------------------- | ----------------------------------------- |
65
+ | Environment | Node.js / Bun | + Browser / Edge / Workers / Deno |
66
+ | Speed | Native | ~50–70% (WASM overhead) |
67
+ | Binary size | ~4 MB (`.node`) | 1.1 MB + 2.0 MB (388 KB + 675 KB gzipped) |
68
+ | Install | Per-platform prebuilt | Single universal `.wasm` |
64
69
 
65
- ## 관련
70
+ ## Documentation
66
71
 
67
- - [@zntc/core](https://npmjs.com/package/@zntc/core) — Native (NAPI) 빌드
68
- - [docs/USAGE.md](https://github.com/ohah/zts/blob/main/docs/USAGE.md)
72
+ - Repository: <https://github.com/ohah/zntc>
73
+ - Official docs: <https://ohah.github.io/zntc>
74
+ - Native build: [`@zntc/core`](https://www.npmjs.com/package/@zntc/core)
69
75
 
70
- ## 라이센스
76
+ ## License
71
77
 
72
- MIT.
78
+ MIT
package/dist/index.js CHANGED
@@ -7,17 +7,17 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
7
7
  });
8
8
  // ../shared/index.ts
9
9
  var ES_TARGET_BITS = {
10
- es5: 268435455,
11
- es2015: 117438464,
12
- es2016: 117436416,
13
- es2017: 117432320,
14
- es2018: 16760832,
15
- es2019: 16744448,
16
- es2020: 16646144,
17
- es2021: 16515072,
18
- es2022: 12582912,
19
- es2023: 8388608,
20
- es2024: 8388608,
10
+ es5: 2147483647,
11
+ es2015: 1996486656,
12
+ es2016: 1996484608,
13
+ es2017: 1996480512,
14
+ es2018: 822067200,
15
+ es2019: 822050816,
16
+ es2020: 821952512,
17
+ es2021: 821821440,
18
+ es2022: 817889280,
19
+ es2023: 813694976,
20
+ es2024: 813694976,
21
21
  es2025: 0,
22
22
  esnext: 0
23
23
  };
@@ -11,7 +11,7 @@
11
11
  */
12
12
  export type Engine = 'chrome' | 'firefox' | 'safari' | 'edge' | 'node' | 'deno' | 'ios' | 'opera' | 'hermes';
13
13
  /** compat.zig의 Feature enum과 동일 순서. bit 위치 = 배열 인덱스. */
14
- export declare const FEATURES: readonly ["arrow", "class", "template_literal", "destructuring", "for_of", "spread", "object_extensions", "default_params", "block_scoping", "generator", "new_target", "exponentiation", "async_await", "object_spread", "optional_catch_binding", "nullish_coalescing", "optional_chaining", "logical_assignment", "class_static_block", "class_private_method", "class_private_field", "top_level_await", "hashbang", "using", "regex_sticky", "regex_dotall", "regex_named_groups", "unicode_brace_escape"];
14
+ export declare const FEATURES: readonly ["arrow", "class", "template_literal", "destructuring", "for_of", "spread", "object_extensions", "default_params", "block_scoping", "generator", "new_target", "exponentiation", "async_await", "object_spread", "optional_catch_binding", "nullish_coalescing", "optional_chaining", "logical_assignment", "class_static_block", "class_private_method", "class_private_field", "top_level_await", "hashbang", "using", "regex_sticky", "regex_dotall", "regex_named_groups", "unicode_brace_escape", "regex_duplicate_named_groups", "regex_modifiers", "regex_lookbehind"];
15
15
  export type Feature = (typeof FEATURES)[number];
16
16
  /**
17
17
  * feature × engine → 최소 지원 버전 [major, minor].
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zntc/wasm",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "ZNTC native transpiler & compiler — WASM build",
5
5
  "keywords": [
6
6
  "browser",
package/zntc-bundler.wasm CHANGED
Binary file
package/zntc.wasm CHANGED
Binary file