Skip to content
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

Optional explicit modules #979

Merged
merged 1 commit into from
Sep 11, 2024
Merged

Optional explicit modules #979

merged 1 commit into from
Sep 11, 2024

Conversation

ef4
Copy link
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
11 checks passed
@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