Skip to content

Commit 7a50ad9

Browse files
committed
docs(napi/parser, napi/transform): correct README examples (#13934)
Docs were out of date. `oxc-parser` and `oxc-transform` packages are now ESM-only, so the code examples would no longer run. Correct them.
1 parent ad14a41 commit 7a50ad9

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

napi/parser/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,15 @@ export interface EcmaScriptModule {
9393
## API
9494

9595
```javascript
96-
import oxc from 'oxc-parser';
96+
import { parseSync } from 'oxc-parser';
9797

9898
const code = 'const url: String = /* 🤨 */ import.meta.url;';
9999

100100
// File extension is used to determine which dialect to parse source as.
101101
const filename = 'test.tsx';
102102

103-
const result = oxc.parseSync(filename, code);
104-
// or `await oxc.parseAsync(filename, code)`
103+
const result = parseSync(filename, code);
104+
// or `await parseAsync(filename, code)`
105105

106106
// An array of errors, if any.
107107
console.log(result.errors);

napi/transform/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ This is alpha software and may yield incorrect results, feel free to [submit a b
66

77
```javascript
88
import assert from 'assert';
9-
import oxc from 'oxc-transform';
9+
import { transform } from 'oxc-transform';
1010

11-
const { code, declaration, errors } = oxc.transform(
11+
const { code, declaration, errors } = transform(
1212
'test.ts',
1313
'class A<T> {}',
1414
{
@@ -17,6 +17,7 @@ const { code, declaration, errors } = oxc.transform(
1717
},
1818
},
1919
);
20+
// or `await transformAsync(filename, code, options)`
2021

2122
assert.equal(code, 'class A {}\n');
2223
assert.equal(declaration, 'declare class A<T> {}\n');
@@ -31,9 +32,9 @@ Conforms to TypeScript compiler's `--isolatedDeclarations` `.d.ts` emit.
3132

3233
```javascript
3334
import assert from 'assert';
34-
import oxc from 'oxc-transform';
35+
import { isolatedDeclaration } from 'oxc-transform';
3536

36-
const { map, code, errors } = oxc.isolatedDeclaration('test.ts', 'class A {}');
37+
const { map, code, errors } = isolatedDeclaration('test.ts', 'class A {}');
3738

3839
assert.equal(code, 'declare class A {}\n');
3940
assert(errors.length == 0);

0 commit comments

Comments
 (0)