Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

feat(@angular-devkit/build-ng-packagr): permit to set a custom TsConfig file #750

Merged
merged 3 commits into from
Apr 20, 2018
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ node_modules/
tmp/
npm-debug.log*
yarn-error.log*
.ng_pkg_build/

# Mac OSX Finder files.
**/.DS_Store
Expand Down
13 changes: 10 additions & 3 deletions packages/angular_devkit/build_ng_packagr/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function requireProjectModule(root: string, moduleName: string) {

export interface NgPackagrBuilderOptions {
project: string;
tsConfig?: string;
}

export class NgPackagrBuilder implements Builder<NgPackagrBuilderOptions> {
Expand All @@ -46,9 +47,15 @@ export class NgPackagrBuilder implements Builder<NgPackagrBuilderOptions> {
getSystemPath(root), 'ng-packagr') as typeof ngPackagr;
const packageJsonPath = getSystemPath(resolve(root, normalize(options.project)));

projectNgPackagr.ngPackagr()
.forProject(packageJsonPath)
.build()
const ngPkgProject = projectNgPackagr.ngPackagr()
.forProject(packageJsonPath);

if (options.tsConfig) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@filipesilva (about your first concern) except if I didn't tought about something, the tsConfig is not mandatory (you can see that the tests doesn't fail after the first commit), given that I first test if it's set before using it in the ngPackagr. Did I forgot some "optionnal" config somewhere ?

const tsConfigPath = getSystemPath(resolve(root, normalize(options.tsConfig)));
ngPkgProject.withTsConfig(tsConfigPath);
}

ngPkgProject.build()
.then(() => {
obs.next({ success: true });
obs.complete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"project": {
"type": "string",
"description": "The file path of the package.json for distribution via npm."
},
"tsConfig": {
"type": "string",
"description": "The file path of the TypeScript configuration file."
}
},
"additionalProperties": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"build": {
"builder": "../../../../packages/angular_devkit/build_ng_packagr:build",
"options": {
"project": "projects/lib/ng-package.json"
"project": "projects/lib/ng-package.json",
"tsConfig": "projects/lib/tsconfig.lib.json"
}
},
"test": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ export class LibService {

constructor() { }

testEs2016() {
return ['foo', 'bar'].includes('foo');
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "es6",
"moduleResolution": "node",
"sourceMap": true,
"inlineSources": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"lib": ["dom", "es2016"]
}
}