D
D
Diman Suvorkin2022-03-19 21:06:21
Node.js
Diman Suvorkin, 2022-03-19 21:06:21

Does Node.js wrap default imports in an object?

Hello! I can not figure out one nuance.
There is a simple package.json (with type: module)

{
  "name": "name",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "redux-thunk": "^2.4.1"
  },
  "type": "module"
}

And a simple test.js file
import thunk from 'redux-thunk'
console.log(thunk)

I execute node test.js, outputs the following to the console:
{
  default: [Function: middleware] {
    withExtraArgument: [Function: createThunkMiddleware]
  }
}

Why does it wrap in an object with a default field?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question