master
Commits on Apr 22, 2022
-
fix(bazel): add this_is_bazel marker (#45728)
Add marker for noting that this check confirms we are running in a bazel environment. PR Close #45728
-
feat(router): Allow
loadChildrento return aRoutearray (#45700)This commit expands the `LoadChildrenCallback` to accept returning `Routes` in addition to the existing `NgModule` type. In addition, it adds a check to ensure these loaded routes all use standalone components. The components must be standalone because if they were not, we would not have the required `NgModule` which the component is declared in. Existing API: ``` {path: 'lazy/route', loadChildren: import('./lazy').then(m => m.LazyModule)} @NgModule({ imports: [ ExtraCmpModule, RouterModule.forChild([ {path: 'extra/route', component: ExtraCmp}, ]), ], }) export class LazyModule {} ``` The new API for lazy loading route configs with standalone components (no NgModule) is to expand `loadChildren` to allow returning simply a `Routes` array. ``` // parent.ts { path: 'parent', loadChildren: () => import('./children').then(m => m.ROUTES), } // children.ts export const ROUTES: Route[] = [ {path: 'child', component: ChildCmp}, ]; ``` Note that this includes minimal documentation updates. We need to include a holistic update to the documentation for standalone components in the future that includes this feature. PR Close #45700 -
test(core): add integration test apps for the
bootstrapApplication… -
feat(core): add the
bootstrapApplicationfunction (#45674)This commit implements the `bootstrapApplication` function that allows bootstrapping an application and pass a standalone component as a root component. PR Close #45674
Commits on Apr 21, 2022
-
test: update size golden for hello-world-ivy-compat integration test (#…
…45405) The main bundle fell below the 500b threshold. Likely because the global constant was fixed and is now tree-shakeable. The actual diff in the commit is a little confusing since it makes it seem that polyfills increased as part of this commit. This is not the case but just a side-effect of us accumulating various changes which are not reflected on a per-commit basis in the size golden. The actual sizes in master were: ``` SUCCESS: Commit undefined uncompressed runtime did NOT cross size threshold of 500 bytes or >1% (expected: 1105, actual: 1102). SUCCESS: Commit undefined uncompressed polyfills did NOT cross size threshold of 500 bytes or >1% (expected: 33846, actual: 33957). SUCCESS: Commit undefined uncompressed main did NOT cross size threshold of 500 bytes or >1% (expected: 132392, actual: 131893). ``` Now with this change: ``` SUCCESS: Commit undefined uncompressed runtime did NOT cross size threshold of 500 bytes or >1% (expected: 1105, actual: 1102). SUCCESS: Commit undefined uncompressed polyfills did NOT cross size threshold of 500 bytes or >1% (expected: 33846, actual: 33957). FAIL: Commit undefined uncompressed main fell below expected size by 500 bytes or >1% (expected: 132392, actual: 131883). ``` PR Close #45405
-
build: update systemjs aio boilerplate to work with APF v13+ `exports…
…` field (#45405) The SystemJS examples were using an outdated version of rollup that did not support export fields. Now with the recent changes where we removed secondary package.json files, the rather old/somewhat outdated SystemJS examples failed bundling since exports were not considered. PR Close #45405
-
fix(localize): ensure transitively loaded compiler code is tree-shaka…
…ble (#45405) The localize primary entry-point (used at runtime in application code) indirectly loads from the compiler package for computing message ids. The compiler package has a couple of constants which cannot be DCE-ded/ tree-shaken due to side-effect reliance that is detected by Terser. We fix these constants to be three-shakable. Note that another issue technically would be that the compiler package has a side-effect call for `publishFacade` (for JIT), but that invocation is marked as pure by the Angular CLI babel optimization pipeline. So this results is no unused code currently but is risky and should be addressed in the future. PR Close #45405
-
refactor(localize): init APF entry-point should not duplicate code (#…
…45405) This commit addresses two issues: * The init entry-point currenly access code from another entry-point using relative imports, resulting in code to be duplicated. * The init types are now bundled as part of the ng_package APF rule. There is an API extractor bundling issue with global module augmentations. API extractor does not properly handle module augmentation. We need to disable dts bundling for this entry-point to ensure `$localize` remains globally accessible for users. This is an option in the `ng_package` rule. Note that this worked before because `localize/init` was a `ts_library` that did not have its types bundled. As part of this change, the `MessageId` and `TargetMessage` exports are also made public. The localize exported functions rely on these types but they were not exported. Related to types, an exception is added for three private exports from the primary entry-point so that they will show up in the API golden. These private exports are re-exposed publicly in the init entry-point but no golden would capture them due to the private symbol prefix. One might wonder why the symbols are not guarded in the init golden. The reason is that goldens never inline signatures from cross-entry-points/packages to avoid duplication. Lastly, the i18n integration test golden had to be updated because the polyfills bundle increased slightly. After thorough and time-consuming investigation, this mostly happens due to different mangle identifies being used (the input code changed --> so the mangling determinism) Size before this change: ``` SUCCESS: Commit undefined uncompressed runtime did NOT cross size threshold of 500 bytes or >1% (expected: 929, actual: 926). SUCCESS: Commit undefined uncompressed main did NOT cross size threshold of 500 bytes or >1% (expected: 124544, actual: 124660). SUCCESS: Commit undefined uncompressed polyfills did NOT cross size threshold of 500 bytes or >1% (expected: 34530, actual: 34641). ``` After: ``` SUCCESS: Commit undefined uncompressed runtime did NOT cross size threshold of 500 bytes or >1% (expected: 929, actual: 926). SUCCESS: Commit undefined uncompressed main did NOT cross size threshold of 500 bytes or >1% (expected: 124544, actual: 124650). FAIL: Commit undefined uncompressed polyfills exceeded expected size by 500 bytes or >1% (expected: 34530, actual: 35252). ``` Inspecting/comparing without mangling shows that the new changes would actually result in a bundle reduction (potentially visible with gzip/brotli): ``` ➜ Desktop stat -f%z master-nomangle.js 101357 ➜ Desktop stat -f%z with-changes-nomangle.js 101226 ``` PR Close #45405
-
refactor: fix duplication in platform-server NPM package (#45405)
The platform-server init entry-point imported code from another entry-point using a relative import. This resulted in the code to be bundled into the `init` entry-point as well. This has no breaking impact but resulted in a little code duplication that we should clean up. PR Close #45405
-
test: add test for new
types_bundlerule from Angular bazel package (……#45405) Adds a little golden test for the new `types_bundle` rule that ensures the rule works at a general level. This rule will be useful for non-APF ESM packages like the Angular compiler-cli (for which we also want to bundle types to make them compatible with TypeScripts ESM type resolution) PR Close #45405
-
feat(bazel): speed up dev-turnaround by bundling types only when pack…
…aging (#45405) Speeds up the dev-turnaround by only bundling types when packaging. Currently bundling occurs for all the `ng_module` targets in devmode. This has various positive benefits: * Avoidance of this rather slower operation in development * Makes APF-built packages also handle types for `ts_library` targets consistently. * Allows us to ensure APF entry-points have `d.ts` _always_ bundled (working with ESM module resolution in TypeScript -- currently experimental) * Allows us to remove the secondary `package.json` files from APF (maybe APF v14? - seems low-impact). This would clean-up the APF even more and fix resolution issues (like in Vite) PR Close #45405
-
fix(docs-infra): fix placement of "Edit source" button on errors and …
…diagnostics pages (#45634) This commit aligns the layout of errors and extended diagnostics pages more closely with other docs pages to ensure that the "Edit source" button is displayed correctly even when the heading is too long to fit on a single line. For error pages, in particular, this ensures that the button is not obscured by the error video. **Before:** ![error-pages before][1] **After:** ![error-pages after][2] [1]: https://user-images.githubusercontent.com/8604205/163408291-7aebd029-891c-4045-8fa2-a8e2b2b06dab.png [2]: https://user-images.githubusercontent.com/8604205/163408296-40e6df8e-aadc-4a82-978a-ab4d902b6f6e.png PR Close #45634
-
fix(docs-infra): include
tslibinto SystemJS config in `upgrade-mod……ule` example app (#45706) This commit updates the SystemJS for one of the example apps (the `upgrade-module` one) to include a resolution rule for the `tslib`. This is needed in case `tslib` is referenced from the framework code (for example in case of downleveling of some operators). This makes it consistent with other example app configs. PR Close #45706
Commits on Apr 20, 2022
-
docs(core): add API documentation to standalone-related classes (#45687)
This commit adds some internal documentation. PR Close #45687
-
test(core): add more tests for the standalone injector (#45687)
This commit reorganizes the tests around the EnvironmentInjector and its use for standalone injectors, and adds a number of new test cases. PR Close #45687
-
refactor(core): implement standalone injectors (#45687)
This commit implements the `StandaloneFeature` which provides for the creation of standalone injectors, for those components which need them. The feature-based implementation ensures the machinery for standalone injectors is properly tree-shakable. PR Close #45687
-
refactor(core): support standalone components in importProvidersFrom (#…
-
feat(core): implement standalone directives, components, and pipes (#…
…45687) This commit exposes the `standalone` flag on `@Directive`, `@Component`, and `@Pipe`, effectively making standalone components a part of Angular's public API. As part of this operation, it also implements JIT compilation for standalone types. Standalone types are Angular-decorated types which act as their own "declarations", where they would otherwise be declared in an NgModule. Marking an Angular type as standalone means that it can be used directly in other standalone components and in NgModules, without needing an associated NgModule to depend on it. In the case of a standalone component, template dependencies which would otherwise be specified by an NgModule are instead specified directly on the component itself, via the `imports` field. Other standalone types can be imported, as well as NgModules. PR Close #45687
-
refactor(compiler-cli): reorganize importProvidersFrom to avoid cycles (
#45687) This commit extracts the `importProvidersFrom` function and associated machinery into a separate file, as opposed to being colocated with `R3Injector`. Separating these functions will mitigate potential future circular dependencies as `importProvidersFrom` starts being used in different parts of the codebase. PR Close #45687
-
feat(router): add ariaCurrentWhenActive input to RouterLinkActive dir…
-
refactor(router): deprecate no longer needed resolver fields (#45597)
DEPRECATED: The `resolver` argument of the `RouterOutletContract.activateWith` function and the `resolver` field of the `OutletContext` class are deprecated. Passing component factory resolvers are no longer needed. The `ComponentFactoryResolver`-related symbols were deprecated in `@angular/core` package since v13. PR Close #45597
-
feat(router): Add
EnvironmentInjectortoRouterOutlet.activateWith(#45597) The current API for `activateWith` uses the deprecated `ComponentFactoryResolver`. The replacement for this is to use `EnvironmentInjector`. That is, instead of ``` const factory = componentFactoryResolver.resolveComponentFactory(component); location.createComponent(factory, location.length, injector); ``` the replacement would be ``` location.createComponent( component, {index: location.length, injector, environmentInjector}); ``` PR Close #45597
-
feat(router): Add ability to specify providers on a Route (#45673)
Currently, the only way to specify new providers for a `Route` and the children is to create a new `NgModule` with those providers and use the `loadChildren` feature. This is pretty confusing and a wholly indirect way of accomplishing this task. With this commit, developers will be able to specify a list of providers directly on the `Route` itself. These providers will apply the that route and its children. This feature was inspired by the upcoming standalone components feature. This ties in there because, as mentioned before, the prior art for lazy loading configs was to load an `NgModule`. This loaded module contained new route configs _and_ could specify new providers. Separating those two concepts, there should be a way to load _just_ some new routes, but there should also be a way to specify new providers as well (something you could do in the `NgModule` world and now will be able to do in the world without any `NgModule` through this feature). PR Close #45673
-
-
fix(forms): Fix a typing bug in FormBuilder. (#45684)
Previously, the following code would fail to compile: ``` let form: FormGroup<{email: FormControl<string | null>}>; form = fb.group({ email: ['', Validators.required] }); ``` This is because the compiler was unable to properly infer the inner type of `ControlConfig` arrays in some cases. The same issue applies to `FormArray` as well under certain circumstances. This change cleans up the `FormBuilder` type signatures to always use the explicit Element type, and to catch `ControlConfig` types that might fall through. PR Close #45684 -
fix(docs-infra): avoid internal symbols from being referenced during …
-
test(http): Add + to encoding test (#45111)
Changes the existing test for query parameter encoding to include the + symbol and its expected encoding to %2B. PR Close #45111
-
fix(http): encode + signs in query params as %2B (#11058) (#45111)
Servers always decode + as a space, which is undesirable when one actually wants to query for a plus. BREAKING CHANGE: Queries including + will now actually query for + instead of space. Most workarounds involving custom codecs will be unaffected. Possible server-side workarounds will need to be undone. Fixes #11058 PR Close #45111
-
test(compiler-cli): tests for standalone components/directives/pipes (#…
-
refactor(compiler-cli): propagate standalone flag in .d.ts metadata (#…
…45672) This commit adds a type field to .d.ts metadata for directives, components, and pipes which carries a boolean literal indicating whether the given type is standalone or not. For backwards compatibility, this flag defaults to `false`. Tests are added to validate that standalone types coming from .d.ts files can be correctly imported into new standalone components. PR Close #45672
-
test: set skipLibCheck on ngcc integration test (#45672)
The ngcc integration test is in an awkward state: it's attempting to test that the current ngcc can process @angular/core at v12. We need to make a forwards-incompatible change to the typings of @angular/core, which means that the compiled typings from the current ngcc won't be compatible with core as of v12. To get around this and allow the integration test to have some value, we're disabling library checking for the time being. PR Close #45672
-
refactor(compiler-cli): emit isStandalone flag in partial declarations (
-
refactor(compiler-cli): move standalone scope computation out of hand…
…ler (#45672) Standalone component scopes were first implemented in the `ComponentDecoratorHandler` itself, due to an assumption that "standalone" allowed for a localized analysis of the component's dependencies. However, this is not strictly true. Other compiler machinery also needs to understand component scopes, including standalone component scopes. A good example is the template type-checking engine, which uses a `ComponentScopeReader` to build full metadata objects (that is, metadata that considers the entire inheritance chain) for type-checking purposes. Therefore, the `ComponentScopeReader` should be able to give the scope for a standalone component. To achieve this, a new `StandaloneComponentScopeReader` is implemented, and the return type of `ComponentScopeReader.getScopeForComponent` is expanded to express standalone scopes. This cleanly integrates the "standalone" concept into the existing machinery. PR Close #45672