Skip to content

[META] Embroider Readiness #19099

Open
Open
@wycats

Description

@wycats

Today, Embroider in compatibility mode can be used in new applications and in many existing applications. It is more difficult to use Embroider in staticComponents, mode, which is necessary to get the benefit of splitAtRoutes mode.

Issue #501 on the Embroider repository tracks the remaining issues needed to stabilize Embroider as a part of an Ember.js release.

This issue tracks the steps that we need to take before people can practically use Ember with Embroider as a supported option with route-based code splitting ("Embroider readiness"). While there are many granular ways to use Embroider (including a compatibility mode that offers few concrete benefits but is important for migrating Ember itself to Embroider by default), this issue is focused on the ability to use Embroider with a normal Ember application and get benefits from route-based code splitting.

Technical Requirements

As described in the Embroider README, in order to enable route-based code splitting (splitAtRoutes), an application must be able to enable these flags:

  • staticAddonTestSupportTrees
  • staticAddonTrees
  • staticHelpers
  • staticComponents

If an addon or application cannot work in the presence of these flags, they are using "classic dynamic features".

MVP: Deprecate and replace (component dynamicString)

For the first target of Embroider readiness ("MVP"), we need to eliminate the most common roadblocks that we've found when trying to enable the static flags in real-world applications.

For the MVP milestone, it is a non-goal for all ecosystem addons support these flags.

Instead, the goal is for applications to have a reasonable transition path to splitAtRoutes, and that it's possible to build substantial, non-trivial applications in that mode. That means that all addons included in the default blueprint must have migrated away from classic dynamic features. It also means that addons that are frequently used in real-world applications, such as Ember concurrency, must not use classic dynamic features.

staticComponents

This is the most important static flag, and its requirement poses the most substantial obstacle to the MVP target.

In order to enable staticComponents, an application (including its addons) must be free of all uses of (component dynamicString).

Importantly, applications and their addons are allowed to use (component "static string") in staticComponents mode.

In practice, this means that we will need to migrate away from patterns like this:

{{#let (component this.componentName) as | Component |}}

Addons that currently take strings as part of their public API will need to, instead, take components, which would mean that this addon would need to migrate to an approach that required their users to supply the component to invoke, rather than a string.

This is a particularly thorny situation, since this.component is defined as this.componentName = scaffolding/${dasherize(csId!)}/${dasherize(this.args.feature)}. Situations like this are precisely the reason that we will need to think about and carefully roll out a transition strategy.

At minimum, in order to allow addons to migrate away from (component dynamicString), we will need to create a new version of the component keyword that does not allow invocation of dynamic components.

Additionally, we need to fix a bug that inadvertantly allows component invocation with angle-bracket syntax to work the same way as the dynamic component keyword. This needs to be done soon, because once people begin to try to migrate away from (component dynamic), there's a high likelihood that people will accidentally migrate to <dynamic>, observe that it works, and move on.

Action items:

  • Design and release a new version of (component) that only supports static strings (requires RFC)
  • Fix the bug that allows angle bracket invocation to behave like dynamic component invocation in Ember (bugfix, perhaps an intimate API)

staticHelpers

The staticHelpers flag does not reduce the expressiveness of Ember templates, but it means that the entire list of an application's helpers will not be available in the set of modules in the loader.

We assume that this will have breaking effects on Ember applications, but many fewer problems than staticComponents. We don't currently expect staticHelpers to affect the MVP target, but that may change as we attempt to upgrade applications to splitAtRoutes. If that happens, we will need to evaluate the problematic use-cases and consider new APIs to facilitate migration.

staticAddonTrees and staticAddonTestSupportTrees

The current assumption is that these flags are compatible with most idiomatic Ember apps and addons, and therefore do not pose any substantial problems for the requirements of the MVP target.

Next Steps

This issue is intended to remain as a tracking issue after we achieve the MVP target. After the MVP target, we will need to facilitate a complete ecosystem migration and improve the ergonomics of dynamic use-cases (which retaining support for code splitting). Template imports is likely to help achieve these goals.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions