@@ -17,8 +17,8 @@ optional in the standard [package.json schema] are required by `jsii`.
1717For example, Maven Central requires packages to carry [ sufficient metadata] , such as _ developer information_ and
1818_ license_ , in order to be valid for publishing.
1919
20- | Field | Required | Extensions |
21- | ------------ | :-------------------------------: | -------------------------------- |
20+ | Field | Required | Extensions |
21+ | ------------ | :-----------------------------: | -------------------------------- |
2222| ` author ` | :octicons-check-circle-fill-24: | ` author.organization ` |
2323| ` license ` | :octicons-check-circle-fill-24: | |
2424| ` main ` | :octicons-check-circle-fill-24: | |
@@ -135,32 +135,20 @@ package maintainer, the generic interpretation for those on packages is:
135135In order to configure the behavior of ` jsii ` , the ` package.json ` file must include a ` jsii ` section that can contain the
136136following entries:
137137
138- | Field | Type | Required | Default |
139- | ------------------- | ----------------------- | :-------------------------------:| ------------------------------------ |
140- | ` excludeTypescript ` | ` #!ts string[] ` | | _ none_ |
141- | ` metadata ` | ` #!ts object ` | | _ none_ |
142- | ` projectReferences ` | ` #!ts boolean ` | | ` #!ts true ` |
143- | ` targets ` | ` #!ts object ` | :octicons-check-circle-fill-24: | |
144- | ` tsc ` | ` #!ts object ` | | ` #!ts { outDir: '.', rootDir: '.' } ` |
145- | ` versionFormat ` | `#!ts 'short' | 'full'` | | ` #!ts 'full' ` |
138+ | Field | Type | Required | Default | Supported versions |
139+ | ------------------- | ------------------------------------------------- | :-----------------------------: | ------------------------------------ | ------------------ |
140+ | ` excludeTypescript ` | ` #!ts string[] ` | | _ none_ | _ all_ |
141+ | ` metadata ` | ` #!ts object ` | | _ none_ | _ all_ |
142+ | ` projectReferences ` | ` #!ts boolean ` | | ` #!ts true ` | _ all_ |
143+ | ` targets ` | ` #!ts object ` | :octicons-check-circle-fill-24: | | _ all_ |
144+ | ` tsc ` | ` #!ts object ` | | ` #!ts { outDir: '.', rootDir: '.' } ` | _ all_ |
145+ | ` tsconfig ` | ` #!ts string ` | | _ none_ | ` >= 5.2 ` |
146+ | ` validateTsconfig ` | `#!ts 'strict' | 'generated' | 'minimal' | 'off'` | | _ none_ | ` >= 5.2 ` |
147+ | ` versionFormat ` | `#!ts 'short' | 'full'` | | ` #!ts 'full' ` | _ all_ |
146148
147- ### ` excludeTypescript `
149+ ### Language targets
148150
149- By default, ` jsii ` will include _ all_ ` *.ts ` files (except ` .d.ts ` files) in the ` TypeScript ` compiler input. This can
150- be problematic for example when the package's build or test procedure generates ` .ts ` files that cannot be compiled with
151- ` jsii ` 's compiler settings.
152-
153- The ` excludeTypescript ` configuration accepts a list of glob patterns. Files matching any of those patterns will be
154- excluded from the ` TypeScript ` compiler input.
155-
156- ### ` metadata `
157-
158- The ` metadata ` section can be used to record additional metadata as key-value pairs that will be recorded as-is into the
159- ` .jsii ` assembly file. That metadata can later be inspected using [ ` jsii-reflect ` ] [ jsii-reflect ] utilities, for example.
160-
161- [ jsii-reflect ] : https://github.com/aws/jsii/tree/main/packages/jsii-reflect
162-
163- ### ` targets `
151+ #### ` targets `
164152
165153The ` targets ` section is where ` jsii ` packages define which target languages they support. This provides the package
166154generators with the additional information they require in order to name generated artifacts. Configuration is provided
@@ -173,7 +161,31 @@ The specific configuration accepted for each supported language is presented in
173161- [ :octicons-book-24: Java Target] ( targets/java.md )
174162- [ :octicons-book-24: Python Target] ( targets/python.md )
175163
176- ### ` tsc `
164+ ### Typescript configuration
165+
166+ By default, ` jsii ` generates a ` tsconfig.json ` for you, using best practice settings that are optimized for
167+ widespread support and backwards compatibility. Use the ` excludeTypescript ` and ` tsc ` settings to configure
168+ some supported typescript compiler options.
169+
170+ You may want to customize the typescript configuration even further. In this case, use the ` tsconfig ` setting
171+ to instruct the jsii compiler to use user-owned typescript configuration file. Such a user-provider tsconfig must
172+ follow certain rules to be a valid config for use with jsii. These rules are enforced via the ` validateTsconfig `
173+ setting. You may choose the level of validation to match your use case.
174+
175+ !!! info
176+ Using a user-provider tsconfig and configuration via ` excludeTypescript ` and ` tsc ` are mutually exclusive.
177+ Specifically when using a user-provided tsconfig, any other configuration settings will be ignored.
178+
179+ #### ` excludeTypescript `
180+
181+ By default, ` jsii ` will include _ all_ ` *.ts ` files (except ` .d.ts ` files) in the ` TypeScript ` compiler input. This can
182+ be problematic for example when the package's build or test procedure generates ` .ts ` files that cannot be compiled with
183+ ` jsii ` 's compiler settings.
184+
185+ The ` excludeTypescript ` configuration accepts a list of glob patterns. Files matching any of those patterns will be
186+ excluded from the ` TypeScript ` compiler input.
187+
188+ #### ` tsc `
177189
178190In order to the generated ` javascript ` can be properly loaded by the ` jsii ` runtimes, ` jsii ` generates a
179191[ ` tsconfig.json ` ] file with fixed settings at the beginning of the compilation pass. Certain configuration options can
@@ -188,11 +200,11 @@ are set in the `jsii.tsc` section of the `package.json` file, but use the same n
188200- ` forceConsistentCasingInFileNames ` - if ` true ` , will make the ` TypeScript ` compiler care about the casing of files
189201 specified in ` import ` statements. This is helpful if you're developing on a filesystem that is case-insensitive
190202 (Mac/Win), but building/deploying on a filesystem that is case-sensitive (Linux).
191- - ` declarationMap ` , ` inlineSourceMap ` , ` inlineSources ` , and ` sourceMap ` allow confifuring the source map generation.
203+ - ` declarationMap ` , ` inlineSourceMap ` , ` inlineSources ` , and ` sourceMap ` allow configuring the source map generation.
192204 This option can be useful to finely control your local development experience (for example, by enabling
193205 ` declarationMap ` ), or to optimize the emitted code size (by disabling source maps entirely).
194- + if any of these options is specified, the source map configuration will exactly match what is being provided here
195- + If none are specified, the default settings will be used: ` #!ts { inlineSourceMap: true, inlineSources: true } `
206+ - if any of these options is specified, the source map configuration will exactly match what is being provided here
207+ - If none are specified, the default settings will be used: ` #!ts { inlineSourceMap: true, inlineSources: true } `
196208- ` types ` allows limiting which visible type libraries get loaded in the global scope by the typescript compiler. By
197209 default, all visible ` @types/* ` packages will be loaded, which can be undesirable (in particular in monorepos, where
198210 some type libraries are not compatible with the TypeScript compiler version that ` jsii ` uses). The value specified
@@ -204,7 +216,59 @@ Refer to the [TypeScript compiler options reference][ts-options] for more inform
204216[ `tsconfig.json` ] : https://www.typescriptlang.org/docs/handbook/tsconfig-json.html
205217[ ts-options ] : https://www.typescriptlang.org/docs/handbook/compiler-options.html
206218
207- ### ` versionFormat `
219+ #### ` tsconfig `
220+
221+ _ Available from jsii >= 5.2_
222+
223+ !!! warn
224+ :test_tube : This features is experimental. Behavior may change as bugs are addressed, and requirements are clarified
225+ through early adopters. Use at your own risk, and please any [ report bugs] .
226+
227+ Provide this setting, to use a user-provided typescript configuration with ` jsii ` . Set to the name of the tsconfig
228+ file that should be used. Usually this will be ` "tsconfig.json" ` , but can be set to any filename.
229+ The provided tsconfig is subject to validation rules, see below for more details.
230+
231+ ``` json
232+ {
233+ "jsii" : {
234+ "tsconfig" : " tsconfig.json"
235+ }
236+ }
237+ ```
238+
239+ #### ` validateTsconfig `
240+
241+ _ Available from jsii >= 5.2_
242+
243+ !!! warn
244+ :test_tube : This features is experimental. Behavior may change as bugs are addressed, and requirements are clarified
245+ through early adopters. Use at your own risk, and please any [ report bugs] .
246+
247+ A user-provider typescript config must follow certain rules to be a valid config for use with jsii.
248+ By default the tsconfig is validated against the ` strict ` rule set.
249+ If needed, you can change the level of enforcement with the ` validateTsconfig ` setting.
250+
251+ --8<-- "partials/tsconfig-rulesets.md"
252+
253+ ``` json
254+ {
255+ "jsii" : {
256+ "tsconfig" : " tsconfig.json" ,
257+ "validateTsconfig" : " generated" // ensure user tsconfig is similar to jsii-generated tsconfig
258+ }
259+ }
260+ ```
261+
262+ ### Metadata
263+
264+ #### ` metadata `
265+
266+ The ` metadata ` section can be used to record additional metadata as key-value pairs that will be recorded as-is into the
267+ ` .jsii ` assembly file. That metadata can later be inspected using [ ` jsii-reflect ` ] [ jsii-reflect ] utilities, for example.
268+
269+ [ jsii-reflect ] : https://github.com/aws/jsii/tree/main/packages/jsii-reflect
270+
271+ #### ` versionFormat `
208272
209273Determines the format of the ` jsii ` toolchain version string that will be included in the ` .jsii ` assembly file's
210274` jsiiVersion ` attribute.
@@ -270,3 +334,4 @@ modules, **must** also be referenced in the [`bundledDependencies`][npm-bundled]
270334within the NPM package.
271335
272336[ npm-bundled ] : https://docs.npmjs.com/files/package.json#bundleddependencies
337+ [ report bugs ] : https://github.com/aws/jsii/issues/new/choose
0 commit comments