简体   繁体   中英

Why this import line doesn't have an export

I just learned import/export for JS today but I saw this code from here but it uses something like,

import { modal, configure } from 'web3-login';

But I thought it was supposed to be like,

import { modal, configure } from './web3-login.js';

What does web3-login mean? It is a shorthand?

And also, I can't an export anywhere in the code. I thought we should have like,

export function modal()

How come?

UPDATE: I originally found the file when I downloaded from - wordpress.org/plugins/ethpress but it doesn't use node. It's just a WordPress plugin. And there're no traces of web3-login text in a function or export.

-- when you are importing from node_modueles you use just package folder name like 'web3-login'

-- when you import some exported function from your project structure you use './web3-login.js'. this means you are importing some function that is exported from same directory that you are currently into.

It uses web3-login instead of ./web3-login.js because it's downloaded with npm (Node Package Manager). If you were trying to import a local file you have created yourself in your folder structure you would use: ./web3-login.js but because it's now referring to a npm package you won't have to write more than just the package name.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM