S
S
Sergey2021-06-01 18:14:35
React
Sergey, 2021-06-01 18:14:35

How to import from component library repository?

There are 2 projects.
They should have one React + Next component library stored in the gitlab repository. I register the library as a package in package.json.

"dependencies": {
    "my-ui-kit": "git+https://gitlab.com/frontend/ui-kit-react.git#master",
  }

In node_modules it is fully loaded. With this ok.
But how to get a specific component from the list? The architecture of the library is as follows -
60b6490be63cd136270569.png
In the Components folder - folders for each component containing js and scss files.
The index.js file looks like, in theory, components should be drawn from it.
60b649fa5d335810478292.png
I'm trying to import from the library already into the project like this -
import { Button } from 'my-ui-kit';
Error when building crashes - SyntaxError: Cannot use import statement outside a module

How to organize the library correctly? And how in the components then install additional packages for their work?
After all, the node_modules folder does not go into the repository. It is unlikely that it should be removed from gitignore. As an option, throw the package code in a separate file and refer to it already.

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