Open mehulkar opened 3 years ago
It seems that ember-cli may not be using the default export, and it's just using the named export, but I'm not sure if the object here is the module or not.
This function only seems to be called when I enable Embroider builds, not in regular ember-cli builds, so I'm not sure if this is intentional or what the expectations are.
I don't fully understand what you mean here. Are you saying that in ember-cli
's build pipeline that initialize
function is never invoked, but in Embroiders it is invoked? Or are you saying the reverse (called in ember-cli pipeline but not in Embroider)?
I believe these are related references:
This function only seems to be called when I enable Embroider builds, not in regular ember-cli builds, so I'm not sure if this is intentional or what the expectations are.
I don't fully understand what you mean here.
I was totally wrong here. the function is called in both.
The difference seems to be that when the default export is missing, with regular ember builds, module.default
is circular:
{ initialize: [Function: initialize], default: [Circular] }
So it doesn't cause a crash while registering the initializers.
With Embroider, maybe require
is being changed, causing the circular structure not to happen?
I've made simple repro here (see commit history): https://github.com/mehulkar/embroider-initializer-crash. The easiest workaround is to just add the default exports into my initializers, but I think resolveInitializer
should explicitly throw when module.default
is undefined, so that adopting Embroider doesn't cause this, kind of hard to track problem.
Right, you are describing the same thing that is described in the issues I linked in my initial comment. If you use the flag to disable the default export munging in loader.js
you will have the same behavior in both worlds.
How do I use this flag? I looked ovr that issue but don't see how to do it from the standpoint of ember-cli. Not sure where loader.js gets invoked.
If you have an initializer that does not have a default export:
resolveInitializer
crashes here:https://github.com/ember-cli/ember-load-initializers/blob/b69de85ab66bfa0d857b8165e5bbc7769fba8382/addon/index.ts#L15-L16
This function only seems to be called when I enable Embroider builds, not in regular ember-cli builds, so I'm not sure if this is intentional or what the expectations are.
ember-cli could be stricter and require this default export, but if it's intentional to not require the default export, then
resolveInitializer
should handle this case as well?