oxc-transform 0.25.0 → 0.26.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.
Files changed (3) hide show
  1. package/README.md +12 -2
  2. package/index.d.ts +20 -4
  3. package/package.json +9 -9
package/README.md CHANGED
@@ -12,16 +12,26 @@ This is still in alpha and may yield incorrect results, feel free to [submit a b
12
12
  import assert from 'assert';
13
13
  import oxc from 'oxc-transform';
14
14
 
15
- const { sourceText, errors } = oxc.isolatedDeclaration("test.ts", "class A {}");
15
+ const { sourceMap, sourceText, errors } = oxc.isolatedDeclaration("test.ts", "class A {}", { sourcemap: true });
16
16
 
17
17
  assert.equal(sourceText, "declare class A {}\n");
18
+ assert.deepEqual(ret.sourceMap, {
19
+ mappings: "AAAA,cAAM,EAAE,CAAE",
20
+ names: [],
21
+ sources: ["test.ts"],
22
+ sourcesContent: ["class A {}"],
23
+ });
18
24
  assert(errors.length == 0);
19
25
  ```
20
26
 
21
27
  ### API
22
28
 
23
29
  ```typescript
24
- export function isolatedDeclaration(filename: string, sourceText: string): IsolatedDeclarationsResult
30
+ export function isolatedDeclaration(filename: string, sourceText: string, options: IsolatedDeclarationsOptions): IsolatedDeclarationsResult
31
+
32
+ export interface IsolatedDeclarationsOptions {
33
+ sourcemap: boolean
34
+ }
25
35
 
26
36
  export interface IsolatedDeclarationsResult {
27
37
  sourceText: string
package/index.d.ts CHANGED
@@ -18,10 +18,15 @@ export interface Es2015BindingOptions {
18
18
  }
19
19
 
20
20
  /** TypeScript Isolated Declarations for Standalone DTS Emit */
21
- export declare function isolatedDeclaration(filename: string, sourceText: string): IsolatedDeclarationsResult
21
+ export declare function isolatedDeclaration(filename: string, sourceText: string, options: IsolatedDeclarationsOptions): IsolatedDeclarationsResult
22
+
23
+ export interface IsolatedDeclarationsOptions {
24
+ sourcemap: boolean
25
+ }
22
26
 
23
27
  export interface IsolatedDeclarationsResult {
24
- sourceText: string
28
+ code: string
29
+ map?: SourceMap
25
30
  errors: Array<string>
26
31
  }
27
32
 
@@ -175,13 +180,13 @@ export interface TransformResult {
175
180
  *
176
181
  * If parsing failed, this will be an empty string.
177
182
  */
178
- sourceText: string
183
+ code: string
179
184
  /**
180
185
  * The source map for the transformed code.
181
186
  *
182
187
  * This will be set if {@link TransformOptions#sourcemap} is `true`.
183
188
  */
184
- sourceMap?: SourceMap
189
+ map?: SourceMap
185
190
  /**
186
191
  * The `.d.ts` declaration file for the transformed code. Declarations are
187
192
  * only generated if `declaration` is set to `true` and a TypeScript file
@@ -225,5 +230,16 @@ export interface TypeScriptBindingOptions {
225
230
  * @default false
226
231
  */
227
232
  declaration?: boolean
233
+ /**
234
+ * Rewrite or remove TypeScript import/export declaration extensions.
235
+ *
236
+ * - When set to `rewrite`, it will change `.ts`, `.mts`, `.cts` extensions to `.js`, `.mjs`, `.cjs` respectively.
237
+ * - When set to `remove`, it will remove `.ts`/`.mts`/`.cts`/`.tsx` extension entirely.
238
+ * - When set to `true`, it's equivalent to `rewrite`.
239
+ * - When set to `false` or omitted, no changes will be made to the extensions.
240
+ *
241
+ * @default false
242
+ */
243
+ rewriteImportExtensions?: 'rewrite' | 'remove' | boolean
228
244
  }
229
245
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oxc-transform",
3
- "version": "0.25.0",
3
+ "version": "0.26.0",
4
4
  "description": "Oxc transform Node API",
5
5
  "keywords": [
6
6
  "transform"
@@ -23,13 +23,13 @@
23
23
  "index.js"
24
24
  ],
25
25
  "optionalDependencies": {
26
- "@oxc-transform/binding-win32-x64-msvc": "0.25.0",
27
- "@oxc-transform/binding-win32-arm64-msvc": "0.25.0",
28
- "@oxc-transform/binding-linux-x64-gnu": "0.25.0",
29
- "@oxc-transform/binding-linux-arm64-gnu": "0.25.0",
30
- "@oxc-transform/binding-linux-x64-musl": "0.25.0",
31
- "@oxc-transform/binding-linux-arm64-musl": "0.25.0",
32
- "@oxc-transform/binding-darwin-x64": "0.25.0",
33
- "@oxc-transform/binding-darwin-arm64": "0.25.0"
26
+ "@oxc-transform/binding-win32-x64-msvc": "0.26.0",
27
+ "@oxc-transform/binding-win32-arm64-msvc": "0.26.0",
28
+ "@oxc-transform/binding-linux-x64-gnu": "0.26.0",
29
+ "@oxc-transform/binding-linux-arm64-gnu": "0.26.0",
30
+ "@oxc-transform/binding-linux-x64-musl": "0.26.0",
31
+ "@oxc-transform/binding-linux-arm64-musl": "0.26.0",
32
+ "@oxc-transform/binding-darwin-x64": "0.26.0",
33
+ "@oxc-transform/binding-darwin-arm64": "0.26.0"
34
34
  }
35
35
  }