Create React App with TypeScript to compile code from node_modules

Viewed 370

I created the new project using CRA with typescript. I added npm dependency from my private repository in package.json common-ui": "git@github.com:someorg/common-ui.git#develop" because I want to reuse some code between 2 projects. I this repo I have a simple file structure. I just want to include some files in 2 projects because they are common. I'm not able to get it to work together. I get 'You may need an appropriate loader to handle this file type' error. So I ejected CRA and I changed webpack config like this

            // Process application JS with Babel.
            // The preset includes JSX, Flow, TypeScript, and some ESnext features.
            {
              test: /\.(js|mjs|jsx|ts|tsx)$/,
              include: paths.appPath,
              loader: require.resolve('babel-loader'),

I wanted to included all files in babel-loader. Now I'm getting another error 'SyntaxError: ...Unexpected token'. Looks like it doesn't recognise TypeScript. Any idea how to make it work? App created with CRA and TypeScript repo included with npm.

0 Answers
Related