@@ -341,55 +341,6 @@ class Application extends Engine {
341341 */
342342 declare autoboot : boolean ;
343343
344- /**
345- Whether the application should be configured for the legacy "globals mode".
346- Under this mode, the Application object serves as a global namespace for all
347- classes.
348-
349- ```javascript
350- import Application from '@ember/application';
351- import Component from '@ember/component';
352-
353- let App = Application.create({
354- ...
355- });
356-
357- App.Router.reopen({
358- location: 'none'
359- });
360-
361- App.Router.map({
362- ...
363- });
364-
365- App.MyComponent = Component.extend({
366- ...
367- });
368- ```
369-
370- This flag also exposes other internal APIs that assumes the existence of
371- a special "default instance", like `App.__container__.lookup(...)`.
372-
373- This option is currently not configurable, its value is derived from
374- the `autoboot` flag – disabling `autoboot` also implies opting-out of
375- globals mode support, although they are ultimately orthogonal concerns.
376-
377- Some of the global modes features are already deprecated in 1.x. The
378- existence of this flag is to untangle the globals mode code paths from
379- the autoboot code paths, so that these legacy features can be reviewed
380- for deprecation/removal separately.
381-
382- Forcing the (autoboot=true, _globalsMode=false) here and running the tests
383- would reveal all the places where we are still relying on these legacy
384- behavior internally (mostly just tests).
385-
386- @property _globalsMode
387- @type Boolean
388- @default true
389- @private
390- */
391- declare _globalsMode : boolean ;
392-
393344 /**
394345 An array of application instances created by `buildInstance()`. Used
395346 internally to ensure that all instances get destroyed.
@@ -413,7 +364,6 @@ class Application extends Engine {
413364 this . customEvents ??= null ;
414365 this . autoboot ??= true ;
415366 this . _document ??= hasDOM ? window . document : null ;
416- this . _globalsMode ??= true ;
417367
418368 if ( DEBUG ) {
419369 if ( ENV . LOG_VERSION ) {
@@ -429,13 +379,15 @@ class Application extends Engine {
429379 this . _booted = false ;
430380 this . _applicationInstances = new Set ( ) ;
431381
432- this . autoboot = this . _globalsMode = Boolean ( this . autoboot ) ;
433-
434- if ( this . _globalsMode ) {
435- this . _prepareForGlobalsMode ( ) ;
436- }
382+ this . autoboot = Boolean ( this . autoboot ) ;
437383
438384 if ( this . autoboot ) {
385+ // Create subclass of Router for this Application instance.
386+ // This is to ensure that someone reopening `App.Router` does not
387+ // tamper with the default `Router`.
388+ this . Router = ( this . Router || Router ) . extend ( ) as typeof Router ;
389+
390+ this . _buildDeprecatedInstance ( ) ;
439391 this . waitForDOMReady ( ) ;
440392 }
441393 }
@@ -489,26 +441,6 @@ class Application extends Engine {
489441
490442 Router ?: typeof Router ;
491443
492- /**
493- Enable the legacy globals mode by allowing this application to act
494- as a global namespace. See the docs on the `_globalsMode` property
495- for details.
496-
497- Most of these features are already deprecated in 1.x, so we can
498- stop using them internally and try to remove them.
499-
500- @private
501- @method _prepareForGlobalsMode
502- */
503- _prepareForGlobalsMode ( ) : void {
504- // Create subclass of Router for this Application instance.
505- // This is to ensure that someone reopening `App.Router` does not
506- // tamper with the default `Router`.
507- this . Router = ( this . Router || Router ) . extend ( ) as typeof Router ;
508-
509- this . _buildDeprecatedInstance ( ) ;
510- }
511-
512444 __deprecatedInstance__ ?: ApplicationInstance ;
513445 __container__ ?: Container ;
514446
@@ -590,7 +522,7 @@ class Application extends Engine {
590522 ```javascript
591523 _autoBoot() {
592524 this.boot().then(() => {
593- let instance = ( this._globalsMode) ? this. __deprecatedInstance__ : this.buildInstance() ;
525+ let instance = this.__deprecatedInstance__;
594526 return instance.boot();
595527 }).then((instance) => {
596528 App.ready();
@@ -872,10 +804,10 @@ class Application extends Engine {
872804
873805 assert (
874806 `Calling reset() on instances of \`Application\` is not
875- supported when globals mode is disabled; call \`visit()\` to
807+ supported when autoboot is disabled; call \`visit()\` to
876808 create new \`ApplicationInstance\`s and dispose them
877809 via their \`destroy()\` method instead.` ,
878- this . _globalsMode && this . autoboot
810+ this . autoboot
879811 ) ;
880812
881813 let instance = this . __deprecatedInstance__ ;
@@ -907,24 +839,12 @@ class Application extends Engine {
907839 assert ( 'expected _bootResolver' , this . _bootResolver ) ;
908840
909841 try {
910- // TODO: Is this still needed for _globalsMode = false?
911-
912842 // See documentation on `_autoboot()` for details
913843 if ( this . autoboot ) {
914- let instance ;
915-
916- if ( this . _globalsMode ) {
917- // If we already have the __deprecatedInstance__ lying around, boot it to
918- // avoid unnecessary work
919- instance = this . __deprecatedInstance__ ;
920- assert ( 'expected instance' , instance ) ;
921- } else {
922- // Otherwise, build an instance and boot it. This is currently unreachable,
923- // because we forced _globalsMode to === autoboot; but having this branch
924- // allows us to locally toggle that flag for weeding out legacy globals mode
925- // dependencies independently
926- instance = this . buildInstance ( ) ;
927- }
844+ // If we already have the __deprecatedInstance__ lying around, boot it to
845+ // avoid unnecessary work
846+ let instance = this . __deprecatedInstance__ ;
847+ assert ( 'expected instance' , instance ) ;
928848
929849 instance . _bootSync ( ) ;
930850
0 commit comments