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

feat: user-provided TypeScript config #931

Merged
merged 2 commits into from May 14, 2024

Conversation

mrgrain
Copy link
Contributor

@mrgrain mrgrain commented May 2, 2024

This PR introduces support for user-provided TypeScript configs through new options to the CLI, the programmatic API and the jsii config section in package.json respectively:

CLI package.json Programmatic API Description
-c, --tsconfig jsii.tsconfig typeScriptConfig Use this typescript configuration file to compile the jsii project.
--validate-tsconfig jsii.validateTsconfig validateTypeScriptConfig Validate the provided typescript configuration file against a set of rules.

The following validation rule sets are available:

Rule set Description
strict Validates the provided config against a strict rule set designed for maximum backwards-compatibility.
generated Enforces a config as created by --generate-tsconfig. Use this to stay compatible with the generated config, but have full ownership over the file.
minimal Only enforce options that are known to be incompatible with jsii. This rule set is likely to be incomplete and new rules will be added without notice as incompatibilities emerge.
off 🧪 Disables all config validation, including options that are known to be incompatible with jsii. Intended for experimentation only. Use at your own risk.

Resolves aws/jsii#2071


Refactors

Mostly changed the compiler by moving some code around or into new locations to be reused. Specifically the generated config was created in multiple places without re-use. With this PR, loading or building the tsconfig now happens once in the constructor and this config is used through out.

Testing strategy

Compiler changes are covered by existing test cases.
Added property-based tests for the new config validator.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mrgrain mrgrain force-pushed the mrgrain/custom-tsconfig branch 2 times, most recently from d9ff279 to 21c115f Compare May 2, 2024 09:22
src/compiler.ts Outdated Show resolved Hide resolved
@mrgrain mrgrain changed the title feat: BYO config feat: bring-your-own TypeScript config May 7, 2024
@mrgrain mrgrain force-pushed the mrgrain/custom-tsconfig branch 4 times, most recently from a8eabc3 to 38b6016 Compare May 13, 2024 09:57
@mrgrain mrgrain changed the title feat: bring-your-own TypeScript config feat: user provided TypeScript config May 13, 2024
@mrgrain mrgrain changed the title feat: user provided TypeScript config feat: user-provided TypeScript config May 13, 2024
@mrgrain mrgrain force-pushed the mrgrain/custom-tsconfig branch 4 times, most recently from 78f1672 to 502f639 Compare May 13, 2024 16:53
src/tsconfig/rulesets/minimal.ts Outdated Show resolved Hide resolved
src/tsconfig/validator.ts Outdated Show resolved Hide resolved
src/tsconfig/validator.ts Show resolved Hide resolved
src/tsconfig/validator.ts Outdated Show resolved Hide resolved
src/tsconfig/validator.ts Outdated Show resolved Hide resolved
src/tsconfig/rulesets/generated.ts Outdated Show resolved Hide resolved
src/tsconfig/rulesets/strict.ts Outdated Show resolved Hide resolved
@mrgrain mrgrain marked this pull request as ready for review May 14, 2024 11:24
@aws-cdk-automation aws-cdk-automation added this pull request to the merge queue May 14, 2024
Merged via the queue into main with commit 14a51b9 May 14, 2024
73 checks passed
@aws-cdk-automation aws-cdk-automation deleted the mrgrain/custom-tsconfig branch May 14, 2024 11:45
aws-cdk-automation pushed a commit that referenced this pull request May 16, 2024
This PR introduces support for user-provided TypeScript configs through
new options to the CLI, the programmatic API and the `jsii` config
section in `package.json` respectively:

| CLI | package.json | Programmatic API | Description |
|-----|--------------|-------------------|-------------|
| `-c`, `--tsconfig` | `jsii.tsconfig` | `typeScriptConfig` | Use this
typescript configuration file to compile the jsii project. |
| `--validate-tsconfig` | `jsii.validateTsConfig` |
`validateTypeScriptConfig` | Validate the provided typescript
configuration file against a set of rules.|

The following validation rule sets are available:

| Rule set | Description |
|---------|-------------|
| **strict** ⭐ | Validates the provided config against a strict rule set
designed for maximum backwards-compatibility. |
| **generated** | Enforces a config as created by `--generate-tsconfig`.
Use this to stay compatible with the generated config, but have full
ownership over the file. |
| **minimal** | Only enforce options that are known to be incompatible
with jsii. This rule set is likely to be incomplete and new rules will
be added without notice as incompatibilities emerge. |
| **off** 🧪 | Disables all config validation, including options that are
known to be incompatible with jsii. Intended for experimentation only.
Use at your own risk. |

Resolves aws/jsii#2071

---

## Refactors

Mostly changed the compiler by moving some code around or into new
locations to be reused. Specifically the generated config was created in
multiple places without re-use. With this PR, loading or building the
tsconfig now happens once in the constructor and this config is used
through out.

## Testing strategy

Compiler changes are covered by existing test cases.
Added property-based tests for the new config validator.

---

By submitting this pull request, I confirm that my contribution is made
under the terms of the [Apache 2.0 license].

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0

(cherry picked from commit 14a51b9)
aws-cdk-automation pushed a commit that referenced this pull request May 16, 2024
This PR introduces support for user-provided TypeScript configs through
new options to the CLI, the programmatic API and the `jsii` config
section in `package.json` respectively:

| CLI | package.json | Programmatic API | Description |
|-----|--------------|-------------------|-------------|
| `-c`, `--tsconfig` | `jsii.tsconfig` | `typeScriptConfig` | Use this
typescript configuration file to compile the jsii project. |
| `--validate-tsconfig` | `jsii.validateTsConfig` |
`validateTypeScriptConfig` | Validate the provided typescript
configuration file against a set of rules.|

The following validation rule sets are available:

| Rule set | Description |
|---------|-------------|
| **strict** ⭐ | Validates the provided config against a strict rule set
designed for maximum backwards-compatibility. |
| **generated** | Enforces a config as created by `--generate-tsconfig`.
Use this to stay compatible with the generated config, but have full
ownership over the file. |
| **minimal** | Only enforce options that are known to be incompatible
with jsii. This rule set is likely to be incomplete and new rules will
be added without notice as incompatibilities emerge. |
| **off** 🧪 | Disables all config validation, including options that are
known to be incompatible with jsii. Intended for experimentation only.
Use at your own risk. |

Resolves aws/jsii#2071

---

## Refactors

Mostly changed the compiler by moving some code around or into new
locations to be reused. Specifically the generated config was created in
multiple places without re-use. With this PR, loading or building the
tsconfig now happens once in the constructor and this config is used
through out.

## Testing strategy

Compiler changes are covered by existing test cases.
Added property-based tests for the new config validator.

---

By submitting this pull request, I confirm that my contribution is made
under the terms of the [Apache 2.0 license].

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0

(cherry picked from commit 14a51b9)
@aws-cdk-automation
Copy link
Collaborator

💔 Some backports could not be created

Status Branch Result
maintenance/v5.2 An unhandled error occurred. Please see the logs for details
maintenance/v5.3

Manual backport

To create the backport manually run:

backport --pr 931

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

aws-cdk-automation pushed a commit that referenced this pull request May 16, 2024
This PR introduces support for user-provided TypeScript configs through
new options to the CLI, the programmatic API and the `jsii` config
section in `package.json` respectively:

| CLI | package.json | Programmatic API | Description |
|-----|--------------|-------------------|-------------|
| `-c`, `--tsconfig` | `jsii.tsconfig` | `typeScriptConfig` | Use this
typescript configuration file to compile the jsii project. |
| `--validate-tsconfig` | `jsii.validateTsConfig` |
`validateTypeScriptConfig` | Validate the provided typescript
configuration file against a set of rules.|

The following validation rule sets are available:

| Rule set | Description |
|---------|-------------|
| **strict** ⭐ | Validates the provided config against a strict rule set
designed for maximum backwards-compatibility. |
| **generated** | Enforces a config as created by `--generate-tsconfig`.
Use this to stay compatible with the generated config, but have full
ownership over the file. |
| **minimal** | Only enforce options that are known to be incompatible
with jsii. This rule set is likely to be incomplete and new rules will
be added without notice as incompatibilities emerge. |
| **off** 🧪 | Disables all config validation, including options that are
known to be incompatible with jsii. Intended for experimentation only.
Use at your own risk. |

Resolves aws/jsii#2071

---

## Refactors

Mostly changed the compiler by moving some code around or into new
locations to be reused. Specifically the generated config was created in
multiple places without re-use. With this PR, loading or building the
tsconfig now happens once in the constructor and this config is used
through out.

## Testing strategy

Compiler changes are covered by existing test cases.
Added property-based tests for the new config validator.

---

By submitting this pull request, I confirm that my contribution is made
under the terms of the [Apache 2.0 license].

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0

(cherry picked from commit 14a51b9)
@aws-cdk-automation
Copy link
Collaborator

💚 All backports created successfully

Status Branch Result
maintenance/v5.2
maintenance/v5.3

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

github-merge-queue bot pushed a commit that referenced this pull request May 16, 2024
# Backport

This will backport the following commits from `main` to
`maintenance/v5.2`:
- [feat: user-provided TypeScript config
(#931)](#931)

<!--- Backport version: 9.5.1 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

Co-authored-by: Momo Kornher <kornherm@amazon.co.uk>
github-merge-queue bot pushed a commit that referenced this pull request May 16, 2024
# Backport

This will backport the following commits from `main` to
`maintenance/v5.3`:
- [feat: user-provided TypeScript config
(#931)](#931)

<!--- Backport version: 9.5.1 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

Co-authored-by: Momo Kornher <kornherm@amazon.co.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ability to override default settings of generated tsconfig.json
4 participants