Skip to content

Optional explicit modules#979

Merged
ef4 merged 1 commit intomainfrom
explicit-modules
Sep 11, 2024
Merged

Optional explicit modules#979
ef4 merged 1 commit intomainfrom
explicit-modules

Conversation

@ef4
Copy link
Copy Markdown
Contributor

@ef4 ef4 commented Sep 11, 2024

This creates an alternative way to give the resolver access to your modules.

export default class App extends Application {
  modulePrefix = config.modulePrefix;
-  Resolver = Resolver;
+  Resolver = Resolver.withModules(modulesGoHere) 
}

It expects a POJO with string keys and instantiated modules as values. It's intentionally eager to keep the rest of the public resolver API the same while being compatible with real ES module systems. An example of how you'd get the modulesGoHere value is to derive it from import.meta.glob(..., { eager: true }) or to use a virtual backward-compatibility set of modules provided by embroider.

When you use withModules, the resolver will not attempt to touch require or requirejs, meaning your app can function entirely without an AMD loader.

@ef4 ef4 merged commit fb11f7c into main Sep 11, 2024
@ef4 ef4 deleted the explicit-modules branch September 11, 2024 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant