Do you want to request a feature or report a bug?
Bug.
What is the current behavior?
If you require a package with a module field in its package.json, and the module has an export default, the require call does not return the default export like it should.
Instead, it returns an object with default and all properties.
Both of these forms will return the default export:
const merge = require('deepmerge').default
import merge from 'deepmerge'
If the current behavior is a bug, please provide the steps to reproduce.
Reproduction at https://github.com/perry-mitchell/repo-deepmerge-webpack
What is the expected behavior?
require('any-esm-module') should return the default export.
For many Webpack users, require('any-esm-module').default is not even an option, since they are importing a package that depends on some CJS/ESM module (like deepmerge).
Please mention other relevant information such as the browser version, Node.js version, webpack version, and Operating System.
Tested with Webpack 3.11.0 and 4.0.0.
Edit: per the discussion below, my original report above is incorrect.
What should probably happen: require('my-module') should import the main (or browser) entry point in the package.json file.
What happens now: require('my-module') imports the module entry point in the package.json file.
Do you want to request a feature or report a bug?
Bug.
What is the current behavior?
If you
requirea package with amodulefield in its package.json, and the module has anexport default, therequirecall does not return the default export like it should.Instead, it returns an object with
defaultandallproperties.Both of these forms will return the default export:
If the current behavior is a bug, please provide the steps to reproduce.
Reproduction at https://github.com/perry-mitchell/repo-deepmerge-webpack
What is the expected behavior?
require('any-esm-module')should return the default export.For many Webpack users,
require('any-esm-module').defaultis not even an option, since they are importing a package that depends on some CJS/ESM module (like deepmerge).Please mention other relevant information such as the browser version, Node.js version, webpack version, and Operating System.
Tested with Webpack 3.11.0 and 4.0.0.
Edit: per the discussion below, my original report above is incorrect.
What should probably happen:
require('my-module')should import themain(orbrowser) entry point in the package.json file.What happens now:
require('my-module')imports themoduleentry point in the package.json file.