-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bazel): support ts_library targets as entry-points for ng_package (
#32610) Within an Angular package, it can happen that there are entry-points which do not contain features that belong into an `@NgModule` or need metadata files to be generated. For example: the `cdk`, `cdk/testing` and `cdk/coercion` entry-points. Besides other entry-points in the `cdk` package, those entry-points do not need metadata to be generated and no not use the `ng_module` rule. Currently the "ng_package" rule properly picks up such entry-points and builds bundles, does downleveling etc. The only thing it misses is that no `package.json` files are generated for the entry-point. This means that consumers will not be able to use these entry-points built with "ts_library" (except accessing the individual bundlings explicitly). The "ng_package" rule should follow the full APF specification for such entry-points. Partially building bundles and doing the downleveling is confusing and a breaking issue. The motifivation of supporting this (besides making the rule behavior consistent; the incomplete output is not acceptable), is that using the "ng_module" rule does not make sense to be used for non-Angular entry-points. Especially since it depends on Angular packages to be specified as Bazel action inputs just to compile vanilla TypeScript with `@angular/compiler-cli`. PR Close #32610
- Loading branch information
1 parent
be13e8b
commit 217db9b
Showing
14 changed files
with
1,195 additions
and
33 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
23 changes: 23 additions & 0 deletions
23
packages/bazel/test/ng_package/example-with-ts-library/BUILD.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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,23 @@ | |||
load("//tools:defaults.bzl", "ng_package", "ts_library") | |||
|
|||
package(default_visibility = ["//packages/bazel/test:__subpackages__"]) | |||
|
|||
ts_library( | |||
name = "example", | |||
srcs = glob(["*.ts"]), | |||
module_name = "example", | |||
deps = [], | |||
) | |||
|
|||
ng_package( | |||
name = "npm_package", | |||
srcs = [ | |||
"package.json", | |||
], | |||
entry_point = ":index.ts", | |||
deps = [ | |||
":example", | |||
"//packages/bazel/test/ng_package/example-with-ts-library/portal", | |||
"//packages/bazel/test/ng_package/example-with-ts-library/utils", | |||
], | |||
) |
9 changes: 9 additions & 0 deletions
9
packages/bazel/test/ng_package/example-with-ts-library/index.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
/** | |||
* @license | |||
* Copyright Google Inc. All Rights Reserved. | |||
* | |||
* Use of this source code is governed by an MIT-style license that can be | |||
* found in the LICENSE file at https://angular.io/license | |||
*/ | |||
|
|||
export const VERSION = '0.0.0'; |
13 changes: 13 additions & 0 deletions
13
packages/bazel/test/ng_package/example-with-ts-library/package.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,13 @@ | |||
{ | |||
"name": "example", | |||
"version": "0.0.0-PLACEHOLDER", | |||
"main": "./bundles/example.umd.js", | |||
"fesm5": "./fesm5/example.js", | |||
"fesm2015": "./fesm2015/example.js", | |||
"esm5": "./esm5/index.js", | |||
"esm2015": "./esm2015/index.js", | |||
"typings": "./index.d.ts", | |||
"module": "./fesm5/example.js", | |||
"es2015": "./fesm2015/example.js", | |||
"schematics": "Custom property that should be preserved." | |||
} |
14 changes: 14 additions & 0 deletions
14
packages/bazel/test/ng_package/example-with-ts-library/portal/BUILD.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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,14 @@ | |||
load("//tools:defaults.bzl", "ng_module") | |||
|
|||
package(default_visibility = ["//packages/bazel/test:__subpackages__"]) | |||
|
|||
ng_module( | |||
name = "portal", | |||
srcs = glob(["*.ts"]), | |||
bundle_dts = False, | |||
module_name = "example/portal", | |||
deps = [ | |||
"//packages/core", | |||
"@npm//@types", | |||
], | |||
) |
9 changes: 9 additions & 0 deletions
9
packages/bazel/test/ng_package/example-with-ts-library/portal/index.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
/** | |||
* @license | |||
* Copyright Google Inc. All Rights Reserved. | |||
* | |||
* Use of this source code is governed by an MIT-style license that can be | |||
* found in the LICENSE file at https://angular.io/license | |||
*/ | |||
|
|||
export * from './portal-module'; |
15 changes: 15 additions & 0 deletions
15
packages/bazel/test/ng_package/example-with-ts-library/portal/portal-module.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,15 @@ | |||
/** | |||
* @license | |||
* Copyright Google Inc. All Rights Reserved. | |||
* | |||
* Use of this source code is governed by an MIT-style license that can be | |||
* found in the LICENSE file at https://angular.io/license | |||
*/ | |||
|
|||
import {NgModule} from '@angular/core'; | |||
|
|||
@NgModule({}) | |||
export class PortalModule { | |||
} | |||
|
|||
export const a = 1; |
9 changes: 9 additions & 0 deletions
9
packages/bazel/test/ng_package/example-with-ts-library/utils/BUILD.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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
load("//tools:defaults.bzl", "ts_library") | |||
|
|||
package(default_visibility = ["//packages/bazel/test:__subpackages__"]) | |||
|
|||
ts_library( | |||
name = "utils", | |||
srcs = glob(["*.ts"]), | |||
module_name = "example/utils", | |||
) |
9 changes: 9 additions & 0 deletions
9
packages/bazel/test/ng_package/example-with-ts-library/utils/index.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
/** | |||
* @license | |||
* Copyright Google Inc. All Rights Reserved. | |||
* | |||
* Use of this source code is governed by an MIT-style license that can be | |||
* found in the LICENSE file at https://angular.io/license | |||
*/ | |||
|
|||
export * from './testing'; |
Oops, something went wrong.