@kubb/parser-ts 5.8.2 → 5.8.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
@@ -10,7 +10,7 @@
10
10
  [![Node][node-src]][node-href]
11
11
 
12
12
  <h4>
13
- <a href="https://kubb.dev" target="_blank">Documentation</a>
13
+ <a href="https://kubb.dev/extensions/kubb-labs/parser-ts" target="_blank">Documentation</a>
14
14
  <span> · </span>
15
15
  <a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Report Bug</a>
16
16
  <span> · </span>
package/dist/index.cjs CHANGED
@@ -10,7 +10,7 @@ var compatibility = {
10
10
  };
11
11
  //#endregion
12
12
  //#region package.json
13
- var version = "5.8.2";
13
+ var version = "5.8.3";
14
14
  //#endregion
15
15
  //#region ../../internals/utils/src/fs.ts
16
16
  /**
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ var compatibility = {
9
9
  };
10
10
  //#endregion
11
11
  //#region package.json
12
- var version = "5.8.2";
12
+ var version = "5.8.3";
13
13
  //#endregion
14
14
  //#region ../../internals/utils/src/fs.ts
15
15
  /**
@@ -0,0 +1,30 @@
1
+ # Options
2
+
3
+ `parserTs` and `parserTsx` accept the same single option, `extension`, which rewrites the import and export extensions the TypeScript parser emits.
4
+
5
+ ## Options overview
6
+
7
+ | Option | Purpose | Default |
8
+ | ------------------------- | --------------------------------------------------------------- | --------------- |
9
+ | [`extension`](#extension) | Rewrite the extensions emitted in `import`/`export` statements. | `{ '.ts': '' }` |
10
+
11
+ ## Option details
12
+
13
+ ### extension
14
+
15
+ Rewrites the extensions emitted in `import`/`export` statements. Keys are the source extension, values the output, and `''` drops it. Only the module-specifier string changes, never the on-disk filename.
16
+
17
+ Use it to emit `.js` imports from `.ts` sources for an ESM dual package, or to keep the source extension for Node16/NodeNext resolution.
18
+
19
+ The same mapping applies to runtime templates a plugin copies into the output, such as the `.kubb/` runtime files of `@kubb/plugin-fetch`. Their top-level `import` and `export … from` statements become import and export nodes, so the whole output follows one convention.
20
+
21
+ | | |
22
+ | -------- | ------------------------ |
23
+ | Type | `Record<string, string>` |
24
+ | Required | `false` |
25
+ | Default | `{ '.ts': '' }` |
26
+
27
+ ```typescript
28
+ parserTs({ extension: { '.ts': '.js' } }) // import './api.js' instead of './api'
29
+ parserTs({ extension: { '.ts': '.ts' } }) // import './api.ts' instead of './api'
30
+ ```
@@ -8,19 +8,24 @@ The package also exports `parserTsx`, which handles `.tsx` and `.jsx` files with
8
8
 
9
9
  Set `defineConfig.parsers` only to change an option. A custom `parsers` array replaces the default set, so list every parser your plugins need. Files no parser claims are written as their source text.
10
10
 
11
- ```ts
11
+ ## Options
12
+
13
+ `extension` rewrites the extension of relative imports and exports. Keys are the source extension and values the output, and `''` drops it. By default `.ts` imports have no extension. Use `{ '.ts': '.js' }` for ESM packages, or `{ '.ts': '.ts' }` for Node.js `NodeNext` resolution. Package imports stay unchanged. See [Options](https://kubb.dev/extensions/kubb-labs/parser-ts/options) for its type and default.
14
+
15
+ ## Example
16
+
17
+ Override import extensions while keeping every default parser registered.
18
+
19
+ ```typescript [kubb.config.ts]
12
20
  import { defineConfig } from 'kubb/config'
13
21
  import { parserTs, parserTsx } from '@kubb/parser-ts'
14
22
  import { parserMd } from '@kubb/parser-md'
23
+ import { pluginTs } from '@kubb/plugin-ts'
15
24
 
16
25
  export default defineConfig({
17
26
  input: './petStore.yaml',
18
27
  output: { path: './src/gen' },
19
28
  parsers: [parserTs({ extension: { '.ts': '.js' } }), parserTsx(), parserMd()],
20
- plugins: [],
29
+ plugins: [pluginTs()],
21
30
  })
22
31
  ```
23
-
24
- ## Options
25
-
26
- `extension` rewrites the extension of relative imports and exports. Keys are the source extension and values the output, and `''` drops it. By default `.ts` imports have no extension. Use `{ '.ts': '.js' }` for ESM packages, or `{ '.ts': '.ts' }` for Node.js `NodeNext` resolution. Package imports stay unchanged.
@@ -10,7 +10,8 @@
10
10
  "light": "https://kubb.dev/feature/typescript.svg"
11
11
  },
12
12
  "tags": ["typescript", "tsx", "parser", "printer", "ast"],
13
- "docs": "https://kubb.dev/parsers/parser-ts",
13
+ "docs": "https://kubb.dev/extensions/kubb-labs/parser-ts",
14
+ "maintainers": [{ "name": "Stijn Van Hulle", "github": "stijnvanhulle" }],
14
15
  "compatibility": {
15
16
  "kubb": ">=5.8.0",
16
17
  "node": ">=22"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/parser-ts",
3
- "version": "5.8.2",
3
+ "version": "5.8.3",
4
4
  "description": "TypeScript and TSX source file parser for Kubb. Converts AST nodes into formatted source strings using the TypeScript compiler API.",
5
5
  "keywords": [
6
6
  "codegen",
@@ -10,7 +10,7 @@
10
10
  "tsx",
11
11
  "typescript"
12
12
  ],
13
- "homepage": "https://kubb.dev/parsers/parser-ts",
13
+ "homepage": "https://kubb.dev/extensions/kubb-labs/parser-ts",
14
14
  "license": "MIT",
15
15
  "author": "stijnvanhulle",
16
16
  "repository": {
@@ -35,7 +35,7 @@
35
35
  "files": [
36
36
  "dist",
37
37
  "kubb-extension.json",
38
- "OVERVIEW.md",
38
+ "docs",
39
39
  "!/**/**.test.**",
40
40
  "!/**/__tests__/**",
41
41
  "!/**/__snapshots__/**"
@@ -59,7 +59,7 @@
59
59
  "registry": "https://registry.npmjs.org/"
60
60
  },
61
61
  "dependencies": {
62
- "@kubb/kit": "5.8.2",
62
+ "@kubb/kit": "5.8.3",
63
63
  "typescript": "^6.0.3"
64
64
  },
65
65
  "devDependencies": {