Skip to content

Commit 90c2088

Browse files
committed
build: make devmode a noop and ensure it never runs (angular#48521)
This is basically a pre-step for combining devmode and prodmode into a single compilation. We are already achieving this now, and can claim with confidence that we reduced possible actions by half. This is especially important now that prodmode is used more often, but rules potentially still using the devmode ESM sources. We can avoid double compilations (which existed before the whole ESM migration too!). We will measure this more when we have more concrete documentation of the changes & a better planning document. Changes: * ts_library will no longer generate devmode `d.ts`. Definitions are generated as part of prodmode. That way only prodmode can be exposed via providers. * applied the same to `ng_module`. * updates migrations to bundle because *everything* using `ts_library` is now ESM. This is actually also useful in the future if schematics rely on e.g. the compiler. * updates schematics for localize to also bundle. similar reason as above. PR Close angular#48521
1 parent 623ca1f commit 90c2088

File tree

40 files changed

+330
-219
lines changed

40 files changed

+330
-219
lines changed

WORKSPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ yarn_install(
105105
"//:scripts/puppeteer-chromedriver-versions.js",
106106
"//:scripts/webdriver-manager-update.js",
107107
"//tools:postinstall-patches.js",
108-
"//tools/esm-interop:patches/npm/@angular+build-tooling+0.0.0-d4d1329adbe1cdb5fd382d618e830c69e578c41b.patch",
108+
"//tools/esm-interop:patches/npm/@angular+build-tooling+0.0.0-246cebbf2a78566ff1fe9b88fdde2459606568dc.patch",
109109
"//tools/esm-interop:patches/npm/@bazel+concatjs+5.7.1.patch",
110110
"//tools/esm-interop:patches/npm/@bazel+esbuild+5.7.1.patch",
111111
"//tools/esm-interop:patches/npm/@bazel+protractor+5.7.1.patch",

aio/content/examples/examples.bzl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,13 @@ def docs_example(name, test = True, test_tags = [], test_exec_properties = {}, f
190190
nodejs_test(
191191
name = "e2e",
192192
data = [
193+
":%s" % name,
194+
YARN_LABEL,
193195
"@aio_npm//@angular/build-tooling/bazel/browsers/chromium",
194196
"//aio/tools/examples:run-example-e2e",
195197
"//aio/tools:windows-chromium-path",
196198
# We install the whole node modules for runtime deps of e2e tests
197199
"@{workspace}//:node_modules_files".format(workspace = EXAMPLE_DEPS_WORKSPACE_NAME),
198-
],
199-
data_for_expansion = [
200-
":%s" % name,
201-
YARN_LABEL,
202200
] + select({
203201
"//aio:aio_local_deps": LOCAL_PACKAGE_DEPS,
204202
"//conditions:default": [],

aio/scripts/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ nodejs_test(
8484
testonly = True,
8585
data = [
8686
":audit-web-app",
87+
":audit-web-app-script",
8788
"@aio_npm//shelljs",
8889
],
89-
data_for_expansion = [":audit-web-app-script"],
9090
entry_point = "test-aio-a11y.mjs",
9191
env = {
9292
"AUDIT_SCRIPT_PATH": "$(rootpath :audit-web-app-script)",

aio/scripts/local_server_test.bzl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ def local_server_test(name, entry_point, serve_target, data = [], args = [], **k
1515
nodejs_test(
1616
name = name,
1717
testonly = True,
18-
data_for_expansion = [
19-
serve_target,
20-
entry_point,
21-
"@aio_npm//light-server/bin:light-server",
22-
],
2318
args = [
2419
"$(rootpath @aio_npm//light-server/bin:light-server)",
2520
"$(rootpath %s)" % serve_target,
@@ -30,6 +25,9 @@ def local_server_test(name, entry_point, serve_target, data = [], args = [], **k
3025
"@aio_npm//get-port",
3126
"@aio_npm//shelljs",
3227
"@aio_npm//tree-kill",
28+
"@aio_npm//light-server/bin:light-server",
29+
serve_target,
30+
entry_point,
3331
] + data,
3432
entry_point = "//aio/scripts:run-with-local-server.mjs",
3533
**kwargs

modules/playground/src/routing/app/inbox-app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export class DraftsCmp {
125125
export const ROUTER_CONFIG: Routes = [
126126
{path: '', pathMatch: 'full', redirectTo: 'inbox'}, {path: 'inbox', component: InboxCmp},
127127
{path: 'drafts', component: DraftsCmp},
128-
{path: 'detail', loadChildren: () => import('./inbox-detail.js').then(mod => mod.default)}
128+
{path: 'detail', loadChildren: () => import('./inbox-detail').then(mod => mod.default)}
129129
];
130130

131131
@Component({selector: 'inbox-app', templateUrl: './inbox-app.html'})

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179
},
180180
"// 2": "devDependencies are not used under Bazel. Many can be removed after test.sh is deleted.",
181181
"devDependencies": {
182-
"@angular/build-tooling": "https://github.com/angular/dev-infra-private-build-tooling-builds.git#98ed19ad0bc7e985718d240aac9c9f56f5fbcd4c",
182+
"@angular/build-tooling": "https://github.com/angular/dev-infra-private-build-tooling-builds.git#c70bd1895ed5b95dc97cb57f3ef2a0f045d1700c",
183183
"@angular/ng-dev": "https://github.com/angular/dev-infra-private-ng-dev-builds.git#05278122c48e06eff8e5398d59c49ed6688c949b",
184184
"@bazel/bazelisk": "^1.7.5",
185185
"@bazel/buildifier": "^5.0.0",

packages/bazel/src/ng_module/ng_module.bzl

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ load(
1919
"compile_ts",
2020
"js_ecma_script_module_info",
2121
"js_module_info",
22-
"js_named_module_info",
2322
"node_modules_aspect",
2423
"ts_providers_dict_to_struct",
2524
"tsc_wrapped_tsconfig",
@@ -184,9 +183,9 @@ def _ngc_tsconfig(ctx, files, srcs, **kwargs):
184183
is_devmode = "devmode_manifest" in kwargs
185184
outs = _expected_outs(ctx)
186185
if is_devmode:
187-
expected_outs = outs.devmode_js + outs.declarations
186+
expected_outs = outs.devmode_js
188187
else:
189-
expected_outs = outs.closure_js
188+
expected_outs = outs.closure_js + outs.declarations
190189

191190
if not ctx.attr.type_check and ctx.attr.strict_templates:
192191
fail("Cannot set type_check = False and strict_templates = True for ng_module()")
@@ -390,11 +389,11 @@ def _compile_action(
390389

391390
def _prodmode_compile_action(ctx, inputs, outputs, tsconfig_file, node_opts):
392391
outs = _expected_outs(ctx)
393-
return _compile_action(ctx, inputs, outputs + outs.closure_js + outs.prod_perf_files, tsconfig_file, node_opts, "prodmode")
392+
return _compile_action(ctx, inputs, outputs + outs.closure_js + outs.prod_perf_files + outs.declarations, tsconfig_file, node_opts, "prodmode")
394393

395394
def _devmode_compile_action(ctx, inputs, outputs, tsconfig_file, node_opts):
396395
outs = _expected_outs(ctx)
397-
compile_action_outputs = outputs + outs.devmode_js + outs.declarations + outs.dev_perf_files
396+
compile_action_outputs = outputs + outs.devmode_js + outs.dev_perf_files
398397
_compile_action(ctx, inputs, compile_action_outputs, tsconfig_file, node_opts, "devmode")
399398

400399
# Note: We need to define `label` and `srcs_files` as `tsc_wrapped` passes
@@ -448,11 +447,7 @@ def _ng_module_impl(ctx):
448447
# and issue https://github.com/bazelbuild/rules_nodejs/issues/57 for more details.
449448
ts_providers["providers"].extend([
450449
js_module_info(
451-
sources = ts_providers["typescript"]["es5_sources"],
452-
deps = ctx.attr.deps,
453-
),
454-
js_named_module_info(
455-
sources = ts_providers["typescript"]["es5_sources"],
450+
sources = ts_providers["typescript"]["es6_sources"],
456451
deps = ctx.attr.deps,
457452
),
458453
js_ecma_script_module_info(
@@ -470,7 +465,7 @@ def _ng_module_impl(ctx):
470465
package_name = ctx.attr.package_name,
471466
package_path = ctx.attr.package_path,
472467
path = path,
473-
files = ts_providers["typescript"]["es5_sources"],
468+
files = ts_providers["typescript"]["es6_sources"],
474469
))
475470

476471
return ts_providers_dict_to_struct(ts_providers)

packages/bazel/src/ng_package/BUILD.bazel

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
2-
3-
# BEGIN-DEV-ONLY
4-
load("@npm//@bazel/concatjs:index.bzl", "ts_library")
5-
# END-DEV-ONLY
1+
load("//tools:defaults.bzl", "nodejs_binary", "ts_library")
62

73
package(default_visibility = ["//visibility:public"])
84

packages/bazel/test/ngc-wrapped/flat_module_test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ describe('flat_module ng_module', () => {
1616

1717
beforeAll(() => {
1818
packageOutput =
19-
dirname(runfiles.resolve('angular/packages/bazel/test/ngc-wrapped/flat_module/index.js'));
20-
flatModuleOutFile = join(packageOutput, 'flat_module.js');
19+
dirname(runfiles.resolve('angular/packages/bazel/test/ngc-wrapped/flat_module/index.mjs'));
20+
flatModuleOutFile = join(packageOutput, 'flat_module.mjs');
2121
});
2222

2323
it('should have a flat module out file', () => {

packages/bazel/test/ngc-wrapped/ivy_enabled/ng_module_ivy_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {readFileSync} from 'fs';
1212
describe('ng_module with ivy enabled', () => {
1313
it('should generate definitions as with full compilation mode', () => {
1414
const outputFile = runfiles.resolveWorkspaceRelative(
15-
'packages/bazel/test/ngc-wrapped/ivy_enabled/test_module_default_compilation.js');
15+
'packages/bazel/test/ngc-wrapped/ivy_enabled/test_module_default_compilation.mjs');
1616
const fileContent = readFileSync(outputFile, 'utf8');
1717
expect(fileContent).toContain(`TestComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent(`);
1818
});

0 commit comments

Comments
 (0)