refactor(core): make deps tracker globally available#51495
refactor(core): make deps tracker globally available#51495pmvald wants to merge 1 commit intoangular:mainfrom
Conversation
In some cases (e.g., aio tests) the file `dept_tracker.ts` might be loaded into browser multiple times (possibly due to presence in different chunks) and this leads to multiple copies of the deps tracker. But the dept tracker should be singleton. So we use `global` to achieve this.
|
Sorry for the noise if I'm wrong, but in #50063, some usages of |
@Yogu This is fine here, the |
|
This has the potential of introducing issues for environments with multiple copies of Angular on a page, e.g. self-contained Angular elements. |
|
@JoostK Good point! Do we have a test for this type of environments? I didn't see any, but it is nice to have as there are some usages of For this particular case I'm optimistic it may not cause issues since deps tracker uses the class as key to store Types and their info, and since classes from different environments are different there might not be a conflict ... in other words one depsTracker for all environments might work. But we can try it out and even add some tests for that if possible. |
|
I don't know of any such scenarios being covered by tests. My main concern is how the code of the deps tracker itself might be different across versions, possibly resulting in failures. I doubt that multiple copies/versions of I would like to understand how this module may end up being loaded twice unintentionally to better judge the changes in this PR, i.e. is this a "root cause" fix, or a workaround for an unknown cause. |
|
The actual bug is that we are importing using relative imports from other entry-points. The bundler will then duplicate the code, even though it should actually be imported from e.g. We never ended up needing it here, but I've started work to build this into |
|
Nice! Close in favour of #51500 |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
In some cases (e.g., aio tests) the file
dept_tracker.tsmight be loaded into browser multiple times (possibly due to presence in different chunks) and this leads to multiple copies of the deps tracker. But the dept tracker should be singleton. So we useglobalto achieve this.This will effectively fix the local aio breakage in #51415
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information