@soda-gql/tsc-transformer 0.1.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 +68 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# @soda-gql/tsc-transformer
|
|
2
|
+
|
|
3
|
+
Core TypeScript transformation logic for soda-gql. This package extracts the AST transformation functionality used by `@soda-gql/tsc-plugin` and provides conformance tests for other plugin implementations.
|
|
4
|
+
|
|
5
|
+
## Status
|
|
6
|
+
|
|
7
|
+
**Internal package** - This package is used internally by soda-gql plugins and is not intended for direct use by end users.
|
|
8
|
+
|
|
9
|
+
## Purpose
|
|
10
|
+
|
|
11
|
+
This package provides:
|
|
12
|
+
|
|
13
|
+
1. **Shared transformation logic** - The core AST transformation that converts `gql.default()` calls to runtime registrations
|
|
14
|
+
2. **Conformance test cases** - Test fixtures and utilities for verifying plugin implementations match expected behavior
|
|
15
|
+
3. **TypeScript AST utilities** - Helpers for import management and code generation
|
|
16
|
+
|
|
17
|
+
## Used By
|
|
18
|
+
|
|
19
|
+
- `@soda-gql/tsc-plugin` - TypeScript compiler plugin
|
|
20
|
+
- `@soda-gql/babel-plugin` - Babel transformation plugin (for test conformance)
|
|
21
|
+
|
|
22
|
+
## API
|
|
23
|
+
|
|
24
|
+
### createTransformer
|
|
25
|
+
|
|
26
|
+
Creates a TypeScript transformer that processes soda-gql files.
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { createTransformer } from "@soda-gql/tsc-transformer";
|
|
30
|
+
import type { BuilderArtifact } from "@soda-gql/builder";
|
|
31
|
+
import type { ResolvedSodaGqlConfig } from "@soda-gql/config";
|
|
32
|
+
import * as ts from "typescript";
|
|
33
|
+
|
|
34
|
+
const transformer = createTransformer({
|
|
35
|
+
compilerOptions: ts.getDefaultCompilerOptions(),
|
|
36
|
+
config: resolvedConfig,
|
|
37
|
+
artifact: builderArtifact,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Use in a TypeScript transformer factory
|
|
41
|
+
const result = transformer.transform({
|
|
42
|
+
sourceFile,
|
|
43
|
+
context: transformationContext,
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### createAfterStubTransformer
|
|
48
|
+
|
|
49
|
+
Creates a post-transformation step that cleans up stub imports.
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { createAfterStubTransformer } from "@soda-gql/tsc-transformer";
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### TypeScriptEnv
|
|
56
|
+
|
|
57
|
+
Type definition for the TypeScript-specific environment.
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
type TypeScriptEnv = {
|
|
61
|
+
readonly sourceFile: ts.SourceFile;
|
|
62
|
+
readonly context: ts.TransformationContext;
|
|
63
|
+
};
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@soda-gql/tsc-transformer",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"private": false,
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "Shota Hatada",
|
|
12
|
+
"email": "shota.hatada@whatasoda.me",
|
|
13
|
+
"url": "https://github.com/whatasoda"
|
|
14
|
+
},
|
|
15
|
+
"main": "./dist/index.mjs",
|
|
16
|
+
"module": "./dist/index.mjs",
|
|
17
|
+
"types": "./dist/index.d.mts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"@soda-gql": "./src/index.ts",
|
|
21
|
+
"types": "./dist/index.d.mts",
|
|
22
|
+
"import": "./dist/index.mjs",
|
|
23
|
+
"require": "./dist/index.cjs",
|
|
24
|
+
"default": "./dist/index.mjs"
|
|
25
|
+
},
|
|
26
|
+
"./test": {
|
|
27
|
+
"@soda-gql": "./test/export.ts"
|
|
28
|
+
},
|
|
29
|
+
"./package.json": "./package.json"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@soda-gql/builder": "0.1.0",
|
|
33
|
+
"@soda-gql/common": "0.1.0",
|
|
34
|
+
"@soda-gql/config": "0.1.0",
|
|
35
|
+
"@soda-gql/core": "0.1.0",
|
|
36
|
+
"@soda-gql/plugin-common": "0.1.0",
|
|
37
|
+
"neverthrow": "^8.1.1"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@soda-gql/codegen": "0.1.0",
|
|
41
|
+
"prettier": "^3.4.2"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"typescript": "5.*"
|
|
45
|
+
}
|
|
46
|
+
}
|