CommonJS modules are not handled properly with ES6 star imports

Bug report

A star import should always resolve to a module object in ES6 module land. However, when importing CommonJS modules, webpack does not behave this way.

If the current behavior is a bug, please provide the steps to reproduce.

Create these two files:

// ./src/index.js
import * as thing from "./cjs.js";

console.log(thing);
// ./src/cjs.js
module.exports = function() {
  return 4;
}

then do

$ webpack
$ node ./dist/main.js`

What is the current behavior?

thing is a function.

What is the expected behavior?

thing should be a Module (or at least an object):

{
  default: function() {/*...*/}
}

Other relevant information:
webpack version: 4.8.3
Node.js version: 10
Operating System: Mac OS 10.13.4
Additional tools:

Author: Fantashit

1 thought on “CommonJS modules are not handled properly with ES6 star imports

Comments are closed.