📝 This is a draft PR to stop using require to load initializers, it proposes an implementation but if we want to merge it at some point we'll also have to clean up the types.
Context: This PR was drafted in the context of the Embroider Initiative. At some point, we thought we would need it to support initializers when building with Embroider + Vite. It turns out we didn't have to go that far to get initializers work, but this PR can still be interesting in the context of Strict ES Module Support RFC.
How to use: The idea is to pass the app modules to the loadInitializers function directly, with a new argument compatModules. The app.js file of an Ember app would look like this:
// my-ember-app/app/app.js
import compatModules from '@embroider/core/entrypoint';
// Define modules imported from Embroider internals
let d = window.define;
for (const [name, module] of Object.entries(compatModules)) {
d(name, function () {
return module;
});
}
export default class App extends Application { /* modulePrefix = ... */ }
// Pass modules to loadInitializers
loadInitializers(App, config.modulePrefix, compatModules);
📝 This is a draft PR to stop using
require
to load initializers, it proposes an implementation but if we want to merge it at some point we'll also have to clean up the types.Context: This PR was drafted in the context of the Embroider Initiative. At some point, we thought we would need it to support initializers when building with Embroider + Vite. It turns out we didn't have to go that far to get initializers work, but this PR can still be interesting in the context of Strict ES Module Support RFC.
How to use: The idea is to pass the app modules to the
loadInitializers
function directly, with a new argumentcompatModules
. Theapp.js
file of an Ember app would look like this: