-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Closed
Labels
Description
Command
run
Is this a regression?
- Yes, this behavior used to work in the previous versionTo pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
The previous version in which this bug was not present was
19
Description
It seems that regular defer triggers are being prefetched despite not having prefetch on
or prefetch when
trigger. This was reported by one of our GDEs. This did work in past versions of Angular. So something must have changed with how these files are being bundled and inlined.
Minimal Reproduction
Minimal repro: https://stackblitz.com/~/github.com/AhsanAyaz/ng-defer-bundle-preload-example?file=src/app/app.html:L338
While running, you can view the SSR page source and see the files listed as modulepreload
.
Exception or Error
Your Environment
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 20.0.2
Node: 20.19.1
Package Manager: npm 10.8.2
OS: linux x64
Angular: 20.0.3
... common, compiler, compiler-cli, core, forms
... platform-browser, platform-server, router
Package Version
------------------------------------------------------
@angular-devkit/architect 0.2000.2
@angular-devkit/core 20.0.2
@angular-devkit/schematics 20.0.2
@angular/build 20.0.2
@angular/cli 20.0.2
@angular/ssr 20.0.2
@schematics/angular 20.0.2
rxjs 7.8.2
typescript 5.8.3
zone.js 0.15.1
Anything else relevant?
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
alan-agius4 commentedon Jun 16, 2025
Preloading occurs when the visited route includes a lazy-loaded bundles, this feature was added in 19.1.0.
In this case, since there's a timer involved, we probably shouldn’t trigger preloading but the bundler lacks the contextual awareness. One possible solution is to enhance the Angular compiler to insert specific instructions into
import
statements: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import/with](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import/withUltimately, this would require compiler-level changes to annotate certain
import
calls with alternative behavior. Alternatively, we could simply avoid adding preloads for modules that aren't explicitly defined in the router configuration. However, this approach would prevent all deferred blocks from being preloaded, which may not be desirable.AhsanAyaz commentedon Jun 16, 2025
As per the current documentation of the defer blocks, especially about
prefetch
, the alternative approach makes more sense to not preload deferred blocks untilprefetch
is specified. I can see how it can make it really confusing for developers to understand what@defer
really does. I.e. does it download the javascript bundle on theon
andwhen
triggers? Or only render the component/load in the component tree when the triggers happen?I think not preloading the deferred blocks makes much more sense. If someone wants to preload, they can use the
prefetch
keyword with their deferred blocks.The documentation also doesn't mention that the default behavior is
prefetch on idle
.fix(@angular/ssr): avoid preloading unnecessary dynamic bundles
fix(@angular/ssr): avoid preloading unnecessary dynamic bundles
fix(@angular/ssr): avoid preloading unnecessary dynamic bundles
angular-automatic-lock-bot commentedon Jul 24, 2025
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.