Commit Graph

436 Commits

Author SHA1 Message Date
Kara Erickson 86104b82b8 refactor(core): rename ngInjectableDef to ɵprov (#33151)
Injectable defs are not considered public API, so the property
that contains them should be prefixed with Angular's marker
for "private" ('ɵ') to discourage apps from relying on def
APIs directly.

This commit adds the prefix and shortens the name from
ngInjectableDef to "prov" (for "provider", since injector defs
are known as "inj"). This is because property names cannot
be minified by Uglify without turning on property mangling
(which most apps have turned off) and are thus size-sensitive.

PR Close #33151
2019-10-16 16:36:19 -04:00
Greg Magolan 0004896ff9 build: update to nodejs rules 0.38.3 (#33073)
All providers now loaded from "@build_bazel_rules_nodejs//:providers.bzl".

PR Close #33073
2019-10-14 20:25:57 +00:00
Greg Magolan 5e694e519b build: update to nodejs rules 0.38.2 (#33073)
Some changes in rules_nodejs providers folded into @angular/bazel package:
* `NodeModuleSources` renamed to `NpmPackageInfo` and now loaded from `//internal/common:npm_package_info.bzl`
* `collect_node_modules_aspect` renamed to `node_modules_aspect`
* new JS provider `JSNamedModuleInfo` now available and ng_module provides it using the `js_named_module_info` factory function
* sources_aspect has also been removed so the use of the `node_sources` legacy provider has been replaced with `JSNamedModuleInfo`.

PR Close #33073
2019-10-14 20:25:57 +00:00
Alex Rickabaugh ed711418f1 style(bazel): fix 2 unformatted .bzl files 2019-10-08 10:45:48 -07:00
Alex Eagle c653a16b57 build: load build_bazel_rules_nodejs through external (#33041)
PR Close #33041
2019-10-08 10:24:41 -07:00
Greg Magolan 64823f561c build: add history-server to @angular/bazel schematics (#32889)
The history_server rule is not longer shipped with rules_nodejs as it has been replaced by auto-generated rule `load("@npm//history-server:index.bzl", "history_server")` which requires the user to add history-server to their package.json.

PR Close #32889
2019-10-08 09:27:11 -07:00
Greg Magolan e1d07b2fd2 build: add JSEcmaScripModuleInfo provider to ng_module (#32889)
PR Close #32889
2019-10-08 09:27:11 -07:00
Alex Eagle cdfbda3d3b build: add missing http-server dep to bazel example (#32889)
Also update rules_nodejs 0.38.0->0.38.1

PR Close #32889
2019-10-08 09:27:11 -07:00
Alex Eagle f783244ad1 build: update to rules_nodejs 0.38 (#32889)
PR Close #32889
2019-10-08 09:27:11 -07:00
George Kalpakas 75fd407bbd build: avoid error in `build-packages-dist.sh` (#32923)
Not sure why it works on other people's environments, but after
217db9b21 I started getting the following error when running
`scripts/build-packages-dist.sh` (on Windows):

```
ERROR: C:/.../angular/packages/bazel/docs/BUILD.bazel:3:1: Generating Skylark documentation dir for docs (3 files) failed (Exit 1)
Traceback (most recent call last):
  File "c:\...\temp\Bazel.runfiles_u_l5te\runfiles\io_bazel_skydoc\skydoc\main.py", line 335, in <module>
    main(sys.argv)
  File "c:\...\temp\Bazel.runfiles_u_l5te\runfiles\io_bazel_skydoc\skydoc\main.py", line 303, in main
    load_symbols = load_sym_extractor.extract(bzl_file)
  File "c:\...\temp\Bazel.runfiles_u_l5te\runfiles\io_bazel_skydoc\skydoc\load_extractor.py", line 110, in extract
    load_symbols = self._extract_loads(bzl_file)
  File "c:\...\temp\Bazel.runfiles_u_l5te\runfiles\io_bazel_skydoc\skydoc\load_extractor.py", line 38, in _extract_loads
    tree = ast.parse(f.read(), bzl_file)
  File "C:\...\.windows-build-tools\python27\lib\ast.py", line 37, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "packages/bazel/src/ng_package/ng_package.bzl", line 39
    print("[ng_package.bzl]", *args)
                              ^
SyntaxError: invalid syntax
```

It seems expected, because `print` is not a function, so
`print(foo, *args)` is interpreted as printing a tuple (where `*args` is
invalid syntax). Not sure why it doesn't break on other people's
machines :/

This change makes the verbose logs a little less pretty, but that
shouldn't be a big issue (given that it is an opt-in feature and it can
always be overwritten locally, if necessary).

PR Close #32923
2019-10-04 08:27:21 -07:00
Paul Gschwendtner 954b8e53a2 refactor(bazel): ng_module action description should include compile mode (#32955)
Similarly to `ts_library` compilation actions, the `ng_module` compile action should include
the current compile mode in the action description. This makes it consistent with `ts_library`
targets and also avoids confusion when both output flavors are requested.

Currently when both output flavors are requested (e.g. in the `ng_package` rule), both
devmode and prodmode compilations have the same action name. This is confusing and
looks like the given target is built *twice* due to a bug (which is obviously not the case though)

PR Close #32955
2019-10-02 13:21:40 -07:00
Greg Magolan c1346462db build: update to nodejs rules 0.37.1 (#32151)
This release includes a ts_config runfiles fix so also cleaning up the one line work-around from #31943.

This also updates to upstream rules_webtesting browser repositories load("@io_bazel_rules_webtesting//web/versioned:browsers-0.3.2.bzl", "browser_repositories") to fix a breaking change in the chromedriver distro. This bumps up the version of chromium to the version here: https://github.com/bazelbuild/rules_webtesting/blob/master/web/versioned/browsers-0.3.2.bzl

PR Close #32151
2019-09-25 11:29:12 -07:00
Jason Bedard df1c456347 fix(bazel): ng_package(data) should support non-text files (#32721)
PR Close #32721
2019-09-17 15:58:42 -07:00
Paul Gschwendtner 217db9b216 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
2019-09-13 13:23:55 -07:00
Greg Magolan 9448828b0d refactor(bazel): remove @angular/bazel protractor rule now provided by @bazel/protractor (#32485)
BREAKING CHANGE:
Angular bazel users using protractor_web_test_suite from @angular/bazel npm package should now switch to the @bazel/protractor npm package.

This should impact very few users and the user's that are impacted have a very easy upgrade path to switch to fetching the protractor_web_test_suite rule via the @bazel/protractor npm package.

PR Close #32485
2019-09-10 15:19:31 -04:00
Alan Agius 350ea47def feat(bazel): update to the latest `@microsoft/api-extractor` (#32185)
PR Close #32185
2019-08-30 13:55:32 -04:00
Miško Hevery 64770571b2 perf: don't create holey arrays (#32155)
Don't use `Array` constructor with the size value (ex. `new Array(5)`) - this will create a `HOLEY_ELEMENTS` array (even if this array is filled in later on!);

https://v8.dev/blog/elements-kinds
https://stackoverflow.com/questions/32054170/how-to-resize-an-array

PR Close #32155
2019-08-21 08:27:43 -07:00
Alex Rickabaugh ec4381dd40 feat: make the Ivy compiler the default for ngc (#32219)
This commit switches the default value of the enableIvy flag to true.
Applications that run ngc will now by default receive an Ivy build!

This does not affect the way Bazel builds in the Angular repo work, since
those are still switched based on the value of the --define=compile flag.
Additionally, projects using @angular/bazel still use View Engine builds
by default.

Since most of the Angular repo tests are still written against View Engine
(particularly because we still publish VE packages to NPM), this switch
also requires lots of `enableIvy: false` flags in tsconfigs throughout the
repo.

Congrats to the team for reaching this milestone!

PR Close #32219
2019-08-20 16:41:08 -07:00
Alex Rickabaugh 2b64031ddc refactor(ivy): remove the tsc passthrough option (#32219)
This option makes ngc behave as tsc, and was originally implemented before
ngtsc existed. It was designed so we could build JIT-only versions of
Angular packages to begin testing Ivy early, and is not used at all in our
current setup.

PR Close #32219
2019-08-20 16:41:08 -07:00
Alan Agius 5da5ca5c23 fix(bazel): pin `@microsoft/api-extractor` (#32187)
The API of `@microsoft/api-extractor` changed in a minor version which is causes an error when using dts flattening downstream.

API wil be updated on master https://github.com/angular/angular/pull/32185

PR Close #32187
2019-08-19 15:42:44 -07:00
Filipe Silva 431ddb9a45 test(bazel): use cross-platform file read of golden file (#31266)
PR Close #31266
2019-08-19 13:32:13 -07:00
Alan Agius 7b9414565e style: fix inline comment typo (#32090)
PR Close #32090
2019-08-12 07:06:00 -07:00
Alan c198a27a3c test: update golden files (#32069)
PR Close #32069
2019-08-09 14:15:25 -07:00
Alan 4f37487b1c fix(bazel): disable treeshaking when generating FESM and UMD bundles (#32069)
There has been a regression where enabling rollup treeshaking causes errors during runtime because it will drop const access which will always evaluate to true or false. However, such `const` in `@angular/core` cannot be dropped because their value is changed when NGCC is run on `@angular/core`

VE
```
const SWITCH_IVY_ENABLED__POST_R3__ = true;
const SWITCH_IVY_ENABLED__PRE_R3__ = false;
const ivyEnabled = SWITCH_IVY_ENABLED__PRE_R3__;
```

Ivy (After NGCC)
```
const SWITCH_IVY_ENABLED__POST_R3__ = true;
const SWITCH_IVY_ENABLED__PRE_R3__ = false;
const ivyEnabled = SWITCH_IVY_ENABLED__POST_R3__;
```

FESM2015
```
load(path) {
	/** @type {?} */
	const legacyOfflineMode = this._compiler instanceof Compiler;
	return legacyOfflineMode ? this.loadFactory(path) : this.loadAndCompile(path);
}
```

ESM2015
```
 load(path) {
	/** @type {?} */
	const legacyOfflineMode = !ivyEnabled && this._compiler instanceof Compiler;
	return legacyOfflineMode ? this.loadFactory(path) : this.loadAndCompile(path);
}
```

From the above we can see that `ivyEnabled ` is being treeshaken away when generating the FESM bundle which is causing runtime errors such as `Cannot find module './lazy/lazy.module.ngfactory'` since in Ivy we will always load the factories.

PR Close #32069
2019-08-09 14:15:25 -07:00
Greg Magolan 5f0d5e9ccf build: update to nodejs rules 0.34.0 and bazel 0.28.1 (#31824)
nodejs rules 0.34.0 now includes protractor_web_test_suite rule (via new @bazel/protractor rule) so we switch to that location for that rule in this PR so that /packages/bazel/src/protractor can be removed in a future PR

this PR also brings in node toolchain support which was released in nodejs rules 0.33.0. this is a prerequisite for RBE for mac & windows users

bazel schematics also updated with the same. @bazel/bazel 0.28.1 npm package includes transitive dep on hide-bazel-files so we're able to remove an explicit dep on that as well.

PR Close #31824
2019-07-26 15:01:25 -07:00
Igor Minar 6ece7db37a build: TypeScript 3.5 upgrade (#31615)
https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#typescript-35

PR Close #31615
2019-07-25 17:05:23 -07:00
Ayaz Hafiz 82055b2fb8 feat(bazel): compile targets used for indexing by Kythe with Ivy (#31786)
This switches all Angular targets to be built with the same Angular compiler architecture (c.n. Ivy) that the Angular indexer uses. This eliminates issues with cross-references to transitive dependencies not being generated because of the way such dependencies are loaded by the legacy compiler arch.

PR Close #31786
2019-07-23 21:14:16 -07:00
Alex Rickabaugh 5a8eb924ba fix(bazel): increase memory limit of ngc under bazel from 2 to 4 GB (#31784)
This commit bumps the heap size of node/ngc under bazel to 4 GB instead of
the previous 2 GB. This brings it in sync with what the TS compiler uses
in g3, and fixes a bug where ngc would crash with OOM in worker mode.

PR Close #31784
2019-07-22 12:14:14 -07:00
Ayaz Hafiz 0c61a35ea3 fix(bazel): pass custom bazel compiler host rather than rewriting one (#31496)
Switch back to passing a custom bazel host instead of rewriting one that
is passed to `compile` now that the Angular indexer is stable.

Revert "feat(bazel): allow passing and rewriting an old bazel host"

This reverts commit 0a4c1c8f803a65f5c156af90e67f7d7d68ebc7f8.

PR Close #31496
2019-07-12 11:37:58 -04:00
George Kalpakas 7724f7446a refactor(bazel): remove unused lockfile (#31458)
The corresponding `package.json` file was removed in 15c2467db; it looks
like the lockfile was left behind by accident.

PR Close #31458
2019-07-09 13:49:43 -07:00
Alex Eagle 1d3e22766a fix(bazel): revert location of xi18n outputs to bazel-genfiles (#31410)
This is needed in g3 where the translation system is sensitive to the full path of the output.
For Bazel users, we don't want this because it would force them to
disable a Bazel option that prevents using the deprecated ctx.new_file
API

PR Close #31410
2019-07-03 14:15:12 -07:00
Ayaz Hafiz 11a208f55c feat(bazel): allow passing and rewriting an old bazel host (#31381)
Updates the decision made in #31341; this is for the Angular indexer
inside Google. The indexer currently passes (and ngc-wrapped#compile
accepts) a bazel host to use, but because many methods are overwritten
specially for Angular compilation a better approach is to pass an old
bazel compiler host and siphon methods needed off of it before creating
a new host. This enables that.

PR Close #31381
2019-07-02 11:28:41 -07:00
Greg Magolan ba5b3af077 build(bazel): update //packages/bazel/test/ngc-wrapped:ngc_test test (#31325)
after update to rules_nodejs 0.32.1, @types are no longer automatically discovered by ngc-wrapped (which uses parts of ts_library) so this test needed updating so that the types files it generates is added as an explicit dep

PR Close #31325
2019-07-01 14:16:42 -07:00
Greg Magolan d2d84c4460 build(bazel): remove deprecated rules_nodejs NodeModuleInfo provider (#31325)
PR Close #31325
2019-07-01 14:16:42 -07:00
Greg Magolan 361109d80f build: update to rules_nodejs 0.32.2 (#31325)
Brings in ts_library fixes required to get angular/angular building after 0.32.0:
typescript: exclude typescript lib declarations in node_module_library transitive_declarations
typescript: remove override of @bazel/tsetse (+1 squashed commit)

@npm//node_modules/foobar:foobar.js labels changed to @npm//:node_modules/foobar/foobar.js with fix for bazelbuild/rules_nodejs#802

also updates to rules_rass commit compatible with rules_nodejs 0.32.0

PR Close #31325
2019-07-01 14:16:42 -07:00
Greg Magolan b7a099d27e build(bazel): update to bazel 0.27.0 and fix compat in @angular/bazel package (#31325)
ctx.actions.declare_file now used in @angular/bazel ng_module rule as ctx.new_file is now deprecated. Fixes error:

```
        File "ng_module.bzl", line 272, in _expected_outs
                ctx.new_file(ctx.genfiles_dir, (ctx.label.name ..."))
Use ctx.actions.declare_file instead of ctx.new_file.
Use --incompatible_new_actions_api=false to temporarily disable this check.
```

This can be worked around with incompatible_new_actions_api flag but may as well fix it proper so downstream doesn't require this flag due to this code.

Also, depset() is no longer iterable by default without a flag. This required fixing in a few spots in @angular/bazel.

fix: foo

PR Close #31325
2019-07-01 14:16:42 -07:00
Ayaz Hafiz a29dc961a2 feat(bazel): allow passing a custom bazel compiler host to ngc compile (#31341)
Enable users to pass a custom Bazel CompilerHost to use for an Angular
compilation. This supports users who must override the TypeScript
compiler host.

PR Close #31341
2019-06-28 12:18:20 -07:00
George Kalpakas 3851544674 style: fix code style in several files (#31295)
These files have not been formatted properly, due to issues in the
`gulp format*` tasks. See previous commits (or #31295) for more details.

PR Close #31295
2019-06-26 13:29:29 -07:00
Alex Rickabaugh 280e8563f0 Revert "build(bazel): update to bazel 0.27.0 and fix compat in @angular/bazel package (#31019)" (#31267)
This reverts commit 28d3bfc416.

Reason: this causes failures in g3 with i18n extraction. See #31267.

PR Close #31267
2019-06-25 14:36:01 -07:00
Alex Rickabaugh 660800ca4e Revert "build: update to rules_nodejs 0.32.2 (#31019)" (#31267)
This reverts commit a38433f36b.

Reason: this causes failures in g3 with i18n extraction. See #31267.

PR Close #31267
2019-06-25 14:36:00 -07:00
Alex Rickabaugh 5eb4691dec Revert "build(bazel): remove deprecated rules_nodejs NodeModuleInfo provider (#31019)" (#31267)
This reverts commit 72e4ff7591.

Reason: this causes failures in g3 with i18n extraction. See #31267.

PR Close #31267
2019-06-25 14:36:00 -07:00
Alex Rickabaugh 8afc998ec4 Revert "build(bazel): update //packages/bazel/test/ngc-wrapped:ngc_test test (#31019)" (#31267)
This reverts commit 708d0a2db2.

Reason: this causes failures in g3 with i18n extraction. See #31267.

PR Close #31267
2019-06-25 14:36:00 -07:00
Paul Gschwendtner 1d5c44551d build: use checked-in configuration from bazel-toolchains (#31251)
No longer uses docker in order to pull down the toolchain configs
for remote build execution. We don't need to make docker a prerequisite
for working on the Angular repository since we can leverage the checked-in
toolchain configurations from the `@bazel-toolchains` repository.

PR Close #31251
2019-06-25 10:24:43 -07:00
Greg Magolan 708d0a2db2 build(bazel): update //packages/bazel/test/ngc-wrapped:ngc_test test (#31019)
after update to rules_nodejs 0.32.1, @types are no longer automatically discovered by ngc-wrapped (which uses parts of ts_library) so this test needed updating so that the types files it generates is added as an explicit dep

PR Close #31019
2019-06-25 10:21:07 -07:00
Greg Magolan 72e4ff7591 build(bazel): remove deprecated rules_nodejs NodeModuleInfo provider (#31019)
PR Close #31019
2019-06-25 10:21:07 -07:00
Greg Magolan a38433f36b build: update to rules_nodejs 0.32.2 (#31019)
Brings in ts_library fixes required to get angular/angular building after 0.32.0:
typescript: exclude typescript lib declarations in node_module_library transitive_declarations
typescript: remove override of @bazel/tsetse (+1 squashed commit)

@npm//node_modules/foobar:foobar.js labels changed to @npm//:node_modules/foobar/foobar.js with fix for bazelbuild/rules_nodejs#802

also updates to rules_rass commit compatible with rules_nodejs 0.32.0

PR Close #31019
2019-06-25 10:21:07 -07:00
Greg Magolan 28d3bfc416 build(bazel): update to bazel 0.27.0 and fix compat in @angular/bazel package (#31019)
ctx.actions.declare_file now used in @angular/bazel ng_module rule as ctx.new_file is now deprecated. Fixes error:

```
        File "ng_module.bzl", line 272, in _expected_outs
                ctx.new_file(ctx.genfiles_dir, (ctx.label.name ..."))
Use ctx.actions.declare_file instead of ctx.new_file.
Use --incompatible_new_actions_api=false to temporarily disable this check.
```

This can be worked around with incompatible_new_actions_api flag but may as well fix it proper so downstream doesn't require this flag due to this code.

Also, depset() is no longer iterable by default without a flag. This required fixing in a few spots in @angular/bazel.

fix: foo

PR Close #31019
2019-06-25 10:21:06 -07:00
Alan Agius 16717fa12c fix(bazel): exclude all angular schematics folders from metadata build (#31237)
Fixes #31235

PR Close #31237
2019-06-24 18:48:44 -07:00
Alan Agius e83667ad76 fix(bazel): remove unsupported Css pre-processors from ng new (#31234)
Under Bazel, we don't yet support Stylus and Less, and thus we should not offer the users to generate applications which are known not to work.

Closes #31209

PR Close #31234
2019-06-24 14:57:06 -07:00
Alan Agius 805fc8698c fix(bazel): update ng new schema to match the current ng new schema of @schematics/angular (#31234)
The schema used in ng-new bazel, includes several outdated options. With this update we match the current version of @schematics/angular: https://github.com/angular/angular-cli/blob/master/packages/schematics/angular/ng-new/schema.json

Relates to #31233

PR Close #31234
2019-06-24 14:57:06 -07:00