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
Bazel build rules moving into Angular repo #18733
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
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 |
---|---|---|
@@ -1,17 +1,21 @@ | ||
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") | ||
|
||
git_repository( | ||
name = "build_bazel_rules_typescript", | ||
remote = "https://github.com/bazelbuild/rules_typescript.git", | ||
tag = "0.0.5", | ||
name = "build_bazel_rules_nodejs", | ||
remote = "https://github.com/bazelbuild/rules_nodejs.git", | ||
tag = "0.0.2", | ||
) | ||
|
||
load("@build_bazel_rules_typescript//:defs.bzl", "node_repositories") | ||
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories") | ||
|
||
node_repositories(package_json = "//:package.json") | ||
node_repositories(package_json = ["//:package.json"]) | ||
|
||
git_repository( | ||
name = "build_bazel_rules_angular", | ||
remote = "https://github.com/bazelbuild/rules_angular.git", | ||
tag = "0.0.1", | ||
local_repository( | ||
name = "build_bazel_rules_typescript", | ||
path = "node_modules/@bazel/typescript", | ||
) | ||
|
||
local_repository( | ||
name = "angular", | ||
path = "packages/bazel", | ||
) |
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,10 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
filegroup( | ||
name = "node_modules", | ||
srcs = glob([ | ||
"node_modules/**/*.js", | ||
"node_modules/**/*.d.ts", | ||
"node_modules/**/*.json", | ||
]) | ||
) |
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,30 @@ | ||
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") | ||
|
||
git_repository( | ||
name = "build_bazel_rules_nodejs", | ||
remote = "https://github.com/bazelbuild/rules_nodejs.git", | ||
tag = "0.0.2", | ||
) | ||
|
||
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories") | ||
node_repositories(package_json = ["//:package.json"]) | ||
|
||
local_repository( | ||
name = "build_bazel_rules_typescript", | ||
path = "node_modules/@bazel/typescript", | ||
) | ||
|
||
local_repository( | ||
name = "angular", | ||
path = "node_modules/@angular/bazel", | ||
) | ||
|
||
git_repository( | ||
name = "io_bazel_rules_sass", | ||
remote = "https://github.com/bazelbuild/rules_sass.git", | ||
tag = "0.0.2", | ||
) | ||
|
||
load("@io_bazel_rules_sass//sass:sass.bzl", "sass_repositories") | ||
|
||
sass_repositories() |
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 @@ | ||
// WORKAROUND https://github.com/angular/angular/issues/18810 | ||
// This file is required to run ngc on angular libraries, to write files like | ||
// node_modules/@angular/core/core.ngsummary.json | ||
{ | ||
"compilerOptions": { | ||
"lib": [ | ||
"dom", | ||
"es2015" | ||
], | ||
"experimentalDecorators": true, | ||
"types": [] | ||
}, | ||
"include": [ | ||
"node_modules/@angular/**/*" | ||
], | ||
"exclude": [ | ||
"node_modules/@angular/bazel/**", | ||
"node_modules/@angular/compiler-cli/**", | ||
// Workaround bug introduced by 079d884 | ||
"node_modules/@angular/common/i18n_data*", | ||
"node_modules/@angular/tsc-wrapped/**" | ||
] | ||
} |
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,25 @@ | ||
{ | ||
"name": "angular-bazel", | ||
"description": "example and integration test for building Angular apps with Bazel", | ||
"version": "0.0.0", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@angular/animations": "file:../../dist/packages-dist/animations", | ||
"@angular/common": "file:../../dist/packages-dist/common", | ||
"@angular/compiler": "file:../../dist/packages-dist/compiler", | ||
"@angular/core": "file:../../dist/packages-dist/core", | ||
"@angular/platform-browser": "file:../../dist/packages-dist/platform-browser", | ||
"rxjs": "5.3.1", | ||
"zone.js": "0.8.6" | ||
}, | ||
"devDependencies": { | ||
"@angular/bazel": "file:../../dist/packages-dist/bazel", | ||
"@angular/compiler-cli": "file:../../dist/packages-dist/compiler-cli", | ||
"@bazel/typescript": "0.0.7", | ||
"typescript": "~2.3.1" | ||
}, | ||
"scripts": { | ||
"postinstall": "ngc -p angular.tsconfig.json", | ||
"test": "bazel build ..." | ||
} | ||
} |
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,11 @@ | ||
load("@angular//:index.bzl", "ng_module") | ||
|
||
# Allow targets under sub-packages to reference the tsconfig.json file | ||
exports_files(["tsconfig.json"]) | ||
|
||
ng_module( | ||
name = "app", | ||
srcs = ["app.module.ts"], | ||
deps = ["//src/hello-world"], | ||
tsconfig = ":tsconfig.json", | ||
) |
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,9 @@ | ||
import {HelloWorldModule} from './hello-world/hello-world.module'; | ||
|
||
import {NgModule} from '@angular/core'; | ||
import {BrowserModule} from '@angular/platform-browser'; | ||
|
||
@NgModule({ | ||
imports: [BrowserModule, HelloWorldModule] | ||
}) | ||
export class AppModule {} |
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,19 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
load("@angular//:index.bzl", "ng_module") | ||
load("@io_bazel_rules_sass//sass:sass.bzl", "sass_binary") | ||
|
||
sass_binary( | ||
name = "styles", | ||
src = "hello-world.component.scss", | ||
deps = [ | ||
"//src/shared:colors", | ||
"//src/shared:fonts", | ||
], | ||
) | ||
|
||
ng_module( | ||
name = "hello-world", | ||
srcs = glob(["*.ts"]), | ||
tsconfig = "//src:tsconfig.json", | ||
assets = [":styles"], | ||
) |
12 changes: 12 additions & 0 deletions
12
integration/bazel/src/hello-world/hello-world.component.scss
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,12 @@ | ||
@import "src/shared/fonts"; | ||
@import "src/shared/colors"; | ||
|
||
html { | ||
body { | ||
font-family: $default-font-stack; | ||
h1 { | ||
font-family: $modern-font-stack; | ||
color: $example-red; | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
integration/bazel/src/hello-world/hello-world.component.ts
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,15 @@ | ||
|
||
import {Component, NgModule} from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'hello-world-app', | ||
template: ` | ||
<div>Hello {{ name }}!</div> | ||
<input type="text" [value]="name" (input)="name = $event.target.value"/> | ||
`, | ||
// TODO: might be better to point to .scss so this looks valid at design-time | ||
styleUrls: ['./styles.css'] | ||
}) | ||
export class HelloWorldComponent { | ||
name: string = 'world'; | ||
} |
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,8 @@ | ||
import {HelloWorldComponent} from './hello-world.component'; | ||
import {NgModule} from '@angular/core'; | ||
|
||
@NgModule({ | ||
declarations: [HelloWorldComponent], | ||
bootstrap: [HelloWorldComponent], | ||
}) | ||
export class HelloWorldModule {} |
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 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
load("@io_bazel_rules_sass//sass:sass.bzl", "sass_library") | ||
|
||
sass_library( | ||
name = "colors", | ||
srcs = ["_colors.scss"], | ||
) | ||
|
||
sass_library( | ||
name = "fonts", | ||
srcs = ["_fonts.scss"], | ||
) |
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,2 @@ | ||
$example-blue: #0000ff; | ||
$example-red: #ff0000; |
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,2 @@ | ||
$default-font-stack: Cambria, "Hoefler Text", Utopia, "Liberation Serif", "Nimbus Roman No9 L Regular", Times, "Times New Roman", serif; | ||
$modern-font-stack: Constantia, "Lucida Bright", Lucidabright, "Lucida Serif", Lucida, "DejaVu Serif", "Bitstream Vera Serif", "Liberation Serif", Georgia, serif; |
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,12 @@ | ||
{ | ||
"compilerOptions": { | ||
"experimentalDecorators": true, | ||
"lib": [ | ||
"dom", | ||
"es5", | ||
"es2015.collection", | ||
"es2015.iterable", | ||
"es2015.promise" | ||
] | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 @@ | ||
# Empty marker file, indicating this directory is a Bazel package. |
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,9 @@ | ||
# By convention, the name should "describe the project in reverse-DNS form" | ||
# https://docs.bazel.build/versions/master/be/functions.html#workspace | ||
# But if we use "io_angular" then the loads used in BUILD files will | ||
# be unfamiliar to Angular users who import from '@angular/pkg' in | ||
# TypeScript files. We want to reduce the impedance between the Bazel | ||
# and node naming schemes. | ||
# We take the name "angular" so that users can write | ||
# load("@angular//:index.bzl", "ng_module") | ||
workspace(name = "angular") |
Oops, something went wrong.
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.
why are these under
shared
?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.
This was following the example from the sass rules
https://github.com/bazelbuild/rules_sass#basic-example
I'd prefer to lay these out following the angular style guide, but I didn't spend the time to learn it...