question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JSX (TSX) not resolved

See original GitHub issue

Hi, I’m trying to make this work with my project, but again I cannot make the JSX to resolve.

On contrary to #92 when I add ‘import ./a.jsx’ it works for jsx but that’s not the solution as I need it to import by default. The TS and TSX solution does not work at all as it is not even resolving TS and TSX to supply to “ts-loader”

I even added my own webpack.config.js with a following content but I still have to explicitly specify import ./a.jsx. This is a no-go for me since I’m compiling files from typescript.

const path = require('path');
module.exports = {
  module: {
    resolve: {
      extensions: ['', '.js', '.jsx']
    },
    loaders: [
      {
        test: /\.jsx?$/,
        loader: 'babel',
        query: { presets: ['react', 'es2015', 'stage-2'] },
        exclude: [path.resolve('./node_modules'), path.resolve(__dirname, 'node_modules')],
        include: [path.resolve('./'), __dirname],
      },
      {
        test: /\.css?$/,
        loaders: [ 'style', 'raw' ],
        include: path.resolve(__dirname, '../')
      }
    ]
  }
};

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
tomitrescakcommented, Apr 21, 2016

SOLVED. I disected the way you compose the final config and following works (please see the “resolve” section in the parent of the child configuration):

const path = require('path');
module.exports = {
  resolve: {
    extensions: ['', '.js', '.jsx']
  },
  module: {
    loaders: [
      {
        test: /\.css?$/,
        loaders: [ 'style', 'raw' ],
        include: path.resolve(__dirname, '../')
      }
    ]
  }
};
0reactions
mkozhukharenkocommented, Sep 6, 2016

@tomitrescak, try to add few more lines to your code:

module.exports = (storybookBaseConfig, configType) => {
  /* you code */
  storybookBaseConfig.ts = {
    configFileName: path.resolve(__dirname, '../path-to-ts-config.json')
  }
  return storybookBaseConfig;
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

React can't resolve .tsx files - Stack Overflow
I just came across this problem as well, with a brand new React project. Temporarily downgrading react-scripts from version 5.0.0 to 4.0.3 ...
Read more >
TypeScript source resolution does not work with jsx #6866
js it will not resolve to ./MyComponent.tsx it will try and look for ./MyComponent.ts which does not exist. I believe the issue is...
Read more >
Module not found: Can't resolve 'react/jsx-runtime' | bobbyhadz
To solve the error "Module not found: Error: Can't resolve 'react/jsx-runtime'", make sure to update the react package by opening your terminal in...
Read more >
Troubleshooting | React Navigation
Sometimes it might even be due to a corrupt installation. If clearing cache didn't work, try deleting your node_modules folder and run npm...
Read more >
Tutorial: Create a Node.js and React app in Visual Studio
tsx and not webpack:///./app.tsx, which prevents the Visual Studio debugger from locating app.tsx. Or, try using the debugger; statement in app.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found