How to import React component from node_modules without using babel

Viewed 67

I can not import a React component from a different repo.

Steps I followed:

  1. added the repo as submodule: git submodule add <remote-url>
  2. added a symlink: npm link (name of the repo is "submodule-repo" )

I can see created module in node_modules of the main project.

mainReactProject 
  /.git
  /node_modules
     /submodule-repo
        /node_modules
        /public
        /src
            /theButton
                /theButton.js 
        /...

When I try to import the component file as:

import newButton from 'submodule-repo/sec/theButton/theButton'

I receive an error:

Support for the experimental syntax 'jsx' isn't currently enabled (7:9):

When I searched for it most people say configure babel. However I do not even use babel in both projects. Nevertheless I tried but creating .babelrc, installing and adding

{
   "plugins": [
       ["@babel/plugin-syntax-jsx"]
   ]
}

or

{
   "presets": ["@babel/preset-env", "@babel/preset-react"]
}

also did not work. Should I install all babel packages to make this work or is there a way to not to use babel at all?

0 Answers
Related