This repository was archived by the owner on May 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 307
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(angular): support angular 2.3+ ngc api
- Loading branch information
1 parent
b76c21b
commit 13e930a
Showing
7 changed files
with
88 additions
and
54 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { CodegenOptions } from '../util/interfaces'; | ||
import { runCodegen, isAngular22 } from './codegen/codegen-ng22'; | ||
import { runCodegen as runCodegen23 } from './codegen/codegen-ng23plus'; | ||
|
||
|
||
export function doCodegen(options: CodegenOptions) { | ||
if (isAngular22()) { | ||
return runCodegen(options); | ||
} | ||
return runCodegen23(options); | ||
} | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import * as CompilerCLI from '@angular/compiler-cli'; | ||
import { CodegenOptions } from '../../util/interfaces'; | ||
|
||
export function isAngular22() { | ||
if ((CompilerCLI as any).NodeReflectorHostContext) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
export function runCodegen(options: CodegenOptions) { | ||
const NodeReflectorHostContextConstructor = (CompilerCLI as any).NodeReflectorHostContext; | ||
const instance = new NodeReflectorHostContextConstructor(options.compilerHost); | ||
const codeGenerator = CompilerCLI.CodeGenerator.create(options.angularCompilerOptions, | ||
options.cliOptions, | ||
options.program, | ||
options.compilerHost, | ||
instance); | ||
|
||
// angular 2.2 api to codegen | ||
return (codeGenerator.codegen as any)({transitiveModules: true}); | ||
} | ||
|
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import * as CompilerCLI from '@angular/compiler-cli'; | ||
import { CodegenOptions } from '../../util/interfaces'; | ||
|
||
export function isAngular23Plus() { | ||
if ((CompilerCLI as any).NodeCompilerHostContext) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
export function runCodegen(options: CodegenOptions) { | ||
const NodeCompilerHostContext = (CompilerCLI as any).NodeCompilerHostContext; | ||
const instance = new NodeCompilerHostContext(); | ||
const codeGenerator = CompilerCLI.CodeGenerator.create(options.angularCompilerOptions, | ||
options.cliOptions, | ||
options.program, | ||
options.compilerHost, | ||
instance); | ||
|
||
// angular 2.3+ api for codegen does not take any options | ||
return (codeGenerator.codegen as any)(); | ||
} |
This file was deleted.
Oops, something went wrong.
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