Skip to content

Remove unneeded restriction around creating sub-applications #20910

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

NullVoxPopuli
Copy link
Contributor

@NullVoxPopuli NullVoxPopuli commented May 19, 2025

A path to unblocking:

While working new repl infra for https://limber.glimdown.com, I want to take a more "islands" approach, like https://astro.build -- it enables a ton of power -- however, there is an assertion that prevents using nested applications -- which kinda feels silly since we allow it via "engines".

Like with how we use modifiers and 3rd party libraries that manage DOM, whenever we use an element that has some external control of its descendents, we must make the same assumptions and allowances --- generally this is safe, as once we let 3rd party scripts manage their subtree, ember doesn't mess around in there (because when someone would instruct ember to mess around in someone else's subtree, that's when you run in to problems -- but this is easy enough to avoid).

In my use case, I have:

  • host ember app (could be any other app though, even react)
    • run through repl stuff
      • be given an element to put somewhere
        • render that element
          • in my case for https://limber.glimdown.com, the element is rendered via a component.
            so this component is mounting a whole new app, and nothing is is going to mess with the subtree.
            This works via using the new template() API for the runtime compiler:
            const element = await compiler.compile('gjs', code);
            
            component = template(`{{element}}`, { scope: () => ({ element }) });

Copy link

github-actions bot commented May 19, 2025

Development Assets

Diff

--- main/out.txt	2025-05-05 18:22:36.000000000 +0000
+++ pr/./pr-15116085569/out.txt	2025-05-19 14:46:34.000000000 +0000
@@ -1,10 +1,10 @@
  2.2M └─┬ .
-1015K   ├─┬ @ember
+1014K   ├─┬ @ember
  205K   │ ├─┬ -internals
-  69K   │ │ ├─┬ views
-  64K   │ │ │ └─┬ lib
+  68K   │ │ ├─┬ views
+  63K   │ │ │ └─┬ lib
   23K   │ │ │   ├── mixins
-  22K   │ │ │   ├── system
+  21K   │ │ │   ├── system
   10K   │ │ │   ├── views
  4.3K   │ │ │   └── compat
   35K   │ │ ├─┬ runtime

Details

This PRmain
Dev
 2.2M └─┬ .
1014K   ├─┬ @ember
 205K   │ ├─┬ -internals
  68K   │ │ ├─┬ views
  63K   │ │ │ └─┬ lib
  23K   │ │ │   ├── mixins
  21K   │ │ │   ├── system
  10K   │ │ │   ├── views
 4.3K   │ │ │   └── compat
  35K   │ │ ├─┬ runtime
  30K   │ │ │ └─┬ lib
  21K   │ │ │   ├── mixins
 5.7K   │ │ │   └── ext
  26K   │ │ ├─┬ meta
  21K   │ │ │ └── lib
  11K   │ │ ├── owner
 9.4K   │ │ ├── deprecations
 7.4K   │ │ ├── metal
 7.0K   │ │ ├── string
 5.1K   │ │ ├── glimmer
 4.9K   │ │ ├── utils
 4.9K   │ │ ├── routing
 4.5K   │ │ ├── error-handling
 4.5K   │ │ ├── utility-types
 4.2K   │ │ ├── container
 4.2K   │ │ ├── browser-environment
 4.1K   │ │ └── environment
 183K   │ ├─┬ routing
  28K   │ │ └── lib
 149K   │ ├─┬ object
  66K   │ │ └─┬ lib
  62K   │ │   └── computed
 114K   │ ├─┬ template-compiler
 109K   │ │ └─┬ lib
  20K   │ │   ├── plugins
 4.6K   │ │   ├── system
 4.1K   │ │   └── -internal
  66K   │ ├─┬ application
 5.6K   │ │ └── lib
  52K   │ ├─┬ debug
  21K   │ │ └── lib
  38K   │ ├─┬ array
 4.9K   │ │ └── lib
  31K   │ ├─┬ engine
 4.7K   │ │ └── lib
  27K   │ ├── runloop
  22K   │ ├─┬ utils
  18K   │ │ └── lib
  20K   │ ├── helper
  11K   │ ├── destroyable
 9.8K   │ ├── instrumentation
 9.4K   │ ├── controller
 7.4K   │ ├── service
 7.2K   │ ├── owner
 6.2K   │ ├── component
 5.6K   │ ├── canary-features
 5.5K   │ ├── modifier
 5.1K   │ ├── template-compilation
 5.0K   │ ├── enumerable
 5.0K   │ ├── test
 4.4K   │ ├── template
 4.4K   │ ├── renderer
 4.2K   │ ├── deprecated-features
 4.1K   │ ├── template-factory
 4.1K   │ └── version
 709K   ├── shared-chunks
 384K   ├─┬ @glimmer
 166K   │ ├── runtime
  60K   │ ├── opcode-compiler
  30K   │ ├── manager
  22K   │ ├── validator
  14K   │ ├── program
  12K   │ ├── reference
  11K   │ ├── destroyable
  10K   │ ├─┬ tracking
 4.4K   │ │ └── primitives
  10K   │ ├── util
 8.1K   │ ├── node
 7.3K   │ ├── global-context
 6.4K   │ ├── wire-format
 5.0K   │ ├── vm
 4.9K   │ ├── encoder
 4.6K   │ ├── owner
 4.1K   │ └── env
  60K   ├─┬ ember-testing
  56K   │ └─┬ lib
  14K   │   ├── test
  14K   │   ├── helpers
  10K   │   ├── ext
 6.5K   │   └── adapters
  31K   ├── backburner.js
  25K   ├── ember
  24K   ├── route-recognizer
  18K   ├─┬ @simple-dom
  14K   │ └── document
 9.2K   ├── dag-map
 4.3K   ├── rsvp
 4.3K   └── router_js
 2.2M └─┬ .
1015K   ├─┬ @ember
 205K   │ ├─┬ -internals
  69K   │ │ ├─┬ views
  64K   │ │ │ └─┬ lib
  23K   │ │ │   ├── mixins
  22K   │ │ │   ├── system
  10K   │ │ │   ├── views
 4.3K   │ │ │   └── compat
  35K   │ │ ├─┬ runtime
  30K   │ │ │ └─┬ lib
  21K   │ │ │   ├── mixins
 5.7K   │ │ │   └── ext
  26K   │ │ ├─┬ meta
  21K   │ │ │ └── lib
  11K   │ │ ├── owner
 9.4K   │ │ ├── deprecations
 7.4K   │ │ ├── metal
 7.0K   │ │ ├── string
 5.1K   │ │ ├── glimmer
 4.9K   │ │ ├── utils
 4.9K   │ │ ├── routing
 4.5K   │ │ ├── error-handling
 4.5K   │ │ ├── utility-types
 4.2K   │ │ ├── container
 4.2K   │ │ ├── browser-environment
 4.1K   │ │ └── environment
 183K   │ ├─┬ routing
  28K   │ │ └── lib
 149K   │ ├─┬ object
  66K   │ │ └─┬ lib
  62K   │ │   └── computed
 114K   │ ├─┬ template-compiler
 109K   │ │ └─┬ lib
  20K   │ │   ├── plugins
 4.6K   │ │   ├── system
 4.1K   │ │   └── -internal
  66K   │ ├─┬ application
 5.6K   │ │ └── lib
  52K   │ ├─┬ debug
  21K   │ │ └── lib
  38K   │ ├─┬ array
 4.9K   │ │ └── lib
  31K   │ ├─┬ engine
 4.7K   │ │ └── lib
  27K   │ ├── runloop
  22K   │ ├─┬ utils
  18K   │ │ └── lib
  20K   │ ├── helper
  11K   │ ├── destroyable
 9.8K   │ ├── instrumentation
 9.4K   │ ├── controller
 7.4K   │ ├── service
 7.2K   │ ├── owner
 6.2K   │ ├── component
 5.6K   │ ├── canary-features
 5.5K   │ ├── modifier
 5.1K   │ ├── template-compilation
 5.0K   │ ├── enumerable
 5.0K   │ ├── test
 4.4K   │ ├── template
 4.4K   │ ├── renderer
 4.2K   │ ├── deprecated-features
 4.1K   │ ├── template-factory
 4.1K   │ └── version
 709K   ├── shared-chunks
 384K   ├─┬ @glimmer
 166K   │ ├── runtime
  60K   │ ├── opcode-compiler
  30K   │ ├── manager
  22K   │ ├── validator
  14K   │ ├── program
  12K   │ ├── reference
  11K   │ ├── destroyable
  10K   │ ├─┬ tracking
 4.4K   │ │ └── primitives
  10K   │ ├── util
 8.1K   │ ├── node
 7.3K   │ ├── global-context
 6.4K   │ ├── wire-format
 5.0K   │ ├── vm
 4.9K   │ ├── encoder
 4.6K   │ ├── owner
 4.1K   │ └── env
  60K   ├─┬ ember-testing
  56K   │ └─┬ lib
  14K   │   ├── test
  14K   │   ├── helpers
  10K   │   ├── ext
 6.5K   │   └── adapters
  31K   ├── backburner.js
  25K   ├── ember
  24K   ├── route-recognizer
  18K   ├─┬ @simple-dom
  14K   │ └── document
 9.2K   ├── dag-map
 4.3K   ├── rsvp
 4.3K   └── router_js

@NullVoxPopuli
Copy link
Contributor Author

From two Chrises:

  • global event dispatcher may get in the way here

@NullVoxPopuli
Copy link
Contributor Author

Related: emberjs/rfcs#1102

If we block this PR on the removal of the global event dispatcher, then this can't land until v7 at the latest.

I'm not sure we need to do that though, because it's a "protection", if anything

@kategengler
Copy link
Member

I think it is fine to merge this so long as you can confirm nested apps work as expected. Is the EventDispatcher still used for events on Input and TextArea etc?

Also that RFC should be a deprecation RFC

@NullVoxPopuli
Copy link
Contributor Author

Also that RFC should be a deprecation RFC

I copied the deprecation template 🙈

@kategengler
Copy link
Member

Also that RFC should be a deprecation RFC

I copied the deprecation template 🙈

Sorry about that -- it looked different to me

@ef4
Copy link
Contributor

ef4 commented May 19, 2025

The global event dispatcher was also the thing I was referring to when I said maybe we don't need the assertion anymore. I didn't remember that we still have it.

@kategengler
Copy link
Member

@ef4 Could we solve this for now by changing the assert to a warn that mentions the remaining things that may need the global event dispatcher?

@ef4
Copy link
Contributor

ef4 commented Jun 2, 2025

It sounds like we would need an optional feature here. Because you'd want a way for people who've opted into never using the event dispatcher to avoid seeing a warning.

A single optional feature could:

  • disable the global event dispatcher
  • remove the assertion as in this PR
  • make all the things that would have relied on the global event dispatcher throw instead

@kategengler
Copy link
Member

I think we'd want that if we were to actually deprecate the event dispatcher, but in this case, it would only warn when you create nested applications, which would enable @NullVoxPopuli's explorations.

@NullVoxPopuli
Copy link
Contributor Author

changed to warn here: #20915 -- this will allow me to remove my patch in the new REPL stuff i'm working on

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants