Skip to content

Ability to set the default value of standalone #57829

Description

@anhallbe

Which @angular/* package(s) are relevant/related to the feature request?

core

Description

In this blog post it is communicated that the value for standalone will default to true in version 19.

This will likely break our application that depends on being able to dynamically loading external components. Most of these external components were not developed with standalone in mind, so they have relied on the implicit standalone: false up until now.

The components are loaded by:

  1. Import https://cdn-url/the-component.js
  2. the-component.js exports a @Component and an optional @NgModule
  3. Instantiate/compile the module with createNgModule() (unless the component is standalone)
  4. Instantiate/compile the component with ViewContainerRef.createComponent

After version 19, I'm assuming that the ViewContainerRef.createComponent or the createNgModule calls will fail, since the component now implicitly has standalone: true, but it is also declared in the @NgModule and has no imports.

Proposed solution

Perhaps one of:

  • Add an option to either createNgModule or createComponent where the default value can be overridden.
  • Allow standalone components to be part of a NgModule declarations array, and make them inherit the NgModule imports or something.

This is all based on a lot of assumptions since as far as I can tell the new default isn't implemented yet. So I'm not sure what a good solution looks like (or even if one is needed).

Alternatives considered

None yet

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreIssues related to the framework runtimecross-cutting: standaloneIssues related to the NgModule-less worldneeds: clarificationThis issue needs additional clarification from the reporter before the team can investigate.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions