Description
Is this a regression?
- Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
18.0.6
Description
Since version 18.1.0, a change got introduced in drag-ref.ts which checks the ngDevMode
without taking into account that it could be undefined.
In such cases (when ngDevMode
is undefined) this results in an error:
ReferenceError: ngDevMode is not defined
at DragRef._startDragSequence (drag-drop.mjs:957:82)
It got introduced with version 18.1.0 by feat(cdk/drag-drop): add mixed orientation support
After some investigation, I noticed that in other places within the angular codebase, we always make sure that the code is able to deal with that.
e.g.
if ("undefined" !== typeof ngDevMode && ngDevMode) { ... }
So even though this should only happen for some more exotic use-cases, it looks to me like it is known to the Angular team that this can occur (ngDevMode being undefined) and it should be taken into account.
(I also found this commit which seems to confirm it)
Reproduction
StackBlitz link: https://stackblitz.com/edit/ddzadm?file=angular.json
Steps to reproduce:
- Try dragging one of the items in the list
- Observe: drag does not work + error in JS console
NOTE:
To set up this repro case on StackBlitz, I have "externalized" the Angular packages by listing them as externalDependencies
in the angular.json file, and added an importmap in index.html to resolve the packages at runtime (using @esm-bundle/angular - see Joel Denning's blog post for more info about this).
I fully realize that this an exotic setup, but it simulates the situation where multiple Angular micro-frontends are "sharing" the same angular packages.
Expected Behavior
No error, ngDevMode
should be assumed falsy
when it's undefined.
Actual Behavior
ReferenceError: ngDevMode is not defined
at DragRef._startDragSequence (drag-drop.mjs:957:82)
Environment
Angular CLI: 18.2.1
Node: 20.12.2
Package Manager: pnpm 9.7.1
OS: win32 x64
Angular: 18.2.1
... animations, build, cdk, cli, common, compiler, compiler-cli
... core, forms, language-service, material, platform-browser
... platform-browser-dynamic, router
Package Version
@angular-devkit/architect 0.1802.0
@angular-devkit/build-angular 18.2.1
@angular-devkit/core 18.2.1
@angular-devkit/schematics 18.2.1
@schematics/angular 18.2.1
rxjs 7.8.1
typescript 5.5.4
webpack 5.91.0
zone.js 0.14.10