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.

Babel transpile JSX to JS - Handling for different file extensions

See original GitHub issue

I use Babel CLI for production to compile my ES6 code to ES5. The files with the extension .jsx be compiled to .js. The server will only recognize the .jsx ending. How do you solve the problem?

  server.views({
    engines: {
      jsx: HapiReactViews,
    },
    compileOptions: {
      doctype: '',
    },
    relativeTo: __dirname,
    path: 'views',
  });

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
danielbayerleincommented, Mar 14, 2017

@ThiagoMiranda Nice to hear that it works. 👍

1reaction
ThiagoMirandacommented, Mar 14, 2017

@danielbayerlein Sorry to bother you in this issue but I’m experiencing the same issue here and when I add js: HapiReactViews in my engines configuration object I got an error: Unknown extension and no defaultExtension configured for view template: Default ( my original file is name Default.jsx ).

In my view route I just put reply.view('Default') so do I have to write an extension? If so, how did you deal with it? Using a env argument? Thanks

Update: solved it with the defaultExtension option on the server.views

Read more comments on GitHub >

github_iconTop Results From Across the Web

Compile .jsx files instead of .js using babel - Stack Overflow
It will run babel loader on the .jsx files, instead of .js files. If you want to transpile both .js and .jsx ,...
Read more >
babel/plugin-transform-react-jsx
Automatic runtime is a feature added in v7.9.0 . With this runtime enabled, the functions that JSX compiles to will be imported automatically....
Read more >
Using jsx in .jsx files not achievable -- Babel presets aren't used
.jsx files' jsx code should be transpiled according to the tsconfig's jsx option or there should be another way to achieve this.
Read more >
Three ways to use Babel with React - JavaScript in Plain English
1: Transpile JSX syntax using react preset. 2: Transpile template literal using template ... 3: let babel-loader to handle JavaScript files.
Read more >
Build a Modern JS Project - #6 Babel & React - YouTube
In this video, we'll enable transpilation of ES6+ and JSX syntax in our project. We'll start by configuring ESLint rules for React via ......
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