build: build packages in APF version 16 format · angular/universal@82e643d · GitHub
Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit 82e643d

Browse files
committed
build: build packages in APF version 16 format
This commit update tooling to generate APF version 16 distributables.
1 parent 05fd40c commit 82e643d

9 files changed

Lines changed: 266 additions & 22 deletions

File tree

‎.bazelversion‎

Lines changed: 1 addition & 2 deletions

‎WORKSPACE‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install")
4040
yarn_install(
4141
name = "npm",
4242
all_node_modules_target_name = "node_modules_all",
43+
data = [
44+
"//:tools/postinstall/patches/@angular+bazel+16.0.0-next.6.patch",
45+
"//:tools/postinstall/patches/@bazel+concatjs+5.8.1.patch",
46+
],
4347
# Currently disabled due to:
4448
# 1. Incompatibilites with the `ts_library` rule.
4549
exports_directories_only = False,

‎modules/bazel-tsconfig-build.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"moduleResolution": "node",
1717
"sourceMap": true,
1818
"inlineSources": true,
19-
"target": "es2019",
19+
"target": "es2022",
2020
"lib": ["es2018", "dom"],
2121
"skipLibCheck": true,
2222
"types": ["tslib", "node"],

‎package.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"npm": "Please use yarn instead of NPM to install dependencies"
2323
},
2424
"scripts": {
25+
"postinstall": "patch-package --patch-dir tools/postinstall/patches",
2526
"lint": "eslint --cache --max-warnings=0 \"**/*.ts\"",
2627
"ng-dev": "cross-env TS_NODE_PROJECT=$PWD/.ng-dev/tsconfig.json TS_NODE_TRANSPILE_ONLY=1 node --no-warnings --loader ts-node/esm node_modules/@angular/ng-dev/bundles/cli.mjs",
2728
"build": "npm run bazel:build",
@@ -40,7 +41,7 @@
4041
"@angular-devkit/core": "16.0.0-next.6",
4142
"@angular-devkit/schematics": "16.0.0-next.6",
4243
"@angular/animations": "16.0.0-next.5",
43-
"@angular/bazel": "15.0.4",
44+
"@angular/bazel": "https://github.com/angular/bazel-builds.git#bac9c1abe1e6ac1801fbbccb53353a1ed7126469",
4445
"@angular/build-tooling": "https://github.com/angular/dev-infra-private-build-tooling-builds.git#1bd47a37185746a38fa3371d9af080075d26d4c6",
4546
"@angular/cli": "16.0.0-next.6",
4647
"@angular/common": "16.0.0-next.5",
@@ -87,6 +88,7 @@
8788
"jsdom": "21.1.1",
8889
"node-fetch": "^2.6.1",
8990
"ora": "^5.1.0",
91+
"patch-package": "^6.5.1",
9092
"piscina": "~3.2.0",
9193
"prettier": "^2.2.1",
9294
"protractor": "7.0.0",

‎tools/defaults.bzl‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ def ts_library(
2323
testonly = False,
2424
deps = [],
2525
devmode_module = None,
26-
devmode_target = None,
2726
**kwargs):
2827
deps = deps + ["@npm//tslib", "@npm//@types/node"]
2928
if testonly:
@@ -34,14 +33,13 @@ def ts_library(
3433

3534
if not devmode_module:
3635
devmode_module = "commonjs"
37-
if not devmode_target:
38-
devmode_target = "es2019"
3936

4037
_ts_library(
4138
tsconfig = tsconfig,
4239
testonly = testonly,
4340
devmode_module = devmode_module,
44-
devmode_target = devmode_target,
41+
devmode_target = "es2022",
42+
prodmode_target = "es2022",
4543
deps = deps,
4644
**kwargs
4745
)
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
diff --git a/node_modules/@angular/bazel/src/ng_module/ng_module.bzl b/node_modules/@angular/bazel/src/ng_module/ng_module.bzl
2+
index 99d7f6d..3ea60ea 100755
3+
--- a/node_modules/@angular/bazel/src/ng_module/ng_module.bzl
4+
+++ b/node_modules/@angular/bazel/src/ng_module/ng_module.bzl
5+
@@ -18,6 +18,7 @@ load(
6+
"TsConfigInfo",
7+
"compile_ts",
8+
"js_ecma_script_module_info",
9+
+ "js_named_module_info",
10+
"js_module_info",
11+
"node_modules_aspect",
12+
"ts_providers_dict_to_struct",
13+
@@ -151,9 +152,9 @@ def _ngc_tsconfig(ctx, files, srcs, **kwargs):
14+
is_devmode = "devmode_manifest" in kwargs
15+
outs = _expected_outs(ctx)
16+
if is_devmode:
17+
- expected_outs = outs.devmode_js
18+
+ expected_outs = outs.devmode_js + outs.declarations
19+
else:
20+
- expected_outs = outs.closure_js + outs.declarations
21+
+ expected_outs = outs.closure_js
22+
23+
if not ctx.attr.type_check and ctx.attr.strict_templates:
24+
fail("Cannot set type_check = False and strict_templates = True for ng_module()")
25+
@@ -359,11 +360,11 @@ def _compile_action(
26+
27+
def _prodmode_compile_action(ctx, inputs, outputs, tsconfig_file, node_opts):
28+
outs = _expected_outs(ctx)
29+
- return _compile_action(ctx, inputs, outputs + outs.closure_js + outs.prod_perf_files + outs.declarations, tsconfig_file, node_opts, "prodmode")
30+
+ return _compile_action(ctx, inputs, outputs + outs.closure_js + outs.prod_perf_files, tsconfig_file, node_opts, "prodmode")
31+
32+
def _devmode_compile_action(ctx, inputs, outputs, tsconfig_file, node_opts):
33+
outs = _expected_outs(ctx)
34+
- compile_action_outputs = outputs + outs.devmode_js + outs.dev_perf_files
35+
+ compile_action_outputs = outputs + outs.devmode_js + outs.dev_perf_files + outs.declarations
36+
_compile_action(ctx, inputs, compile_action_outputs, tsconfig_file, node_opts, "devmode")
37+
38+
# Note: We need to define `label` and `srcs_files` as `tsc_wrapped` passes
39+
@@ -417,9 +418,13 @@ def _ng_module_impl(ctx):
40+
# and issue https://github.com/bazelbuild/rules_nodejs/issues/57 for more details.
41+
ts_providers["providers"].extend([
42+
js_module_info(
43+
- sources = ts_providers["typescript"]["es6_sources"],
44+
+ sources = ts_providers["typescript"]["es5_sources"],
45+
deps = ctx.attr.deps,
46+
),
47+
+ js_named_module_info(
48+
+ sources = ts_providers["typescript"]["es5_sources"],
49+
+ deps = ctx.attr.deps,
50+
+ ),
51+
js_ecma_script_module_info(
52+
sources = ts_providers["typescript"]["es6_sources"],
53+
deps = ctx.attr.deps,
54+
@@ -435,7 +440,7 @@ def _ng_module_impl(ctx):
55+
package_name = ctx.attr.package_name,
56+
package_path = ctx.attr.package_path,
57+
path = path,
58+
- files = ts_providers["typescript"]["es6_sources"],
59+
+ files = ts_providers["typescript"]["es5_sources"],
60+
))
61+
62+
return ts_providers_dict_to_struct(ts_providers)
63+
diff --git a/node_modules/@angular/bazel/src/ngc-wrapped/index.mjs b/node_modules/@angular/bazel/src/ngc-wrapped/index.mjs
64+
index 8681a4c..e3b497a 100755
65+
--- a/node_modules/@angular/bazel/src/ngc-wrapped/index.mjs
66+
+++ b/node_modules/@angular/bazel/src/ngc-wrapped/index.mjs
67+
@@ -13,7 +13,7 @@ import * as fs from 'fs';
68+
import * as path from 'path';
69+
import * as tsickle from 'tsickle';
70+
import ts from 'typescript';
71+
-import { EXT, patchNgHostWithFileNameToModuleName as patchNgHost, relativeToRootDirs } from './utils';
72+
+import { EXT, patchNgHostWithFileNameToModuleName as patchNgHost, relativeToRootDirs } from './utils.mjs';
73+
// FIXME: we should be able to add the assets to the tsconfig so FileLoader
74+
// knows about them
75+
const NGC_ASSETS = /\.(css|html)$/;
76+
@@ -351,6 +351,12 @@ function gatherDiagnosticsForInputsOnly(options, bazelOpts, ngProgram) {
77+
}
78+
return diagnostics;
79+
}
80+
+
81+
+main(process.argv.slice(2)).then(exitCode => process.exitCode = exitCode).catch(e => {
82+
+ console.error(e);
83+
+ process.exitCode = 1;
84+
+});
85+
+
86+
/**
87+
* @deprecated
88+
* Kept here just for compatibility with 1P tools. To be removed soon after 1P update.
89+
diff --git a/node_modules/@angular/bazel/src/ngc-wrapped/ngc-wrapped-main.mjs b/node_modules/@angular/bazel/src/ngc-wrapped/ngc-wrapped-main.mjs
90+
index 3649c11..0f4af3c 100755
91+
--- a/node_modules/@angular/bazel/src/ngc-wrapped/ngc-wrapped-main.mjs
92+
+++ b/node_modules/@angular/bazel/src/ngc-wrapped/ngc-wrapped-main.mjs
93+
@@ -5,7 +5,7 @@
94+
* Use of this source code is governed by an MIT-style license that can be
95+
* found in the LICENSE file at https://angular.io/license
96+
*/
97+
-import { main } from './index';
98+
+import { main } from './index.mjs';
99+
main(process.argv.slice(2)).then(exitCode => process.exitCode = exitCode).catch(e => {
100+
console.error(e);
101+
process.exitCode = 1;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/node_modules/@bazel/concatjs/internal/build_defs.bzl b/node_modules/@bazel/concatjs/internal/build_defs.bzl
2+
index 9e5cda6..851c8b7 100755
3+
--- a/node_modules/@bazel/concatjs/internal/build_defs.bzl
4+
+++ b/node_modules/@bazel/concatjs/internal/build_defs.bzl
5+
@@ -76,7 +76,7 @@ _TYPESCRIPT_TYPINGS = Label(
6+
"//typescript:typescript__typings",
7+
)
8+
9+
-_TYPESCRIPT_SCRIPT_TARGETS = ["es3", "es5", "es2015", "es2016", "es2017", "es2018", "es2019", "es2020", "esnext"]
10+
+_TYPESCRIPT_SCRIPT_TARGETS = ["es3", "es5", "es2015", "es2016", "es2017", "es2018", "es2019", "es2020", "es2022", "esnext"]
11+
_TYPESCRIPT_MODULE_KINDS = ["none", "commonjs", "amd", "umd", "system", "es2015", "esnext"]
12+
13+
_DEVMODE_TARGET_DEFAULT = "es2015"

‎tsconfig.json‎

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)