What does "@" mean before importing into React?

I will see imports in React that look like this:

import {object} from '@library/component' 

What is @ and what is this import? Thanks!

+5
source share
2 answers

These are cloud packages.

Scopes are a way of grouping related packages together, and also affect some things about how npm processes the package.

The import uses a specially named import against the default import, which can be used to export the namespace.

+6
source

It is not limited to Reactivity only, but it is also part of npm and many other frameworks (Angular, etc.). In addition to what Lance mentioned here, there are some advantages to this.

  • We need not worry if a name exists - just name it.
  • We do not need to worry about someone else posting in our area of ​​action - only members of the area have permission.
  • We do not need to switch the npm registry to install and publish packages - we assign a specific registry for the area.
+2
source

Source: https://habr.com/ru/post/1276167/


All Articles