Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --code-esm support #200

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ You can pass the following [Ajv options](https://ajv.js.org/options.html):
| `--own-properties` | only validate own properties (not relevant for JSON, but can have effect for JavaScript objects) |
| Code generation |
| `--code-es5` | generate ES5 code |
| `--code-esm` | generate ESM code |
| `--code-lines` | generate multi-line code |
| `--code-optimize=` | disable optimization (`false`) or number of optimization passes (1 pass by default) |
| `--code-formats=` | code to require formats object (only needed if you generate standalone code and do not use [ajv-formats](https://github.com/ajv-validator/ajv-formats)) |
Expand Down
4 changes: 3 additions & 1 deletion src/commands/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ Ajv options (see https://github.com/epoberezkin/ajv#options):

--own-properties only validate own properties (not relevant for JSON, but can have effect for JavaScript objects)

--code-es5 generate ES5 code
--code-es5 generate ES5 code

--code-esm generate ESM code

--code-lines generate multi-line code

Expand Down
1 change: 1 addition & 0 deletions src/commands/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const ajvOptions: SchemaMap = {
multipleOfPrecision: boolOrNat,
messages: {type: "boolean"},
[`${CODE}es5`]: {type: "boolean"},
[`${CODE}esm`]: {type: "boolean"},
[`${CODE}lines`]: {type: "boolean"},
[`${CODE}optimize`]: boolOrNat,
[`${CODE}formats`]: {type: "string"},
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"allowJs": true,
"target": "ES2018",
"resolveJsonModule": true,
"esModuleInterop": false
"esModuleInterop": false,
"useUnknownInCatchVariables": false
}
}