yuku-codegen 0.6.12 → 0.7.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 +102 -88
- package/index.d.ts +60 -46
- package/index.js +15 -11
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -14,121 +14,102 @@ npm install yuku-codegen
|
|
|
14
14
|
|
|
15
15
|
```js
|
|
16
16
|
import { parse } from "yuku-parser";
|
|
17
|
-
import {
|
|
17
|
+
import { generate } from "yuku-codegen";
|
|
18
18
|
|
|
19
19
|
const { program } = parse("const x = 1 + 2;");
|
|
20
|
-
const { code } =
|
|
20
|
+
const { code } = generate(program);
|
|
21
21
|
|
|
22
22
|
console.log(code); // "const x = 1 + 2;"
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
## API
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
| Function | Behavior |
|
|
30
|
-
| -------- | ----------------------------------------------------------------------------------------------------- |
|
|
31
|
-
| `print` | Renders verbatim, preserving TypeScript syntax. |
|
|
32
|
-
| `strip` | Drops type-only syntax and emits plain JavaScript. See [TypeScript stripping](#typescript-stripping). |
|
|
33
|
-
| `minify` | Applies size-reducing rewrites at print time. See [Minification](#minification). |
|
|
34
|
-
|
|
35
|
-
All return a `CodegenResult`:
|
|
27
|
+
`generate` takes the `Program` node off the `ParseResult` returned by [`yuku-parser`](https://www.npmjs.com/package/yuku-parser) and returns a `GenerateResult`:
|
|
36
28
|
|
|
37
29
|
```ts
|
|
38
|
-
interface
|
|
30
|
+
interface GenerateResult {
|
|
39
31
|
code: string;
|
|
40
32
|
errors: Diagnostic[];
|
|
41
33
|
map: SourceMap | null;
|
|
42
34
|
}
|
|
43
35
|
```
|
|
44
36
|
|
|
45
|
-
`errors` is empty on a clean run. `map` is non-null only when `
|
|
37
|
+
`errors` is empty on a clean run. `map` is non-null only when `sourceMap` is enabled.
|
|
46
38
|
|
|
47
39
|
## Options
|
|
48
40
|
|
|
41
|
+
Every transformation is an independent flag, so they compose freely:
|
|
42
|
+
|
|
49
43
|
```js
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
comments: "some",
|
|
55
|
-
sourceMaps: { source },
|
|
44
|
+
const { code, map } = generate(program, {
|
|
45
|
+
strip: true,
|
|
46
|
+
minify: true,
|
|
47
|
+
sourceMap: { source },
|
|
56
48
|
});
|
|
57
49
|
```
|
|
58
50
|
|
|
59
|
-
| Option
|
|
60
|
-
|
|
|
61
|
-
| `
|
|
62
|
-
| `
|
|
63
|
-
| `
|
|
64
|
-
| `
|
|
65
|
-
| `
|
|
51
|
+
| Option | Type | Default | Description |
|
|
52
|
+
| ----------- | ---------------------------------------------------------------- | ------------ | --------------------------------------------------------------------------------- |
|
|
53
|
+
| `strip` | `boolean` | `false` | Drop TypeScript-only syntax and emit plain JavaScript. See [TypeScript stripping](#typescript-stripping). |
|
|
54
|
+
| `minify` | `boolean \| MinifyOptions` | `false` | `true` for maximum minification, an object for fine-grained control. See [Minification](#minification). |
|
|
55
|
+
| `format` | `"pretty" \| "compact"` | `"pretty"` | Whitespace mode. `"compact"` emits only the separators the grammar requires. |
|
|
56
|
+
| `indent` | `number` | `2` | Spaces per indentation level. Applies in pretty mode only. |
|
|
57
|
+
| `quotes` | `"preserve" \| "double" \| "single" \| "shortest"` | `"preserve"` | Quote style for string literals. See [Quotes](#quotes). |
|
|
58
|
+
| `comments` | `boolean \| "some" \| "none" \| "line" \| "block"` | `"some"` | Comment passthrough filter. See [Comments](#comments). |
|
|
59
|
+
| `sourceMap` | `SourceMapOptions` | `undefined` | Pass an object to emit a Source Map V3. See [Source maps](#source-maps). |
|
|
66
60
|
|
|
67
|
-
##
|
|
61
|
+
## TypeScript stripping
|
|
68
62
|
|
|
69
|
-
|
|
63
|
+
`strip: true` rewrites the AST as plain JavaScript.
|
|
70
64
|
|
|
71
65
|
```js
|
|
72
66
|
import { parse } from "yuku-parser";
|
|
73
|
-
import {
|
|
74
|
-
|
|
75
|
-
const source = `const greet = (name) => "Hello, " + name;`;
|
|
76
|
-
const { program } = parse(source);
|
|
77
|
-
|
|
78
|
-
const { code, map } = print(program, {
|
|
79
|
-
sourceMaps: {
|
|
80
|
-
source,
|
|
81
|
-
file: "out.js",
|
|
82
|
-
sourceFileName: "in.js",
|
|
83
|
-
sourcesContent: source,
|
|
84
|
-
},
|
|
85
|
-
});
|
|
67
|
+
import { generate } from "yuku-codegen";
|
|
86
68
|
|
|
87
|
-
|
|
88
|
-
|
|
69
|
+
const { program } = parse(`const x: number = 1;`, { lang: "ts" });
|
|
70
|
+
console.log(generate(program, { strip: true }).code); // "const x = 1;"
|
|
89
71
|
```
|
|
90
72
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
| Field | Type | Description |
|
|
94
|
-
| ---------------- | ---------- | --------------------------------------------------------------------------------- |
|
|
95
|
-
| `source` | `string` | **Required.** The original source text, used to map positions to the source. |
|
|
96
|
-
| `file` | `string` | Output filename, embedded as the map's `file`. |
|
|
97
|
-
| `sourceFileName` | `string` | Source filename, embedded as the single entry of `sources`. |
|
|
98
|
-
| `sourceRoot` | `string` | Prefix embedded as `sourceRoot`. |
|
|
99
|
-
| `sourcesContent` | `string` | When set, embedded as the single entry of the map's `sourcesContent`. Omit to skip. |
|
|
73
|
+
Type annotations, type aliases, interfaces, and other type-only constructs are dropped. Constructs that have no clean JavaScript equivalent (`enum`, `namespace`, `import = require()`, `export =`) are reported in `errors` and elided. The output is always syntactically valid JavaScript.
|
|
100
74
|
|
|
101
|
-
|
|
75
|
+
## Minification
|
|
102
76
|
|
|
103
|
-
`
|
|
77
|
+
`minify: true` enables every switch for maximum minification:
|
|
104
78
|
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
version: 3;
|
|
108
|
-
file: string | null;
|
|
109
|
-
sourceRoot: string | null;
|
|
110
|
-
sources: string[];
|
|
111
|
-
sourcesContent: (string | null)[] | null;
|
|
112
|
-
names: string[];
|
|
113
|
-
mappings: string;
|
|
114
|
-
}
|
|
79
|
+
```js
|
|
80
|
+
const { code } = generate(program, { minify: true });
|
|
115
81
|
```
|
|
116
82
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
## TypeScript stripping
|
|
83
|
+
For fine-grained control, pass an object. Enabled switches override `format` and `quotes`.
|
|
120
84
|
|
|
121
|
-
|
|
85
|
+
| Switch | Behavior |
|
|
86
|
+
| ------------ | ---------------------------------------------------------------------------- |
|
|
87
|
+
| `whitespace` | Emit compact whitespace. |
|
|
88
|
+
| `syntax` | Apply size-reducing syntax rewrites (see below). |
|
|
89
|
+
| `quotes` | Use whichever quote needs fewer escapes per literal. |
|
|
122
90
|
|
|
123
91
|
```js
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const { program } = parse(`const x: number = 1;`, { lang: "ts" });
|
|
128
|
-
console.log(strip(program).code); // "const x = 1;"
|
|
92
|
+
// rewrites only, keeping readable output
|
|
93
|
+
const { code } = generate(program, { minify: { syntax: true } });
|
|
129
94
|
```
|
|
130
95
|
|
|
131
|
-
|
|
96
|
+
The `syntax` rewrites:
|
|
97
|
+
|
|
98
|
+
- `true` and `false` rewrite to `!0` and `!1`.
|
|
99
|
+
- `undefined` rewrites to `void 0` (in expression position).
|
|
100
|
+
- `Infinity` rewrites to `1/0`.
|
|
101
|
+
- Numeric literals shorten to their shortest form (`1000000` becomes `1e6`, `0.5` becomes `.5`).
|
|
102
|
+
- `obj["foo"]` rewrites to `obj.foo` when the key is a valid identifier.
|
|
103
|
+
- `{ "foo": x }` rewrites to `{ foo: x }` when safe.
|
|
104
|
+
|
|
105
|
+
## Quotes
|
|
106
|
+
|
|
107
|
+
| Value | Behavior |
|
|
108
|
+
| ------------ | -------------------------------------------------------------------------------------------- |
|
|
109
|
+
| `"preserve"` | Keep each literal's source quote style, re-escaping the content. _(default)_ |
|
|
110
|
+
| `"double"` | Force double quotes. |
|
|
111
|
+
| `"single"` | Force single quotes. |
|
|
112
|
+
| `"shortest"` | Pick whichever quote needs fewer escapes per literal; double on a tie. |
|
|
132
113
|
|
|
133
114
|
## Comments
|
|
134
115
|
|
|
@@ -136,7 +117,7 @@ Comments live on the AST nodes they were attached to during parsing. To preserve
|
|
|
136
117
|
|
|
137
118
|
```js
|
|
138
119
|
const { program } = parse(source, { attachComments: true });
|
|
139
|
-
|
|
120
|
+
generate(program).code;
|
|
140
121
|
```
|
|
141
122
|
|
|
142
123
|
The `comments` option then selects which attached comments are emitted. The default is `"some"`, which matches the bundler convention of keeping legal banners, JSDoc, and tree-shaking annotations while dropping plain noise.
|
|
@@ -151,31 +132,64 @@ The `comments` option then selects which attached comments are emitted. The defa
|
|
|
151
132
|
|
|
152
133
|
```js
|
|
153
134
|
const { program } = parse(`// hello\nconst x = 1;`, { attachComments: true });
|
|
154
|
-
|
|
135
|
+
generate(program, { comments: true }).code;
|
|
155
136
|
// "// hello\nconst x = 1;"
|
|
156
137
|
```
|
|
157
138
|
|
|
158
139
|
Because comments are attached to nodes, they survive AST transforms: move or replace a node and its comments come with it. See the [yuku-parser comments docs](https://www.npmjs.com/package/yuku-parser#comments) for the comment options.
|
|
159
140
|
|
|
160
|
-
##
|
|
141
|
+
## Source maps
|
|
161
142
|
|
|
162
|
-
`
|
|
143
|
+
Pass a `SourceMapOptions` object to emit a Source Map V3. Its `source` field is required: feed it the original source text (this is what maps generated positions back to the source). Without it, no map is produced and `map` is `null`. The remaining fields (`file`, `sources`, `sourcesContent`, `sourceRoot`) are optional metadata.
|
|
163
144
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
- Numeric literals shorten to their shortest form (`1000000` becomes `1e6`, `0.5` becomes `.5`).
|
|
168
|
-
- `obj["foo"]` rewrites to `obj.foo` when the key is a valid identifier.
|
|
169
|
-
- `{ "foo": x }` rewrites to `{ foo: x }` when safe.
|
|
145
|
+
```js
|
|
146
|
+
import { parse } from "yuku-parser";
|
|
147
|
+
import { generate } from "yuku-codegen";
|
|
170
148
|
|
|
171
|
-
|
|
149
|
+
const source = `const greet = (name) => "Hello, " + name;`;
|
|
150
|
+
const { program } = parse(source);
|
|
172
151
|
|
|
173
|
-
|
|
174
|
-
|
|
152
|
+
const { code, map } = generate(program, {
|
|
153
|
+
sourceMap: {
|
|
154
|
+
source,
|
|
155
|
+
file: "out.js",
|
|
156
|
+
sourceFileName: "in.js",
|
|
157
|
+
sourcesContent: source,
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
await Bun.write("out.js", `${code}\n//# sourceMappingURL=out.js.map`);
|
|
162
|
+
await Bun.write("out.js.map", JSON.stringify(map));
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### `SourceMapOptions`
|
|
166
|
+
|
|
167
|
+
| Field | Type | Description |
|
|
168
|
+
| ---------------- | ---------- | --------------------------------------------------------------------------------- |
|
|
169
|
+
| `source` | `string` | **Required.** The original source text, used to map positions to the source. |
|
|
170
|
+
| `file` | `string` | Output filename, embedded as the map's `file`. |
|
|
171
|
+
| `sourceFileName` | `string` | Source filename, embedded as the single entry of `sources`. |
|
|
172
|
+
| `sourceRoot` | `string` | Prefix embedded as `sourceRoot`. |
|
|
173
|
+
| `sourcesContent` | `string` | When set, embedded as the single entry of the map's `sourcesContent`. Omit to skip. |
|
|
175
174
|
|
|
176
|
-
|
|
175
|
+
### Output shape
|
|
176
|
+
|
|
177
|
+
`map` is a Source Map V3 object, ready to serialize with `JSON.stringify`:
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
interface SourceMap {
|
|
181
|
+
version: 3;
|
|
182
|
+
file: string | null;
|
|
183
|
+
sourceRoot: string | null;
|
|
184
|
+
sources: string[];
|
|
185
|
+
sourcesContent: (string | null)[] | null;
|
|
186
|
+
names: string[];
|
|
187
|
+
mappings: string;
|
|
188
|
+
}
|
|
177
189
|
```
|
|
178
190
|
|
|
191
|
+
Columns are 0-indexed UTF-16 code units, matching Chrome DevTools and consumer-side libraries like `@jridgewell/trace-mapping` and `source-map`.
|
|
192
|
+
|
|
179
193
|
## License
|
|
180
194
|
|
|
181
195
|
MIT
|
package/index.d.ts
CHANGED
|
@@ -4,33 +4,22 @@ import type { Comment, Program } from "@yuku-toolchain/types";
|
|
|
4
4
|
export type Format = "pretty" | "compact";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Quote style for
|
|
8
|
-
*
|
|
9
|
-
* - `"preserve"`: keep each literal's original quote style (single vs double);
|
|
10
|
-
* synthetic nodes default to double.
|
|
11
|
-
* - `"double"` / `"single"`: force that quote.
|
|
7
|
+
* Quote style for string literals. `"preserve"` keeps each literal's source
|
|
8
|
+
* quote; `"shortest"` picks the quote with fewer escapes, double on a tie.
|
|
12
9
|
*/
|
|
13
|
-
export type Quotes = "preserve" | "double" | "single";
|
|
10
|
+
export type Quotes = "preserve" | "double" | "single" | "shortest";
|
|
14
11
|
|
|
15
12
|
/**
|
|
16
|
-
* Comment passthrough filter.
|
|
17
|
-
*
|
|
18
|
-
* - `false`: drop all comments.
|
|
19
|
-
* - `true` or `"all"`: emit every comment.
|
|
20
|
-
* - `"some"`: emit legal headers, JSDoc, and `@__*__` annotations.
|
|
21
|
-
* - `"line"`: emit `// ...` only.
|
|
22
|
-
* - `"block"`: emit block comments only.
|
|
13
|
+
* Comment passthrough filter. `"some"` emits legal headers, JSDoc, and
|
|
14
|
+
* `@__*__` annotations; `true`/`false` are sugar for `"all"`/`"none"`.
|
|
23
15
|
*/
|
|
24
|
-
export type Comments = boolean | "all" | "some" | "line" | "block";
|
|
16
|
+
export type Comments = boolean | "all" | "some" | "none" | "line" | "block";
|
|
25
17
|
|
|
26
18
|
export type { Comment };
|
|
27
19
|
|
|
28
|
-
/** Source-map configuration. Pass to `
|
|
20
|
+
/** Source-map configuration. Pass to `GenerateOptions.sourceMap` to enable. */
|
|
29
21
|
export interface SourceMapOptions {
|
|
30
|
-
/**
|
|
31
|
-
* The original source text. Required to emit a map; without it, `map` is
|
|
32
|
-
* `null`.
|
|
33
|
-
*/
|
|
22
|
+
/** The original source text. Required to emit a map. */
|
|
34
23
|
source: string;
|
|
35
24
|
/** Output filename, embedded as the map's `file`. */
|
|
36
25
|
file?: string;
|
|
@@ -42,31 +31,47 @@ export interface SourceMapOptions {
|
|
|
42
31
|
sourcesContent?: string;
|
|
43
32
|
}
|
|
44
33
|
|
|
45
|
-
/**
|
|
46
|
-
export interface
|
|
34
|
+
/** Minification switches. Enabled switches override `format` and `quotes`. */
|
|
35
|
+
export interface MinifyOptions {
|
|
36
|
+
/** Emit compact whitespace. @default false */
|
|
37
|
+
whitespace?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Apply size-reducing syntax rewrites (`!0`, `void 0`, `1e6`, `obj.foo`, ...).
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
syntax?: boolean;
|
|
43
|
+
/** Use shortest quotes. @default false */
|
|
44
|
+
quotes?: boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Options for `generate`. Transformations are independent flags and compose freely. */
|
|
48
|
+
export interface GenerateOptions {
|
|
49
|
+
/**
|
|
50
|
+
* Drop TypeScript-only syntax and emit plain JavaScript. Constructs with no
|
|
51
|
+
* JavaScript equivalent (`enum`, `namespace`, ...) are reported in `errors`
|
|
52
|
+
* and elided.
|
|
53
|
+
* @default false
|
|
54
|
+
*/
|
|
55
|
+
strip?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* `true` enables every {@link MinifyOptions} switch for maximum
|
|
58
|
+
* minification; pass an object for fine-grained control.
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
61
|
+
minify?: boolean | MinifyOptions;
|
|
47
62
|
/** @default "pretty" */
|
|
48
63
|
format?: Format;
|
|
49
64
|
/**
|
|
50
|
-
* Spaces per indentation level
|
|
65
|
+
* Spaces per indentation level in pretty format.
|
|
51
66
|
* @default 2
|
|
52
67
|
*/
|
|
53
68
|
indent?: number;
|
|
54
69
|
/** @default "preserve" */
|
|
55
70
|
quotes?: Quotes;
|
|
56
|
-
/**
|
|
57
|
-
* Enable Source Map V3 output. Pass a {@link SourceMapOptions} object. Its
|
|
58
|
-
* `source` (the original source text) is required. The rest of the metadata
|
|
59
|
-
* (`file`, `sources`, `sourcesContent`, `sourceRoot`) is optional. Omit to
|
|
60
|
-
* disable.
|
|
61
|
-
* @default undefined
|
|
62
|
-
*/
|
|
63
|
-
sourceMaps?: SourceMapOptions;
|
|
64
|
-
/**
|
|
65
|
-
* Comment passthrough filter. Defaults to `"some"`, which preserves
|
|
66
|
-
* legal headers, JSDoc, and tree-shaking annotations.
|
|
67
|
-
* @default "some"
|
|
68
|
-
*/
|
|
71
|
+
/** @default "some" */
|
|
69
72
|
comments?: Comments;
|
|
73
|
+
/** Pass to emit a Source Map V3. Omit to disable. */
|
|
74
|
+
sourceMap?: SourceMapOptions;
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
/** A codegen-detected problem in the input AST. */
|
|
@@ -90,22 +95,31 @@ export interface SourceMap {
|
|
|
90
95
|
}
|
|
91
96
|
|
|
92
97
|
/** Result of a codegen run. */
|
|
93
|
-
export interface
|
|
98
|
+
export interface GenerateResult {
|
|
94
99
|
code: string;
|
|
95
100
|
/** Empty when codegen succeeded cleanly. */
|
|
96
101
|
errors: Diagnostic[];
|
|
97
|
-
/** `null` unless `
|
|
102
|
+
/** `null` unless `sourceMap` was enabled. */
|
|
98
103
|
map: SourceMap | null;
|
|
99
104
|
}
|
|
100
105
|
|
|
101
|
-
/** Renders the AST
|
|
102
|
-
export function
|
|
106
|
+
/** Renders the AST back to source code. */
|
|
107
|
+
export function generate(program: Program, options?: GenerateOptions): GenerateResult;
|
|
108
|
+
|
|
109
|
+
/** @deprecated Options type of the deprecated entry points. */
|
|
110
|
+
export type CodegenOptions = GenerateOptions & {
|
|
111
|
+
/** @deprecated Use `sourceMap`. */
|
|
112
|
+
sourceMaps?: SourceMapOptions;
|
|
113
|
+
};
|
|
103
114
|
|
|
104
|
-
/**
|
|
105
|
-
export
|
|
115
|
+
/** @deprecated Use {@link GenerateResult}. */
|
|
116
|
+
export type CodegenResult = GenerateResult;
|
|
106
117
|
|
|
107
|
-
/**
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
*/
|
|
111
|
-
export function
|
|
118
|
+
/** @deprecated Use {@link generate}. */
|
|
119
|
+
export function print(program: Program, options?: CodegenOptions): GenerateResult;
|
|
120
|
+
|
|
121
|
+
/** @deprecated Use `generate(program, { strip: true, ... })`. */
|
|
122
|
+
export function strip(program: Program, options?: CodegenOptions): GenerateResult;
|
|
123
|
+
|
|
124
|
+
/** @deprecated Use `generate(program, { minify: true, ... })`. */
|
|
125
|
+
export function minify(program: Program, options?: CodegenOptions): GenerateResult;
|
package/index.js
CHANGED
|
@@ -2,33 +2,37 @@ import binding from "./binding.js";
|
|
|
2
2
|
import { encode } from "./encode.js";
|
|
3
3
|
|
|
4
4
|
function normalizeOptions(options) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (
|
|
5
|
+
const { minify, sourceMaps, ...next } = options ?? {};
|
|
6
|
+
if (typeof next.comments === "boolean") next.comments = next.comments ? "all" : "none";
|
|
7
|
+
const m = minify === true ? { whitespace: true, syntax: true, quotes: true } : minify || {};
|
|
8
|
+
next.minify = !!m.syntax;
|
|
9
|
+
if (m.whitespace) next.format = "compact";
|
|
10
|
+
if (m.quotes) next.quotes = "shortest";
|
|
11
|
+
next.sourceMap ??= sourceMaps;
|
|
11
12
|
return next;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
function
|
|
15
|
+
export function generate(program, options) {
|
|
15
16
|
if (!program || !program.type) {
|
|
16
17
|
throw new TypeError(
|
|
17
18
|
"Expected a `Program` node from yuku-parser, got " +
|
|
18
19
|
(program === null ? "null" : typeof program),
|
|
19
20
|
);
|
|
20
21
|
}
|
|
21
|
-
return binding
|
|
22
|
+
return binding.generate(encode(program), normalizeOptions(options));
|
|
22
23
|
}
|
|
23
24
|
|
|
25
|
+
/** @deprecated Use `generate(program, options)`. */
|
|
24
26
|
export function print(program, options) {
|
|
25
|
-
return
|
|
27
|
+
return generate(program, options);
|
|
26
28
|
}
|
|
27
29
|
|
|
30
|
+
/** @deprecated Use `generate(program, { strip: true })`. */
|
|
28
31
|
export function strip(program, options) {
|
|
29
|
-
return
|
|
32
|
+
return generate(program, { ...options, strip: true });
|
|
30
33
|
}
|
|
31
34
|
|
|
35
|
+
/** @deprecated Use `generate(program, { minify: true })`. */
|
|
32
36
|
export function minify(program, options) {
|
|
33
|
-
return
|
|
37
|
+
return generate(program, { ...options, minify: { syntax: true, quotes: true } });
|
|
34
38
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yuku-codegen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "High-performance JavaScript/TypeScript code generator written in Zig",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -17,17 +17,17 @@
|
|
|
17
17
|
"encode.js"
|
|
18
18
|
],
|
|
19
19
|
"optionalDependencies": {
|
|
20
|
-
"@yuku-codegen/binding-linux-x64-gnu": "0.
|
|
21
|
-
"@yuku-codegen/binding-linux-arm64-gnu": "0.
|
|
22
|
-
"@yuku-codegen/binding-linux-arm-gnu": "0.
|
|
23
|
-
"@yuku-codegen/binding-linux-x64-musl": "0.
|
|
24
|
-
"@yuku-codegen/binding-linux-arm64-musl": "0.
|
|
25
|
-
"@yuku-codegen/binding-linux-arm-musl": "0.
|
|
26
|
-
"@yuku-codegen/binding-darwin-x64": "0.
|
|
27
|
-
"@yuku-codegen/binding-darwin-arm64": "0.
|
|
28
|
-
"@yuku-codegen/binding-win32-x64": "0.
|
|
29
|
-
"@yuku-codegen/binding-win32-arm64": "0.
|
|
30
|
-
"@yuku-codegen/binding-freebsd-x64": "0.
|
|
20
|
+
"@yuku-codegen/binding-linux-x64-gnu": "0.7.0",
|
|
21
|
+
"@yuku-codegen/binding-linux-arm64-gnu": "0.7.0",
|
|
22
|
+
"@yuku-codegen/binding-linux-arm-gnu": "0.7.0",
|
|
23
|
+
"@yuku-codegen/binding-linux-x64-musl": "0.7.0",
|
|
24
|
+
"@yuku-codegen/binding-linux-arm64-musl": "0.7.0",
|
|
25
|
+
"@yuku-codegen/binding-linux-arm-musl": "0.7.0",
|
|
26
|
+
"@yuku-codegen/binding-darwin-x64": "0.7.0",
|
|
27
|
+
"@yuku-codegen/binding-darwin-arm64": "0.7.0",
|
|
28
|
+
"@yuku-codegen/binding-win32-x64": "0.7.0",
|
|
29
|
+
"@yuku-codegen/binding-win32-arm64": "0.7.0",
|
|
30
|
+
"@yuku-codegen/binding-freebsd-x64": "0.7.0"
|
|
31
31
|
},
|
|
32
32
|
"keywords": [
|
|
33
33
|
"ast",
|
|
@@ -40,6 +40,6 @@
|
|
|
40
40
|
"typescript"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@yuku-toolchain/types": "0.
|
|
43
|
+
"@yuku-toolchain/types": "0.7.0"
|
|
44
44
|
}
|
|
45
45
|
}
|