Skip to content

Commit c8cd5d5

Browse files
devversiondylhunn
authored andcommitted
build: switch all instances from ng_rollup_bundle to app_bundle (#44490)
The `ng_rollup_bundle` rule has been replaced with a new rule called `app_bundle`. This rule replicates the Angular v13 optimization pipeline in the CLI, so that we can get better benchmarking results. Also the rule is much simpler to maintain as it relies on ESbuild. The old `ng_rollup_bundle` rule did rely on e.g. build-optimizer that no longer has an effect on v13 Angular packages, so technically size tests/symbol tests were no longer as correct as they were before. This commit fixes that. A couple of different changes and their explanation: * Language-service will no longer use the benchmark rule for creating its NPM bundles! It will use plain `rollup_bundle`. ESBuild would have been nice but the language-service relies on AMD that ESBuild cannot generate (yet?) * Service-worker ngsw-worker.js file was generated using the benchmark bundle rule. This is wrong. We will use a simple ESbuild rule in the future. The output is more predictable that way, and we can have a clear use of the benchmark bundle rule.. * A couple of benchmarks in `modules/` had to be updated to use e.g. `initTableUtils` calls. This is done because with the new rule, all files except for the entry-point are considered side-effect free. The utilities for benchmarks relied on side-effects in some transitively-loaded file (bad practice anyway IMO). We are now initializing the utilities using a proper init function that is exported... PR Close #44490
1 parent 4e58a50 commit c8cd5d5

File tree

84 files changed

+496
-593
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+496
-593
lines changed

modules/benchmarks/src/change_detection/transplanted_views/BUILD.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle", "ts_devserver")
1+
load("//tools:defaults.bzl", "app_bundle", "ng_module", "ts_devserver")
22
load("@npm//@angular/dev-infra-private/bazel/benchmark/component_benchmark:benchmark_test.bzl", "benchmark_test")
33
load("//modules/benchmarks:e2e_test.bzl", "e2e_test")
44

@@ -18,7 +18,7 @@ ng_module(
1818
],
1919
)
2020

21-
ng_rollup_bundle(
21+
app_bundle(
2222
name = "bundle",
2323
entry_point = ":index_aot.ts",
2424
deps = [
@@ -32,7 +32,7 @@ ts_devserver(
3232
bootstrap = ["//packages/zone.js/bundles:zone.umd.js"],
3333
port = 4200,
3434
static_files = ["index.html"],
35-
deps = [":bundle.min_debug.js"],
35+
deps = [":bundle.debug.min.js"],
3636
)
3737

3838
benchmark_test(

modules/benchmarks/src/expanding_rows/BUILD.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle", "ts_devserver", "ts_library")
1+
load("//tools:defaults.bzl", "app_bundle", "ng_module", "ts_devserver", "ts_library")
22
load("@npm//@angular/dev-infra-private/bazel/benchmark/component_benchmark:benchmark_test.bzl", "benchmark_test")
33

44
package(default_visibility = ["//modules/benchmarks:__subpackages__"])
@@ -31,7 +31,7 @@ ts_library(
3131
],
3232
)
3333

34-
ng_rollup_bundle(
34+
app_bundle(
3535
name = "bundle",
3636
entry_point = ":index_aot.ts",
3737
deps = [
@@ -45,7 +45,7 @@ ts_devserver(
4545
bootstrap = ["//packages/zone.js/bundles:zone.umd.js"],
4646
port = 4200,
4747
static_files = ["index.html"],
48-
deps = [":bundle.min_debug.js"],
48+
deps = [":bundle.debug.min.js"],
4949
)
5050

5151
ts_devserver(

modules/benchmarks/src/js-web-frameworks/ng2/BUILD.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle", "ts_devserver")
1+
load("//tools:defaults.bzl", "app_bundle", "ng_module", "ts_devserver")
22
load("@npm//@angular/dev-infra-private/bazel/benchmark/component_benchmark:benchmark_test.bzl", "benchmark_test")
33

44
package(default_visibility = ["//modules/benchmarks:__subpackages__"])
@@ -15,7 +15,7 @@ ng_module(
1515
],
1616
)
1717

18-
ng_rollup_bundle(
18+
app_bundle(
1919
name = "bundle",
2020
entry_point = ":index_aot.ts",
2121
deps = [
@@ -29,7 +29,7 @@ ts_devserver(
2929
bootstrap = ["//packages/zone.js/bundles:zone.umd.js"],
3030
port = 4200,
3131
static_files = ["index.html"],
32-
deps = [":bundle.min_debug.js"],
32+
deps = [":bundle.debug.min.js"],
3333
)
3434

3535
benchmark_test(

modules/benchmarks/src/largetable/baseline/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
*/
88

99
import {bindAction, profile} from '../../util';
10-
import {buildTable, emptyTable} from '../util';
10+
import {buildTable, emptyTable, initTableUtils} from '../util';
11+
1112
import {TableComponent} from './table';
1213

1314
let table: TableComponent;
@@ -27,6 +28,8 @@ function init() {
2728
rootEl.textContent = '';
2829
table = new TableComponent(rootEl);
2930

31+
initTableUtils();
32+
3033
bindAction('#destroyDom', destroyDom);
3134
bindAction('#createDom', createDom);
3235

modules/benchmarks/src/largetable/incremental_dom/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
*/
88

99
import {bindAction, profile} from '../../util';
10-
import {buildTable, emptyTable} from '../util';
10+
import {buildTable, emptyTable, initTableUtils} from '../util';
11+
1112
import {TableComponent} from './table';
1213

1314
let table: TableComponent;
@@ -25,6 +26,8 @@ function noop() {}
2526
function init() {
2627
table = new TableComponent(document.querySelector('largetable'));
2728

29+
initTableUtils();
30+
2831
bindAction('#destroyDom', destroyDom);
2932
bindAction('#createDom', createDom);
3033

modules/benchmarks/src/largetable/ng2/BUILD.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle", "ts_devserver")
1+
load("//tools:defaults.bzl", "app_bundle", "ng_module", "ts_devserver")
22
load("@npm//@angular/dev-infra-private/bazel/benchmark/component_benchmark:benchmark_test.bzl", "benchmark_test")
33
load("//modules/benchmarks:e2e_test.bzl", "e2e_test")
44

@@ -21,7 +21,7 @@ ng_module(
2121
],
2222
)
2323

24-
ng_rollup_bundle(
24+
app_bundle(
2525
name = "bundle",
2626
entry_point = ":index_aot.ts",
2727
deps = [
@@ -35,7 +35,7 @@ ts_devserver(
3535
bootstrap = ["//packages/zone.js/bundles:zone.umd.js"],
3636
port = 4200,
3737
static_files = ["index.html"],
38-
deps = [":bundle.min_debug.js"],
38+
deps = [":bundle.debug.min.js"],
3939
)
4040

4141
benchmark_test(

modules/benchmarks/src/largetable/ng2/init.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import {ApplicationRef, NgModuleRef} from '@angular/core';
1010

1111
import {bindAction, profile} from '../../util';
12-
import {buildTable, emptyTable} from '../util';
12+
import {buildTable, emptyTable, initTableUtils} from '../util';
1313

1414
import {AppModule, TableComponent} from './table';
1515

@@ -31,8 +31,10 @@ export function init(moduleRef: NgModuleRef<AppModule>) {
3131

3232
const injector = moduleRef.injector;
3333
appRef = injector.get(ApplicationRef);
34-
3534
table = appRef.components[0].instance;
35+
36+
initTableUtils();
37+
3638
bindAction('#destroyDom', destroyDom);
3739
bindAction('#createDom', createDom);
3840
bindAction('#updateDomProfile', profile(createDom, noop, 'update'));

modules/benchmarks/src/largetable/ng2_switch/init.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import {ApplicationRef, NgModuleRef} from '@angular/core';
1010

1111
import {bindAction, profile} from '../../util';
12-
import {buildTable, emptyTable} from '../util';
12+
import {buildTable, emptyTable, initTableUtils} from '../util';
1313

1414
import {AppModule, TableComponent} from './table';
1515

@@ -31,8 +31,10 @@ export function init(moduleRef: NgModuleRef<AppModule>) {
3131

3232
const injector = moduleRef.injector;
3333
appRef = injector.get(ApplicationRef);
34-
3534
table = appRef.components[0].instance;
35+
36+
initTableUtils();
37+
3638
bindAction('#destroyDom', destroyDom);
3739
bindAction('#createDom', createDom);
3840
bindAction('#updateDomProfile', profile(createDom, noop, 'update'));

modules/benchmarks/src/largetable/render3/BUILD.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle", "ts_devserver")
1+
load("//tools:defaults.bzl", "app_bundle", "ng_module", "ts_devserver")
22
load("@npm//@angular/dev-infra-private/bazel/benchmark/component_benchmark:benchmark_test.bzl", "benchmark_test")
33
load("//modules/benchmarks:e2e_test.bzl", "e2e_test")
44

@@ -19,7 +19,7 @@ ng_module(
1919
],
2020
)
2121

22-
ng_rollup_bundle(
22+
app_bundle(
2323
name = "bundle",
2424
entry_point = ":index_aot.ts",
2525
deps = [
@@ -33,7 +33,7 @@ ts_devserver(
3333
port = 4200,
3434
static_files = ["index.html"],
3535
deps = [
36-
":bundle.min_debug.js",
36+
":bundle.debug.min.js",
3737
],
3838
)
3939

modules/benchmarks/src/largetable/render3/index_aot.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import {ɵrenderComponent as renderComponent} from '@angular/core';
99

1010
import {bindAction, profile} from '../../util';
11+
import {initTableUtils} from '../util';
1112

1213
import {createDom, destroyDom, LargeTableComponent} from './table';
1314

@@ -17,6 +18,9 @@ export function main() {
1718
let component: LargeTableComponent;
1819
if (typeof window !== 'undefined') {
1920
component = renderComponent<LargeTableComponent>(LargeTableComponent);
21+
22+
initTableUtils();
23+
2024
bindAction('#createDom', () => createDom(component));
2125
bindAction('#destroyDom', () => destroyDom(component));
2226
bindAction('#updateDomProfile', profile(() => createDom(component), noop, 'update'));

modules/benchmarks/src/largetable/util.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ let maxCol: number;
1818
let numberData: TableCell[][];
1919
let charData: TableCell[][];
2020

21-
init();
22-
23-
function init() {
21+
export function initTableUtils() {
2422
maxRow = getIntParameter('rows');
2523
maxCol = getIntParameter('cols');
2624
tableCreateCount = 0;

modules/benchmarks/src/styling/ng2/BUILD.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle", "ts_devserver")
1+
load("//tools:defaults.bzl", "app_bundle", "ng_module", "ts_devserver")
22
load("@npm//@angular/dev-infra-private/bazel/benchmark/component_benchmark:benchmark_test.bzl", "benchmark_test")
33

44
package(default_visibility = ["//modules/benchmarks:__subpackages__"])
@@ -15,7 +15,7 @@ ng_module(
1515
],
1616
)
1717

18-
ng_rollup_bundle(
18+
app_bundle(
1919
name = "bundle",
2020
entry_point = ":index_aot.ts",
2121
deps = [
@@ -29,7 +29,7 @@ ts_devserver(
2929
bootstrap = ["//packages/zone.js/bundles:zone.umd.js"],
3030
port = 4200,
3131
static_files = ["index.html"],
32-
deps = [":bundle.min_debug.js"],
32+
deps = [":bundle.debug.min.js"],
3333
)
3434

3535
benchmark_test(

modules/benchmarks/src/styling/ng2/init.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,10 @@
77
*/
88

99
import {ApplicationRef, NgModuleRef} from '@angular/core';
10-
import {bindAction, profile} from '../../util';
11-
import {StylingModule} from './styling';
1210

13-
const empty = [];
14-
const items = [];
15-
for (let i = 0; i < 2000; i++) {
16-
items.push(i);
17-
}
11+
import {bindAction, profile} from '../../util';
1812

13+
import {StylingModule} from './styling';
1914

2015
export function init(moduleRef: NgModuleRef<StylingModule>) {
2116
const injector = moduleRef.injector;
@@ -25,6 +20,9 @@ export function init(moduleRef: NgModuleRef<StylingModule>) {
2520
const componentHostEl = componentRef.location.nativeElement;
2621
const select = document.querySelector('#scenario-select')! as HTMLSelectElement;
2722

23+
const empty = [];
24+
const items = [];
25+
2826
function create(tplRefIdx: number) {
2927
component.tplRefIdx = tplRefIdx;
3028
component.data = items;
@@ -57,6 +55,10 @@ export function init(moduleRef: NgModuleRef<StylingModule>) {
5755
});
5856
}
5957

58+
for (let i = 0; i < 2000; i++) {
59+
items.push(i);
60+
}
61+
6062
bindAction('#create', () => create(select.selectedIndex));
6163
bindAction('#update', update);
6264
bindAction('#detect_changes', detectChanges);

modules/benchmarks/src/tree/baseline/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
*/
88

99
import {bindAction, profile} from '../../util';
10-
import {buildTree, emptyTree} from '../util';
10+
import {buildTree, emptyTree, initTreeUtils} from '../util';
11+
1112
import {TreeComponent} from './tree';
1213

1314
let tree: TreeComponent;
@@ -27,6 +28,8 @@ function init() {
2728
rootEl.textContent = '';
2829
tree = new TreeComponent(rootEl);
2930

31+
initTreeUtils();
32+
3033
bindAction('#destroyDom', destroyDom);
3134
bindAction('#createDom', createDom);
3235

modules/benchmarks/src/tree/incremental_dom/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
*/
88

99
import {bindAction, profile} from '../../util';
10-
import {buildTree, emptyTree} from '../util';
10+
import {buildTree, emptyTree, initTreeUtils} from '../util';
11+
1112
import {TreeComponent} from './tree';
1213

1314
let tree: TreeComponent;
@@ -25,6 +26,8 @@ function noop() {}
2526
function init() {
2627
tree = new TreeComponent(document.querySelector('tree'));
2728

29+
initTreeUtils();
30+
2831
bindAction('#destroyDom', destroyDom);
2932
bindAction('#createDom', createDom);
3033

modules/benchmarks/src/tree/ng1/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import {bindAction, profile} from '../../util';
10-
import {buildTree, emptyTree} from '../util';
10+
import {buildTree, emptyTree, initTreeUtils} from '../util';
1111

1212
import {addTreeToModule} from './tree';
1313

@@ -42,6 +42,8 @@ function init() {
4242
});
4343
}
4444

45+
initTreeUtils();
46+
4547
bindAction('#destroyDom', destroyDom);
4648
bindAction('#createDom', createDom);
4749
bindAction('#detectChanges', detectChanges);

modules/benchmarks/src/tree/ng2/BUILD.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle", "ts_devserver")
1+
load("//tools:defaults.bzl", "app_bundle", "ng_module", "ts_devserver")
22
load("@npm//@angular/dev-infra-private/bazel/benchmark/component_benchmark:benchmark_test.bzl", "benchmark_test")
33
load("//modules/benchmarks:e2e_test.bzl", "e2e_test")
44

@@ -21,7 +21,7 @@ ng_module(
2121
],
2222
)
2323

24-
ng_rollup_bundle(
24+
app_bundle(
2525
name = "bundle",
2626
entry_point = ":index_aot.ts",
2727
deps = [
@@ -35,7 +35,7 @@ ts_devserver(
3535
bootstrap = ["//packages/zone.js/bundles:zone.umd.js"],
3636
port = 4200,
3737
static_files = ["index.html"],
38-
deps = [":bundle.min_debug.js"],
38+
deps = [":bundle.debug.min.js"],
3939
)
4040

4141
benchmark_test(

modules/benchmarks/src/tree/ng2/init.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import {ApplicationRef, NgModuleRef} from '@angular/core';
1010

1111
import {bindAction, profile} from '../../util';
12-
import {buildTree, emptyTree} from '../util';
12+
import {buildTree, emptyTree, initTreeUtils} from '../util';
1313

1414
import {AppModule, TreeComponent} from './tree';
1515

@@ -44,6 +44,8 @@ export function init(moduleRef: NgModuleRef<AppModule>) {
4444

4545
tree = appRef.components[0].instance;
4646

47+
initTreeUtils();
48+
4749
bindAction('#destroyDom', destroyDom);
4850
bindAction('#createDom', createDom);
4951
bindAction('#detectChanges', detectChanges);

0 commit comments

Comments
 (0)