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

chore: enable project references in build #1466

Merged
merged 9 commits into from
Jan 3, 2019
Merged
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
3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ fail() {

/bin/bash ./git-secrets-scan.sh

# Prepare for build with references
/bin/bash scripts/generate-aggregate-tsconfig.sh > tsconfig.json

BUILD_INDICATOR=".BUILD_COMPLETED"
rm -rf $BUILD_INDICATOR

Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"nodeunit": "^0.11.2",
"nyc": "^13.0.1",
"tslint": "^5.10.0",
"typescript": "^3.1.2"
"typescript": "^3.2.2"
},
"repository": {
"type": "git",
Expand Down
12 changes: 10 additions & 2 deletions packages/@aws-cdk/assert/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"target":"es2018",
"lib": ["es2016", "es2017.object", "es2017.string"],
"module": "commonjs",
"composite": true,
"declaration": true,
"strict": true,
"noImplicitAny": true,
Expand All @@ -17,6 +18,13 @@
"inlineSources": true,
"strictPropertyInitialization": false,
"experimentalDecorators": true
}
},
"include": ["**/*.ts" ],
"exclude": ["node_modules"],
"references": [
{ "path": "../cdk" },
{ "path": "../cx-api" },
{ "path": "../cfnspec" },
{ "path": "../cloudformation-diff" }
]
}

3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-sns/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"assemblyOriginatorKeyFile": "../../key.snk"
},
"sphinx": {}
}
},
"excludeTypescript": ["examples"]
},
"repository": {
"type": "git",
Expand Down
6 changes: 4 additions & 2 deletions packages/@aws-cdk/cfnspec/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"module": "commonjs",
"lib": ["es2016", "es2017.object", "es2017.string"],
"declaration": true,
"composite": true,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
Expand All @@ -17,6 +18,7 @@
"inlineSources": true,
"experimentalDecorators": true,
"strictPropertyInitialization":false
}
},
"include": ["**/*.ts" ],
"exclude": ["node_modules"]
}

9 changes: 6 additions & 3 deletions packages/@aws-cdk/cloudformation-diff/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"module": "commonjs",
"lib": ["es2016", "es2017.object", "es2017.string"],
"declaration": true,
"composite": true,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
Expand All @@ -18,8 +19,10 @@
"inlineSources": true,
"experimentalDecorators": true
},
"exclude": [
"lib/init-templates/**/*.ts"
"include": ["**/*.ts" ],
"exclude": ["node_modules"],
"references": [
{ "path": "../cfnspec" },
{ "path": "../cx-api" }
]
}

42 changes: 1 addition & 41 deletions scripts/build-typescript.sh
Original file line number Diff line number Diff line change
@@ -1,42 +1,2 @@
#!/bin/bash
cat <<EOF > tsconfig.json
{
"compilerOptions": {
"alwaysStrict": true,
"charset": "utf8",
"declaration": false,
"experimentalDecorators": true,
"inlineSourceMap": true,
"inlineSources": true,
"lib": [
"es2016",
"es2017.object",
"es2017.string"
],
"module": "CommonJS",
"noEmitOnError": false,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"resolveJsonModule": true,
"strict": true,
"strictNullChecks": true,
"target": "ES2018"
},
"include": [
"packages/**/*.ts",
"tools/**/*.ts"
],
"exclude": [
"node_modules",
"packages/@aws-cdk/aws-sns/examples",
"tools/cfn2ts/test/enrichments",
"packages/aws-cdk/lib/init-templates"
],
"_generated_by_jsii_": "Generated by jsii - safe to delete, and ideally should be in .gitignore"
}
EOF
node_modules/.bin/tsc -p . "$@"
node_modules/.bin/tsc -b "$@"
17 changes: 17 additions & 0 deletions scripts/generate-aggregate-tsconfig.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
# Generate an aggregate tsconfig.json with references to all projects in the
# repository.
prefix="$(pwd)/"

echo '{'
echo ' "__comment__": "This file is necessary to make transitive Project References in TypeScript work",'
echo ' "files": [],'
echo ' "references": ['
comma=' '
for package in $(node_modules/.bin/lerna ls -p); do
relpath=${package#"$prefix"}
echo ' '"$comma"'{ "path": "'"$relpath"'" }'
comma=', '
done
echo ' ]'
echo '}'
2 changes: 1 addition & 1 deletion tools/cdk-build-tools/bin/cdk-watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async function main() {
})
.argv as any;

await shell([packageCompiler({ jsii: args.jsii, tsc: args.tsc }), '-w']);
await shell(packageCompiler({ jsii: args.jsii, tsc: args.tsc }).concat(['-w']));
}

main().catch(e => {
Expand Down
2 changes: 1 addition & 1 deletion tools/cdk-build-tools/lib/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Timers } from "./timer";
* Run the compiler on the current package
*/
export async function compileCurrentPackage(timers: Timers, compilers: CompilerOverrides = {}): Promise<void> {
await shell([packageCompiler(compilers)], timers);
await shell(packageCompiler(compilers), timers);

// Find files in bin/ that look like they should be executable, and make them so.
const scripts = currentPackageJson().bin || {};
Expand Down
9 changes: 6 additions & 3 deletions tools/cdk-build-tools/lib/package-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,12 @@ export interface CompilerOverrides {
/**
* Return the compiler for this package (either tsc or jsii)
*/
export function packageCompiler(compilers: CompilerOverrides) {
return isJsii() ? compilers.jsii || require.resolve('jsii/bin/jsii')
: compilers.tsc || require.resolve('typescript/bin/tsc');
export function packageCompiler(compilers: CompilerOverrides): string[] {
if (isJsii()) {
return [compilers.jsii || require.resolve('jsii/bin/jsii'), '--project-references'];
} else {
return [compilers.tsc || require.resolve('typescript/bin/tsc')];
}
}

export interface CDKBuildOptions {
Expand Down
4 changes: 2 additions & 2 deletions tools/cdk-build-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
},
"dependencies": {
"fs-extra": "^7.0.0",
"jsii": "^0.7.12",
"jsii-pacmak": "^0.7.12",
"jsii": "^0.7.13",
"jsii-pacmak": "^0.7.13",
"nodeunit": "^0.11.3",
"nyc": "^13.0.1",
"typescript": "^3.1.2",
Expand Down