@zntc/rspack-loader 0.1.1 → 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,18 +1,27 @@
1
1
  # @zntc/rspack-loader
2
2
 
3
- Rspack / Webpack 5 의 `swc-loader` / `esbuild-loader` / `babel-loader` 자리를 ZNTC (Zig 기반 트랜스파일러) 로 교체하는 loader. TypeScript / JSX / Flow / decorators 변환을 ZNTC 가 담당.
3
+ English · **[한국어](./README_KO.md)**
4
4
 
5
- ## 설치
5
+ > TypeScript / JSX / Flow loader for Rspack and Webpack — a drop-in replacement for `swc-loader` / `esbuild-loader` / `babel-loader`, powered by ZNTC (a Zig-based native transpiler).
6
+
7
+ [![npm](https://img.shields.io/npm/v/@zntc/rspack-loader.svg)](https://www.npmjs.com/package/@zntc/rspack-loader)
8
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/ohah/zntc/blob/main/LICENSE)
9
+
10
+ This loader hands TypeScript / JSX / Flow / decorator transforms to ZNTC, so you can drop it straight into the slot where `builtin:swc-loader`, `esbuild-loader`, or `babel-loader` used to live. The loader API is shared between Rspack and Webpack 5, so the same configuration works on both.
11
+
12
+ ## Installation
6
13
 
7
14
  ```bash
8
15
  bun add -D @zntc/rspack-loader @zntc/core
9
- # 또는
16
+ # or
10
17
  npm i -D @zntc/rspack-loader @zntc/core
11
18
  ```
12
19
 
13
- `@zntc/core` dependency 함께 따라옴 (NAPI binary 포함).
20
+ `@zntc/core` (which ships the native NAPI binary) is pulled in as a dependency.
14
21
 
15
- ## 사용 — Rspack
22
+ ## Usage
23
+
24
+ ### Rspack
16
25
 
17
26
  ```js
18
27
  // rspack.config.mjs
@@ -32,9 +41,9 @@ export default {
32
41
  };
33
42
  ```
34
43
 
35
- `builtin:swc-loader` 를 쓰던 자리에 그대로 대체 가능.
44
+ Drops straight into the slot where you previously used `builtin:swc-loader`.
36
45
 
37
- ## 사용 — Webpack 5
46
+ ### Webpack 5
38
47
 
39
48
  ```js
40
49
  // webpack.config.mjs
@@ -56,9 +65,9 @@ export default {
56
65
  };
57
66
  ```
58
67
 
59
- loader API webpack/rspack 공통이라 동일 코드로 양쪽 동작.
68
+ The loader API is shared across Webpack and Rspack, so the same code runs on both.
60
69
 
61
- ## 옵션
70
+ ### Options
62
71
 
63
72
  ```ts
64
73
  interface ZntcLoaderOptions {
@@ -67,78 +76,78 @@ interface ZntcLoaderOptions {
67
76
  }
68
77
  ```
69
78
 
70
- ### `tsconfigCache` (default: `true`)
79
+ #### `tsconfigCache` (default: `true`)
71
80
 
72
- tsconfig autodiscover walk 결과를 worker 별로 캐시. dev/watch 세션에서 같은 워크스페이스 파일은 번만 walk file 5–10 fs syscall 절약. `transpileOptions.tsconfigPath` / `tsconfigRaw` 명시 자동 무시.
81
+ Caches the result of the tsconfig autodiscover walk per worker. In dev / watch sessions, files inside the same workspace are walked only once saving 5–10 fs syscalls per file. Automatically ignored when `transpileOptions.tsconfigPath` / `tsconfigRaw` is set explicitly.
73
82
 
74
- ### `transpileOptions`
83
+ #### `transpileOptions`
75
84
 
76
- `@zntc/core` `TranspileOptions` 동일 (`filename` loader `this.resourcePath` 로 자동 채움).
85
+ Identical to `TranspileOptions` from `@zntc/core` only `filename` is filled in automatically by the loader from `this.resourcePath`.
77
86
 
78
- #### Target / 모듈
87
+ **Target / module**
79
88
 
80
- | 옵션 | 타입 | 설명 |
81
- | -------------- | ---------------------------------------------------- | ---------------------------------------------- |
82
- | `target` | `'es5' \| 'es2015' \| ... \| 'es2024' \| 'esnext'` | ES 다운레벨 타겟 |
83
- | `browserslist` | `string \| string[]` | browserslist 쿼리 (지정 `target` 보다 우선) |
84
- | `platform` | `'browser' \| 'node' \| 'neutral' \| 'react-native'` | 타겟 플랫폼 |
85
- | `format` | `'esm' \| 'cjs'` | 모듈 포맷 |
89
+ | Option | Type | Description |
90
+ | -------------- | ---------------------------------------------------- | --------------------------------------------------- |
91
+ | `target` | `'es5' \| 'es2015' \| ... \| 'es2024' \| 'esnext'` | ES downlevel target |
92
+ | `browserslist` | `string \| string[]` | browserslist query (takes precedence over `target`) |
93
+ | `platform` | `'browser' \| 'node' \| 'neutral' \| 'react-native'` | Target platform |
94
+ | `format` | `'esm' \| 'cjs'` | Module format |
86
95
 
87
- #### JSX
96
+ **JSX**
88
97
 
89
- | 옵션 | 타입 | 설명 |
98
+ | Option | Type | Description |
90
99
  | ----------------- | --------------------------------------------- | ----------------------------------------------- |
91
- | `jsx` | `'classic' \| 'automatic' \| 'automatic-dev'` | JSX 런타임 |
100
+ | `jsx` | `'classic' \| 'automatic' \| 'automatic-dev'` | JSX runtime |
92
101
  | `jsxFactory` | `string` | classic factory (default `React.createElement`) |
93
102
  | `jsxFragment` | `string` | classic Fragment (default `React.Fragment`) |
94
103
  | `jsxImportSource` | `string` | automatic import source (default `react`) |
95
- | `jsxInJs` | `boolean` | `.js` 에서도 JSX 허용 |
96
-
97
- #### TypeScript / Flow / Decorator
98
-
99
- | 옵션 | 타입 | 설명 |
100
- | ------------------------- | --------- | ------------------------------------------------------------------ |
101
- | `tsconfigPath` | `string` | tsconfig.json 경로 (파일 또는 디렉토리). compilerOptions 자동 머지 |
102
- | `tsconfigRaw` | `string` | inline tsconfig JSON 문자열 (esbuild 동일 의미) |
103
- | `verbatimModuleSyntax` | `boolean` | TS 5.0+: 미사용 import elide |
104
- | `useDefineForClassFields` | `boolean` | class field → constructor `this.x = v` 변환 (default: `true`) |
105
- | `flow` | `boolean` | Flow 타입 스트리핑 |
106
- | `experimentalDecorators` | `boolean` | legacy decorator 변환 |
107
- | `emitDecoratorMetadata` | `boolean` | decorator metadata emit |
108
-
109
- #### 소스맵
110
-
111
- | 옵션 | 타입 | 설명 |
112
- | ------------------- | --------- | -------------------------------- |
113
- | `sourcemap` | `boolean` | 소스맵 생성 |
114
- | `sourcemapDebugIds` | `boolean` | Sentry 호환 Debug ID |
115
- | `sourcesContent` | `boolean` | 원본 소스 포함 (default: `true`) |
116
- | `sourceRoot` | `string` | 소스맵 sourceRoot 필드 |
117
-
118
- #### Minify
119
-
120
- | 옵션 | 타입 | 설명 |
121
- | ------------------- | --------- | -------------------------------------- |
122
- | `minify` | `boolean` | whitespace + identifiers + syntax 전체 |
123
- | `minifyWhitespace` | `boolean` | 공백 축소만 |
124
- | `minifyIdentifiers` | `boolean` | 식별자 축소만 |
125
- | `minifySyntax` | `boolean` | 구문 축소만 |
126
- | `dropConsole` | `boolean` | `console.*` 호출 제거 |
127
- | `dropDebugger` | `boolean` | `debugger` 문 제거 |
128
-
129
- #### 기타
130
-
131
- | 옵션 | 타입 | 설명 |
132
- | ------------- | ------------------------------------------------------------- | -------------------------------------- |
133
- | `define` | `Array<{ key: string; value: string }>` | 식별자 치환 (`value` raw JSON) |
134
- | `quotes` | `'double' \| 'single' \| 'preserve'` | 문자열 따옴표 스타일 |
135
- | `asciiOnly` | `boolean` | non-ASCII `\uXXXX` 이스케이프 |
136
- | `charsetUtf8` | `boolean` | non-ASCII 이스케이프 안 함 |
137
- | `stopAfter` | `'scan' \| 'parse' \| 'semantic' \| 'transform' \| 'codegen'` | 디버그/프로파일해당 phase 이후 skip |
138
-
139
- 전체 옵션 정의는 [`@zntc/core` TranspileOptions](https://github.com/ohah/zntc/blob/main/packages/shared/index.ts) 참고.
140
-
141
- ## 예시 — `define` 으로 환경변수 치환
104
+ | `jsxInJs` | `boolean` | Allow JSX in `.js` files too |
105
+
106
+ **TypeScript / Flow / Decorator**
107
+
108
+ | Option | Type | Description |
109
+ | ------------------------- | --------- | ---------------------------------------------------------------------- |
110
+ | `tsconfigPath` | `string` | Path to tsconfig.json (file or directory); compilerOptions auto-merged |
111
+ | `tsconfigRaw` | `string` | Inline tsconfig JSON string (same semantics as esbuild) |
112
+ | `verbatimModuleSyntax` | `boolean` | TS 5.0+: do not elide unused imports |
113
+ | `useDefineForClassFields` | `boolean` | Transform class fields → constructor `this.x = v` (default: `true`) |
114
+ | `flow` | `boolean` | Flow type stripping |
115
+ | `experimentalDecorators` | `boolean` | Legacy decorator transform |
116
+ | `emitDecoratorMetadata` | `boolean` | Emit decorator metadata |
117
+
118
+ **Source maps**
119
+
120
+ | Option | Type | Description |
121
+ | ------------------- | --------- | ------------------------------------------ |
122
+ | `sourcemap` | `boolean` | Generate source maps |
123
+ | `sourcemapDebugIds` | `boolean` | Sentry-compatible Debug IDs |
124
+ | `sourcesContent` | `boolean` | Include original sources (default: `true`) |
125
+ | `sourceRoot` | `string` | source map `sourceRoot` field |
126
+
127
+ **Minify**
128
+
129
+ | Option | Type | Description |
130
+ | ------------------- | --------- | ---------------------------------------------- |
131
+ | `minify` | `boolean` | whitespace + identifiers + syntax (everything) |
132
+ | `minifyWhitespace` | `boolean` | whitespace only |
133
+ | `minifyIdentifiers` | `boolean` | identifiers only |
134
+ | `minifySyntax` | `boolean` | syntax only |
135
+ | `dropConsole` | `boolean` | Remove `console.*` calls |
136
+ | `dropDebugger` | `boolean` | Remove `debugger` statements |
137
+
138
+ **Other**
139
+
140
+ | Option | Type | Description |
141
+ | ------------- | ------------------------------------------------------------- | --------------------------------------------- |
142
+ | `define` | `Array<{ key: string; value: string }>` | Identifier substitution (`value` is raw JSON) |
143
+ | `quotes` | `'double' \| 'single' \| 'preserve'` | String quote style |
144
+ | `asciiOnly` | `boolean` | Escape non-ASCII as `\uXXXX` |
145
+ | `charsetUtf8` | `boolean` | Do not escape non-ASCII |
146
+ | `stopAfter` | `'scan' \| 'parse' \| 'semantic' \| 'transform' \| 'codegen'` | Debug / profile skip after the given phase |
147
+
148
+ For the full option definitions, see [`@zntc/core` `TranspileOptions`](https://github.com/ohah/zntc/blob/main/packages/shared/index.ts).
149
+
150
+ ### Exampleenvironment variable substitution with `define`
142
151
 
143
152
  ```js
144
153
  {
@@ -154,7 +163,7 @@ tsconfig autodiscover walk 결과를 worker 별로 캐시. dev/watch 세션에
154
163
  }
155
164
  ```
156
165
 
157
- ## 예시 — Flow 코드
166
+ ### Example — Flow code
158
167
 
159
168
  ```js
160
169
  {
@@ -164,7 +173,7 @@ tsconfig autodiscover walk 결과를 worker 별로 캐시. dev/watch 세션에
164
173
  }
165
174
  ```
166
175
 
167
- ## 예시 — tsconfig 명시 + decorator
176
+ ### Exampleexplicit tsconfig + decorators
168
177
 
169
178
  ```js
170
179
  {
@@ -179,13 +188,19 @@ tsconfig autodiscover walk 결과를 worker 별로 캐시. dev/watch 세션에
179
188
  }
180
189
  ```
181
190
 
182
- ## peer
191
+ ### Peer dependencies
183
192
 
184
- - `@rspack/core >= 1.0.0` (optional, rspack 1.x / 2.x 모두 지원)
193
+ - `@rspack/core >= 1.0.0` (optional both Rspack 1.x and 2.x are supported)
185
194
  - `webpack >= 5.0.0` (optional)
186
195
 
187
- 하나만 설치돼있어도 됨.
196
+ Installing either one is enough.
197
+
198
+ ## Documentation
199
+
200
+ - Monorepo: <https://github.com/ohah/zntc>
201
+ - Docs site: <https://ohah.github.io/zntc>
202
+ - Rspack / Webpack integration guide: <https://ohah.github.io/zntc/guides/rspack-loader/>
188
203
 
189
- ## 라이센스
204
+ ## License
190
205
 
191
- MIT.
206
+ MIT
package/dist/index.cjs CHANGED
@@ -14,7 +14,7 @@ function ensureInit(useCache) {
14
14
  }
15
15
  }
16
16
  function zntcLoader(source) {
17
- const callback = this.async(),options = (this.getOptions() ?? {}),transpileOpts = options.transpileOptions ?? {},useCache = options.tsconfigCache ?? true;
17
+ const callback = this.async(),options = this.getOptions() ?? {},transpileOpts = options.transpileOptions ?? {},useCache = options.tsconfigCache ?? true;
18
18
  try {
19
19
  ensureInit(useCache);
20
20
  const result = transpile(source, { ...transpileOpts, filename: this.resourcePath, cache: useCache ? cache : undefined });
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ function ensureInit(useCache) {
11
11
  }
12
12
  }
13
13
  function zntcLoader(source) {
14
- const callback = this.async(),options = (this.getOptions() ?? {}),transpileOpts = options.transpileOptions ?? {},useCache = options.tsconfigCache ?? true;
14
+ const callback = this.async(),options = this.getOptions() ?? {},transpileOpts = options.transpileOptions ?? {},useCache = options.tsconfigCache ?? true;
15
15
  try {
16
16
  ensureInit(useCache);
17
17
  const result = transpile(source, { ...transpileOpts, filename: this.resourcePath, cache: useCache ? cache : undefined });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zntc/rspack-loader",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Use ZNTC as the TypeScript/JSX/Flow transformer in Rspack and Webpack (drop-in alternative to swc-loader / esbuild-loader / babel-loader)",
5
5
  "keywords": [
6
6
  "babel-loader",
@@ -57,7 +57,7 @@
57
57
  "prepublishOnly": "bun run build && bunx publint --strict --level error ."
58
58
  },
59
59
  "dependencies": {
60
- "@zntc/core": "0.1.1"
60
+ "@zntc/core": "0.1.3"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@rspack/core": "^2.0.1",