webpack-contrib/expose-loader

expose ES6 modules

gunnim opened this issue ยท 4 comments

When exposing an es6 module i get a global object with a property named default which represents the export.

I would like to be able to skip this wrapper and have the global variable = default export. no abstraction/wrapper.

As it stands I find myself creating intermediate modules with the following syntax
module.exports = require('./filename').default;

and then
require('expose-loader?LibraryName!./intermediateFile');

Is there a simple solution to this problem?
If not, are there any plans for a fix?

@gunnim Yep we plan to export ES2015 Modules by default in the next major releases of all loaders, but since this is a breaking change and we try to it in one batch, will take some time

Meanwhile you could change this line #20 yourself and it should work ๐Ÿ˜›

module.exports = ... => export default ...

Deduced the following after inspecting the webpack bundle
global["LibraryName"] = require('./fileName').default;

Is this syntax safe to use with webpack or is this subject to change?

Not in the near future, but no guarantees either ๐Ÿ˜›. It's the internal way webpack handles ES2015 Modules (webpack is a still node module (CJS)). Should be fine atm

Alright, thanks for the quick support :)