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

docs: add custom compiler example #213

Merged
merged 1 commit into from
Oct 31, 2022
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
27 changes: 27 additions & 0 deletions examples/custom_compiler/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Shows the use of an alternative compiler, in this case the ngc compiler from Angular.

The compiler has to use the same CLI as `tsc` for this to work.
"""

load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load("@npm//examples:@angular/compiler-cli/package_json.bzl", "bin")

bin.ngc_binary(
name = "ngc",
)

ts_project(
name = "compile",
srcs = [
# Shows that ts_project accepts any file@npm//examples:@angular/compiler-cli/s in srcs, because it can't assume
# the tsc compiler is the only one used.
"component.ng.html",
"component.ts",
],
args = ["--listFiles"],
tsc = ":ngc",
deps = [
"//examples:node_modules/@angular/core",
"//examples:node_modules/@types/node",
],
)
1 change: 1 addition & 0 deletions examples/custom_compiler/component.ng.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div>{{thing}}</div>
8 changes: 8 additions & 0 deletions examples/custom_compiler/component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Component } from '@angular/core'

@Component({
templateUrl: './component.ng.html',
})
export class Comp {
thing: string = ''
}
9 changes: 9 additions & 0 deletions examples/custom_compiler/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"module": "es2015",
"moduleResolution": "node",
"lib": ["ES2015", "DOM"],
"composite": false,
"experimentalDecorators": true
}
}
4 changes: 4 additions & 0 deletions examples/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"private": true,
"dependencies": {
"@angular/core": "14",
alexeagle marked this conversation as resolved.
Show resolved Hide resolved
"@angular/compiler": "14",
jbedard marked this conversation as resolved.
Show resolved Hide resolved
"@angular/compiler-cli": "14",
"@babel/cli": "7.18.9",
"@babel/core": "7.18.9",
"@babel/parser": "7.18.9",
Expand All @@ -9,6 +12,7 @@
"@types/jasmine": "*",
"@types/node": "18.6.1",
"date-fns": "2.29.1",
"rxjs": "7",
"typescript": "4.8.2"
}
}
Loading