oxc-transform 0.72.2 → 0.73.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 CHANGED
@@ -56,3 +56,7 @@ export function isolatedDeclaration(
56
56
  options?: IsolatedDeclarationsOptions,
57
57
  ): IsolatedDeclarationsResult;
58
58
  ```
59
+
60
+ ### Supports WASM
61
+
62
+ See https://stackblitz.com/edit/oxc-transform for usage example.
package/index.d.ts CHANGED
@@ -1,5 +1,41 @@
1
1
  /* auto-generated by NAPI-RS */
2
2
  /* eslint-disable */
3
+ export interface Comment {
4
+ type: 'Line' | 'Block'
5
+ value: string
6
+ start: number
7
+ end: number
8
+ }
9
+
10
+ export interface ErrorLabel {
11
+ message?: string
12
+ start: number
13
+ end: number
14
+ }
15
+
16
+ export interface OxcError {
17
+ severity: Severity
18
+ message: string
19
+ labels: Array<ErrorLabel>
20
+ helpMessage?: string
21
+ codeframe?: string
22
+ }
23
+
24
+ export declare const enum Severity {
25
+ Error = 'Error',
26
+ Warning = 'Warning',
27
+ Advice = 'Advice'
28
+ }
29
+ export interface SourceMap {
30
+ file?: string
31
+ mappings: string
32
+ names: Array<string>
33
+ sourceRoot?: string
34
+ sources: Array<string>
35
+ sourcesContent?: Array<string>
36
+ version: number
37
+ x_google_ignoreList?: Array<number>
38
+ }
3
39
  export interface ArrowFunctionsOptions {
4
40
  /**
5
41
  * This option enables the following:
@@ -12,13 +48,6 @@ export interface ArrowFunctionsOptions {
12
48
  spec?: boolean
13
49
  }
14
50
 
15
- export interface Comment {
16
- type: 'Line' | 'Block'
17
- value: string
18
- start: number
19
- end: number
20
- }
21
-
22
51
  export interface CompilerAssumptions {
23
52
  ignoreFunctionLength?: boolean
24
53
  noDocumentAll?: boolean
@@ -91,12 +120,6 @@ export interface DecoratorOptions {
91
120
  emitDecoratorMetadata?: boolean
92
121
  }
93
122
 
94
- export interface ErrorLabel {
95
- message?: string
96
- start: number
97
- end: number
98
- }
99
-
100
123
  export interface Es2015Options {
101
124
  /** Transform arrow functions into function expressions. */
102
125
  arrowFunction?: ArrowFunctionsOptions
@@ -300,14 +323,6 @@ export interface ModuleRunnerTransformResult {
300
323
  errors: Array<OxcError>
301
324
  }
302
325
 
303
- export interface OxcError {
304
- severity: Severity
305
- message: string
306
- labels: Array<ErrorLabel>
307
- helpMessage?: string
308
- codeframe?: string
309
- }
310
-
311
326
  export interface ReactRefreshOptions {
312
327
  /**
313
328
  * Specify the identifier of the refresh registration variable.
@@ -324,23 +339,6 @@ export interface ReactRefreshOptions {
324
339
  emitFullSignatures?: boolean
325
340
  }
326
341
 
327
- export declare const enum Severity {
328
- Error = 'Error',
329
- Warning = 'Warning',
330
- Advice = 'Advice'
331
- }
332
-
333
- export interface SourceMap {
334
- file?: string
335
- mappings: string
336
- names: Array<string>
337
- sourceRoot?: string
338
- sources: Array<string>
339
- sourcesContent?: Array<string>
340
- version: number
341
- x_google_ignoreList?: Array<number>
342
- }
343
-
344
342
  /**
345
343
  * Transpile a JavaScript or TypeScript into a target ECMAScript version.
346
344
  *
package/index.js CHANGED
@@ -363,6 +363,14 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
363
363
  }
364
364
  }
365
365
 
366
+ if (!nativeBinding && globalThis.process?.versions?.["webcontainer"]) {
367
+ try {
368
+ nativeBinding = require('./webcontainer-fallback.js');
369
+ } catch (err) {
370
+ loadErrors.push(err)
371
+ }
372
+ }
373
+
366
374
  if (!nativeBinding) {
367
375
  if (loadErrors.length > 0) {
368
376
  // TODO Link to documentation with potential fixes
@@ -375,8 +383,8 @@ if (!nativeBinding) {
375
383
  }
376
384
 
377
385
  module.exports = nativeBinding
386
+ module.exports.Severity = nativeBinding.Severity
378
387
  module.exports.HelperMode = nativeBinding.HelperMode
379
388
  module.exports.isolatedDeclaration = nativeBinding.isolatedDeclaration
380
389
  module.exports.moduleRunnerTransform = nativeBinding.moduleRunnerTransform
381
- module.exports.Severity = nativeBinding.Severity
382
390
  module.exports.transform = nativeBinding.transform
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oxc-transform",
3
- "version": "0.72.2",
3
+ "version": "0.73.0",
4
4
  "main": "index.js",
5
5
  "browser": "browser.js",
6
6
  "engines": {
@@ -26,14 +26,15 @@
26
26
  "files": [
27
27
  "index.d.ts",
28
28
  "index.js",
29
- "browser.js"
29
+ "browser.js",
30
+ "webcontainer-fallback.js"
30
31
  ],
31
32
  "publishConfig": {
32
33
  "registry": "https://registry.npmjs.org/",
33
34
  "access": "public"
34
35
  },
35
36
  "devDependencies": {
36
- "vitest": "3.1.4",
37
+ "vitest": "3.2.2",
37
38
  "typescript": "5.8.3"
38
39
  },
39
40
  "napi": {
@@ -62,24 +63,25 @@
62
63
  }
63
64
  },
64
65
  "optionalDependencies": {
65
- "@oxc-transform/binding-win32-x64-msvc": "0.72.2",
66
- "@oxc-transform/binding-win32-arm64-msvc": "0.72.2",
67
- "@oxc-transform/binding-linux-x64-gnu": "0.72.2",
68
- "@oxc-transform/binding-linux-x64-musl": "0.72.2",
69
- "@oxc-transform/binding-freebsd-x64": "0.72.2",
70
- "@oxc-transform/binding-linux-arm64-gnu": "0.72.2",
71
- "@oxc-transform/binding-linux-arm64-musl": "0.72.2",
72
- "@oxc-transform/binding-linux-arm-gnueabihf": "0.72.2",
73
- "@oxc-transform/binding-linux-arm-musleabihf": "0.72.2",
74
- "@oxc-transform/binding-linux-s390x-gnu": "0.72.2",
75
- "@oxc-transform/binding-linux-riscv64-gnu": "0.72.2",
76
- "@oxc-transform/binding-darwin-x64": "0.72.2",
77
- "@oxc-transform/binding-darwin-arm64": "0.72.2",
78
- "@oxc-transform/binding-wasm32-wasi": "0.72.2"
66
+ "@oxc-transform/binding-win32-x64-msvc": "0.73.0",
67
+ "@oxc-transform/binding-win32-arm64-msvc": "0.73.0",
68
+ "@oxc-transform/binding-linux-x64-gnu": "0.73.0",
69
+ "@oxc-transform/binding-linux-x64-musl": "0.73.0",
70
+ "@oxc-transform/binding-freebsd-x64": "0.73.0",
71
+ "@oxc-transform/binding-linux-arm64-gnu": "0.73.0",
72
+ "@oxc-transform/binding-linux-arm64-musl": "0.73.0",
73
+ "@oxc-transform/binding-linux-arm-gnueabihf": "0.73.0",
74
+ "@oxc-transform/binding-linux-arm-musleabihf": "0.73.0",
75
+ "@oxc-transform/binding-linux-s390x-gnu": "0.73.0",
76
+ "@oxc-transform/binding-linux-riscv64-gnu": "0.73.0",
77
+ "@oxc-transform/binding-darwin-x64": "0.73.0",
78
+ "@oxc-transform/binding-darwin-arm64": "0.73.0",
79
+ "@oxc-transform/binding-wasm32-wasi": "0.73.0"
79
80
  },
80
81
  "scripts": {
81
82
  "build-dev": "napi build --platform",
82
83
  "build": "pnpm run build-dev --features allocator --release",
84
+ "postbuild-dev": "node patch.mjs",
83
85
  "test": "tsc && vitest run --dir ./test"
84
86
  }
85
87
  }
@@ -0,0 +1,23 @@
1
+ const fs = require('node:fs');
2
+ const childProcess = require('node:child_process');
3
+
4
+ const pkg = JSON.parse(
5
+ fs.readFileSync(require.resolve('oxc-transform/package.json'), 'utf-8'),
6
+ );
7
+ const version = pkg.version;
8
+ const baseDir = `/tmp/oxc-transform-${version}`;
9
+ const bindingEntry = `${baseDir}/node_modules/@oxc-transform/binding-wasm32-wasi/transform.wasi.cjs`;
10
+
11
+ if (!fs.existsSync(bindingEntry)) {
12
+ fs.rmSync(baseDir, { recursive: true, force: true });
13
+ fs.mkdirSync(baseDir, { recursive: true });
14
+ const bindingPkg = `@oxc-transform/binding-wasm32-wasi@${version}`;
15
+ // eslint-disable-next-line: no-console
16
+ console.log(`[oxc-transform] Downloading ${bindingPkg} on WebContainer...`);
17
+ childProcess.execFileSync('pnpm', ['i', bindingPkg], {
18
+ cwd: baseDir,
19
+ stdio: 'inherit',
20
+ });
21
+ }
22
+
23
+ module.exports = require(bindingEntry);