webpack-contrib/expose-loader

[Refactor] Support exposing ESM without `harmony` export

benirose opened this issue · 3 comments

I'm using expose-loader to expose some ES6 modules, which are currently using export default {...}, however instead of getting the resource at my exposed variable, it's at module.default. Here's my require:

require("expose-loader?Store!./store/index.js");

And here's my export:

export default new Vuex.Store({
...
})

My module is now exposed at Store.default.

Is this just a side effect of ES6 modules or is there a way to expose the default directly on the variable?

No the loader still uses CJS internally so your exposed file becomes a harmony export atm. We could/should update this to use ESM instead, but needs triage

Is there any work around for this issue? I've refactored code today and this issue has reared its head for me...

@michael-ciniawsky how does #85 look? Will this solve this issue?