Skip to content
Permalink
master

Commits on Apr 22, 2022

  1. 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
    josephperrott authored and atscott committed Apr 22, 2022
  2. feat(router): Allow loadChildren to return a Route array (#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
    atscott committed Apr 22, 2022
  3. test(core): add integration test apps for the bootstrapApplication

    …API (#45674)
    
    This commit adds 2 integration apps to verify the `bootstrapApplication` API behavior as well as keep track of the bundle size and retained symbols (tree-shaking).
    
    PR Close #45674
    AndrewKushnir authored and atscott committed Apr 22, 2022
  4. feat(core): add the bootstrapApplication function (#45674)

    This commit implements the `bootstrapApplication` function that allows bootstrapping an application and pass a standalone component as a root component.
    
    PR Close #45674
    AndrewKushnir authored and atscott committed Apr 22, 2022

Commits on Apr 21, 2022

  1. 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
    devversion authored and atscott committed Apr 21, 2022
  2. 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
    devversion authored and atscott committed Apr 21, 2022
  3. 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
    devversion authored and atscott committed Apr 21, 2022
  4. 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
    devversion authored and atscott committed Apr 21, 2022
  5. 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
    devversion authored and atscott committed Apr 21, 2022
  6. test: add test for new types_bundle rule 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
    devversion authored and atscott committed Apr 21, 2022
  7. 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
    devversion authored and atscott committed Apr 21, 2022
  8. 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
    gkalpak authored and atscott committed Apr 21, 2022
  9. fix(docs-infra): include tslib into 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
    AndrewKushnir authored and atscott committed Apr 21, 2022

Commits on Apr 20, 2022

  1. docs(core): add API documentation to standalone-related classes (#45687)

    This commit adds some internal documentation.
    
    PR Close #45687
    pkozlowski-opensource authored and atscott committed Apr 20, 2022
  2. 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
    pkozlowski-opensource authored and atscott committed Apr 20, 2022
  3. 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
    pkozlowski-opensource authored and atscott committed Apr 20, 2022
  4. refactor(core): support standalone components in importProvidersFrom (#…

    …45687)
    
    This commit refactors `importProvidersFrom` to support pulling providers
    from the dependencies of a standalone component, in addition to NgModules.
    Tests will be added in a future commit when standalone components can be
    created without calling private APIs.
    
    PR Close #45687
    alxhub authored and atscott committed Apr 20, 2022
  5. 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
    alxhub authored and atscott committed Apr 20, 2022
  6. 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
    alxhub authored and atscott committed Apr 20, 2022
  7. feat(router): add ariaCurrentWhenActive input to RouterLinkActive dir…

    …ective (#45167)
    
    add the ariaCurrentWhenActive input to the RouterLinkActive directive so that
    users can easily set the aria-current property to their active router
    links
    
    resolves #35051
    
    PR Close #45167
    dario-piotrowicz authored and atscott committed Apr 20, 2022
  8. 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
    atscott authored and dylhunn committed Apr 20, 2022
  9. feat(router): Add EnvironmentInjector to RouterOutlet.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
    atscott authored and dylhunn committed Apr 20, 2022
  10. 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
    atscott authored and dylhunn committed Apr 20, 2022
  11. ci: update payload size golden file (#45699)

    This commit updates the payload size for the Forms-related test app.
    The CI started to fail after merging ff3f5a8. The payload size increase is most likely accumulated.
    
    PR Close #45699
    AndrewKushnir authored and dylhunn committed Apr 20, 2022
  12. 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
    dylhunn committed Apr 20, 2022
  13. fix(docs-infra): avoid internal symbols from being referenced during …

    …auto-linking (#45689)
    
    This commit adds extra logic to avoid internal and privately exported symbols from being referenced during auto-linking. Currently such symbols can be used for linking, thus resulting in a non-existing link and causing the linking process to fail.
    
    PR Close #45689
    AndrewKushnir authored and dylhunn committed Apr 20, 2022
  14. 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
    Clashsoft authored and dylhunn committed Apr 20, 2022
  15. 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
    Clashsoft authored and dylhunn committed Apr 20, 2022
  16. test(compiler-cli): tests for standalone components/directives/pipes (#…

    …45672)
    
    This commit bundles tests for standalone components that are possible after
    previous implementation commits. Most new tests are compliance tests, but
    a test is also included to validate that the template type-checking system
    can work with standalone components as well.
    
    PR Close #45672
    alxhub committed Apr 20, 2022
  17. 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
    alxhub committed Apr 20, 2022
  18. 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
    alxhub committed Apr 20, 2022
  19. refactor(compiler-cli): emit isStandalone flag in partial declarations (

    #45672)
    
    This commit propagates the `isStandalone` flag for a component, directive,
    or pipe during partial compilation of a standalone declaration. This flag
    allows the linker to properly process a standalone declaration that it
    encounters.
    
    PR Close #45672
    alxhub committed Apr 20, 2022
  20. 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
    alxhub committed Apr 20, 2022
Older