Home > Back-end >  What is this style of import, that names no symbols and lacks the `from` keyword?
What is this style of import, that names no symbols and lacks the `from` keyword?

Time:03-19

// file api_setup.js
import { ApiProxy } from "vendor-lib"

ApiProxy.configure({ /* ... */ })

export { ApiProxy }
// file service.js
import "./api_setup" // ?

/* ... */

I believe this is old code, so I looked at the NodeJS doc on import from a few years ago, and it doesn't cover anything like import "./api_setup".

What is this style of import called? What does it do?

CodePudding user response:

See the MDN documentation for import:

Import a module for its side effects only

Import an entire module for side effects only, without importing anything. This runs the module's global code, but doesn't actually import any values.

import '/modules/my-module.js';
  • Related