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.

Having trouble compiling this library in a typescript react project targetting es5

See original GitHub issue

I’m not completely sure what’s causing this, but I wonder if it’s because this project seems to be targetting esnext? The current project I’m on has es5 as the target. The only thing that seems to fix the compilation error below is to set my target to esnext, but that introduces other errors in other files in my project.

./node_modules/react-diff-viewer/lib/styles.js
Module parse failed: Unexpected token (5:42)
You may need an appropriate loader to handle this file type.
| const emotion_1 = require("emotion");
| exports.default = (styleOverride) => {
|     const { variables: overrideVariables, ...styles } = styleOverride;
|     const variables = {
|         ...{

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rokorokucommented, Dec 9, 2019

I made the target as esnext because I wanted the lib files to include all latest syntax. Then, the consumer can change their target according to their needs.

@praneshr I think It’s better to indicate this module is targeted to ESNEXT in README file, so that we can add this module to the transpiling target.

1reaction
andresmgotcommented, Nov 12, 2019

same issue here, I am using react-scripts-ts so I cannot change the webpack configuration. Any suggestion?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to have Typescript target ES5 with React in Webpack?
The answer is, you can't. Babel can transpile ES7 to ES6. But it can't transpile ES6 to ES5, for that it uses a...
Read more >
TSConfig Option: target - TypeScript
The target setting changes which JS features are downleveled and which are left intact. For example, an arrow function () => this will...
Read more >
Compiling and bundling TypeScript libraries with Webpack
This way we have all the es6 typings while targeting es5 . "outDir": "lib". The compiled source is going to be saved into...
Read more >
Publishing Node modules with TypeScript and ES modules
Its typing system and compiler are able to catch a variety of bugs at compile time before your software has even run, and...
Read more >
Content Types - ESBuild
ts files) is not supported. If you are writing a library in TypeScript and you want to publish the compiled JavaScript code as...
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