-
Notifications
You must be signed in to change notification settings - Fork 246
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(jsii): configure outDir and rootDir for tsc #593
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f9a73a2
feat(jsii): configure outDIr and rootDir for tsc
hoegertn cbf1594
fix: path
hoegertn ab4a8c5
add docs
hoegertn ac57eb7
fix: move tsconfig options to sub struct
00b5c37
Merge remote-tracking branch 'origin/master' into configure-tsc-out
hoegertn 45aa01a
chore: review comments
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,10 +98,11 @@ export class Compiler implements Emitter { | |
} | ||
|
||
const tsconf = this.typescriptConfig!; | ||
const pi = this.options.projectInfo; | ||
|
||
const prog = ts.createProgram({ | ||
rootNames: this.rootFiles.concat(_pathOfLibraries(this.compilerHost)), | ||
options: COMPILER_OPTIONS, | ||
options: {...COMPILER_OPTIONS, outDir: pi.tsc && pi.tsc.outDir, rootDir: pi.tsc && pi.tsc.rootDir}, | ||
// Make the references absolute for the compiler | ||
projectReferences: tsconf.references && tsconf.references.map(ref => ({ path: path.resolve(ref.path) })), | ||
host: this.compilerHost | ||
|
@@ -115,10 +116,16 @@ export class Compiler implements Emitter { | |
*/ | ||
private async _startWatch(): Promise<never> { | ||
return new Promise<never>(async () => { | ||
const projectRoot = this.options.projectInfo.projectRoot; | ||
const pi = this.options.projectInfo; | ||
const projectRoot = pi.projectRoot; | ||
const host = ts.createWatchCompilerHost( | ||
this.configPath, | ||
{ ...COMPILER_OPTIONS, noEmitOnError: false }, | ||
{ | ||
...COMPILER_OPTIONS, | ||
noEmitOnError: false, | ||
outDir: pi.tsc && pi.tsc.outDir, | ||
rootDir: pi.tsc && pi.tsc.rootDir, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, here I'd just |
||
}, | ||
{ ...ts.sys, getCurrentDirectory() { return projectRoot; } } | ||
); | ||
if (!host.getDefaultLibLocation) { | ||
|
@@ -180,6 +187,8 @@ export class Compiler implements Emitter { | |
composite = true; | ||
} | ||
|
||
const pi = this.options.projectInfo; | ||
|
||
this.typescriptConfig = { | ||
compilerOptions: { | ||
...COMPILER_OPTIONS, | ||
|
@@ -188,11 +197,13 @@ export class Compiler implements Emitter { | |
lib: COMPILER_OPTIONS.lib && COMPILER_OPTIONS.lib.map(name => name.slice(4, name.length - 5)), | ||
// Those int-enums, we need to output the names instead | ||
module: COMPILER_OPTIONS.module && ts.ModuleKind[COMPILER_OPTIONS.module], | ||
outDir: pi.tsc && pi.tsc.outDir, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here :) |
||
rootDir: pi.tsc && pi.tsc.rootDir, | ||
target: COMPILER_OPTIONS.target && ts.ScriptTarget[COMPILER_OPTIONS.target], | ||
jsx: COMPILER_OPTIONS.jsx && Case.snake(ts.JsxEmit[COMPILER_OPTIONS.jsx]), | ||
}, | ||
include: ["**/*.ts"], | ||
exclude: ["node_modules"].concat(this.options.projectInfo.excludeTypescript), | ||
include: [pi.tsc && pi.tsc.rootDir ? `${pi.tsc.rootDir}/**/*.ts` : "**/*.ts"], | ||
exclude: ["node_modules"].concat(pi.excludeTypescript), | ||
// Change the references a little. We write 'originalpath' to the | ||
// file under the 'path' key, which is the same as what the | ||
// TypeScript compiler does. Make it relative so that the files are | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be (since we decided to use the same name...):
The order is important here - we don't want
pi.tsc
to be able to override the required settings we have inCOMPILER_OPTIONS
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for now this would work, but if someone adds rootDir or outDir to COMPILER_OPTIONS manual overrides would no longer be possible. But I am fine with the change.