Repository: angular
Issue: Code imported inside a lazy-loading module is executed inside the angular zone
Labels: area: zones,P3

### Which @angular/* package(s) are the source of the bug?

router

### Is this a regression?

No

### Description

I am using a lazy loaded modules and imported an external library (Quill: https://quilljs.com/) into one of the components of the module.
When trying to subscribe an event of the library outside the zone with `NgZone.runOutsideAngular()` and testing it, I saw that the event was still running inside the zone. I checked with `NgZone.isInAngularZone()`.

When trying to figure out why this happens, I noticed that inside lazy loaded modules, ALL loaded code is executed inside the zone. This does not happen outside of lazy loaded modules and can lead to various side effects. If a library would for example subscribe to a mousemove event just by being loaded, it would lead to serious performance issues.

Example:

Some library that is used from node_modules might have code similar to this:
```typescript
import { NgZone } from '@angular/core';

class SomeLib {
  bodyClickedHandler: () => void;
  constructor() {
     console.log("SomeLib constructed in zone", NgZone.isInAngularZone()); // true if lazy loaded, false if not
     document.body.addEventListener("click", () => { 
        console.log("click", NgZone.isInAngularZone()); // true if lazy loaded, false if not
        if (this.bodyClickedHandler) this.bodyClickedHandler();
     });
  }
  onBodyClicked(handler: () => void) {
     this.bodyClickedHandler = handler;
  }
}
export const someLib = new SomeLib();
```
Then it is used in a component:
```typescript
import someLib from 'somelib';

@Component(...)
export class TestComponent {
  constructor(private zone: NgZone) {
    this.zone.runOutsideAngular(() => { // this actually has no effect at all because of how the library is written, lazy or not
      someLib.onBodyClicked(() =>
        console.log('clicked in zone', NgZone.isInAngularZone()) // true if lazy loaded, false if not
      );
    });
  }
}

// same for static code
console.log("TestComponent loaded in zone", NgZone.isInAngularZone());  // true if lazy loaded, false if not
```

The module is loaded like this:
```typescript
const routes: Routes = [{
    path: '',
    loadChildren: () => import('./lazy/lazy.module').then(m => m.LazyModule)
}];
....
```


In the example all `NgZone.isInAngularZone()` will log `false` in a normal module and `true` in a lazy loaded one.
The `NgZone.isInAngularZone()` inside the component would be `false` in a normal module even without `runOutsideAngular` because of how the library is written (the event is already subscribed in static code). That is expected and it can easily be put inside the zone with `zone.run()`. In a lazy loaded module it is impossible to get the callback out of the zone (afaik).

The only workaround that I know of is to not lazy load the library. If I import it already in a normal module (e.g. app.module) it will not be loaded again and stays outside zone.

See the Stackblitz for working code to try it.

Expected behavior: Loaded code, that is executed as part of an import (static code) which is not part of angular, should not be executed inside the angular zone. The same way it is with non lazy module.


### Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/angular-ivy-fwzcwh?file=src/app/lazy-module/lazy-cmp.component.ts

### Please provide the exception or error you saw

_No response_

### Please provide the environment you discovered this bug in

```true
Angular CLI: 11.2.9
Node: 14.16.0
Package Manager: npm 6.14.11
OS: Win 10
Angular: 11.2.10  (Stackblitz is 12.1.0, same issue)
TypeScript: 4.1.5
```


### Anything else?

_No response_